38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
import json
|
|
|
|
from rest_framework.test import APITestCase
|
|
|
|
from vbv_lernwelt.core.create_default_users import create_default_users
|
|
from vbv_lernwelt.core.models import User
|
|
from vbv_lernwelt.learnpath.models import LearningContent
|
|
from vbv_lernwelt.learnpath.tests.create_default_learning_path import create_default_learning_path
|
|
from vbv_lernwelt.learnpath.tests.test_create_default_learning_path import create_locales_for_wagtail
|
|
|
|
|
|
class CompletionApiTestCase(APITestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
super(CompletionApiTestCase, cls).setUpClass()
|
|
create_locales_for_wagtail()
|
|
create_default_users()
|
|
create_default_learning_path()
|
|
|
|
def setUp(self) -> None:
|
|
self.user = User.objects.get(username='student')
|
|
self.client.login(username='student', password='student')
|
|
|
|
def test_completeLearningContent_works(self):
|
|
learning_content = LearningContent.objects.get(title='Einleitung Circle "Anlayse"')
|
|
learning_content_key = str(learning_content.translation_key)
|
|
circle_key = str(learning_content.get_parent().translation_key)
|
|
|
|
response = self.client.post(f'/api/completion/complete_learning_content/', {
|
|
'learning_content_key': learning_content_key
|
|
})
|
|
response_json = response.json()
|
|
print(json.dumps(response.json()))
|
|
|
|
self.assertEqual(response.status_code, 201)
|
|
self.assertEqual(response_json['circle_key'], circle_key)
|
|
self.assertEqual(response_json['json_data']['completed_learning_contents'][learning_content_key]['learning_content_key'], learning_content_key)
|