skillbox/server/notes/tests/test_find_content.py

71 lines
2.6 KiB
Python

import json
from django.test import TestCase
from books.factories import InstrumentFactory, ContentBlockFactory, ModuleFactory
from notes.models import InstrumentBookmark
from notes.schema import find_content, find_content_bfs
from users.models import User
from users.services import create_users
class TestFindContentBfs(TestCase):
def setUp(self):
self.data = [
{
"id": "45c5d9e7-233b-4ec7-a539-4136f2f969a4",
"type": "content_list_item",
"value": [
{
"id": "4eb6a9ec-576a-4bec-8eb7-798ac21e88cd",
"type": "text_block",
"value": {"text": "<p>Schauen Sie sich die</p>"}
},
{
"id": "718bee9a-5f92-4e3d-b7f8-aa63b8f2497e",
"type": "link_block",
"value": {"url": "https://skilM2_A2_Studie.pdf", "text": "Studie anzeigen"}
}
]
},
{
"id": "6a72b706-5ad7-4c8b-9fa1-e89909a2a5e6",
"type": "content_list_item",
"value": [
{
"id": "b7cd58c7-3131-4e3c-a51a-cd0026be03f8",
"type": "assignment",
"value": {"assignment_id": 204}
}
]
}
]
def test_content_from_content_list_item_sub_item(self):
result = find_content_bfs(self.data, "4eb6a9ec-576a-4bec-8eb7-798ac21e88cd")
self.assertEqual( {
"id": "4eb6a9ec-576a-4bec-8eb7-798ac21e88cd",
"type": "text_block",
"value": {"text": "<p>Schauen Sie sich die</p>"}
}, result)
def test_content_from_content_list_item(self):
result = find_content_bfs(self.data, "45c5d9e7-233b-4ec7-a539-4136f2f969a4")
self.assertEqual( {
"id": "45c5d9e7-233b-4ec7-a539-4136f2f969a4",
"type": "content_list_item",
"value": [
{
"id": "4eb6a9ec-576a-4bec-8eb7-798ac21e88cd",
"type": "text_block",
"value": {"text": "<p>Schauen Sie sich die</p>"}
},
{
"id": "718bee9a-5f92-4e3d-b7f8-aa63b8f2497e",
"type": "link_block",
"value": {"url": "https://skilM2_A2_Studie.pdf", "text": "Studie anzeigen"}
}
]
}, result)