Skip to content
Snippets Groups Projects

Resolve "Provide import functionality via frontend for reviewers"

Files
13
from rest_framework import status
from rest_framework.test import APIClient, APITestCase
from core.models import UserAccount, SubmissionType
from util.factories import GradyUserFactory
test_data = {
"meta": {
"version": "3.0.0"
"version": "4.0.0"
},
"module": {
"module_reference": "test",
@@ -49,10 +52,13 @@ test_data = {
class ImportViewTest(APITestCase):
factory = GradyUserFactory()
def setUp(self):
self.url = '/api/import/'
self.client = APIClient()
self.client.force_login(user='rev')
self.client.force_login(user=self.factory.make_reviewer())
def test_can_not_submit_nothing(self):
res = self.client.post(self.url)
@@ -65,4 +71,10 @@ class ImportViewTest(APITestCase):
def test_data_is_imported_correctly(self):
res = self.client.post(self.url, test_data)
sub_types = SubmissionType.objects.all()
students = UserAccount.objects.all().filter(role='Student')
self.assertEqual(2, len(sub_types))
self.assertEqual(1, len(students))
self.assertEqual(status.HTTP_201_CREATED, res.status_code)
Loading