def test_section_modification(self): content = ContentBuilder([{ "name": "First section", "questions": [ { "question": 'First question', "depends": [{ "on": "lot", "being": ["SCS", "SaaS", "PaaS"] }] }, { "question": 'Second question', "depends": [{ "on": "lot", "being": ["IaaS"] }] }, ] }]) content2 = content.filter({"lot": "IaaS"}) assert len(content.sections[0]["questions"]) == 2 assert len(content2.sections[0]["questions"]) == 1
def test_a_question_which_shouldnt_be_shown(self): content = ContentBuilder([{ "name": "First section", "questions": [{ "question": 'First question', "depends": [{ "on": "lot", "being": ["SCS", "SaaS", "PaaS"] }] }] }]) assert len(content.filter({"lot": "IaaS"}).sections) == 0
def test_a_question_which_depends_on_one_of_several_answers(self): content = ContentBuilder([{ "name": "First section", "questions": [{ "question": 'First question', "depends": [{ "on": "lot", "being": ["SCS", "SaaS", "PaaS"] }] }] }]) assert len(content.filter({"lot": "SaaS"}).sections) == 1 assert len(content.filter({"lot": "PaaS"}).sections) == 1 assert len(content.filter({"lot": "SCS"}).sections) == 1
def test_get_section(self): content = ContentBuilder([{ "id": "first_section", "name": "First section", "questions": [ { "question": 'First question', "depends": [{ "on": "lot", "being": ["SCS", "SaaS", "PaaS"] }] } ] }]) assert content.get_section( "first_section").get("id") == "first_section" content = content.filter({"lot": "IaaS"}) assert content.get_section("first_section") is None
def test_that_filtering_is_cumulative(self): content = ContentBuilder([{ "name": "First section", "questions": [ { "question": 'First question', "depends": [{ "on": "lot", "being": ["SCS", "SaaS", "PaaS"] }] }, { "question": 'Second question', "depends": [{ "on": "lot", "being": ["SCS", "IaaS"] }] }, { "question": 'Third question', "depends": [{ "on": "lot", "being": ["SaaS", "IaaS"] }] }, ] }]) content = content.filter({"lot": "SCS"}) assert len(content.sections[0]["questions"]) == 2 content = content.filter({"lot": "IaaS"}) assert len(content.sections[0]["questions"]) == 1 content = content.filter({"lot": "PaaS"}) assert len(content.sections) == 0
def test_get_next_section(self): content = ContentBuilder([ { "id": "first_section", "name": "First section", "questions": [{ "question": 'First question', "depends": [{ "on": "lot", "being": ["SCS", "SaaS", "PaaS"] }] }] }, { "id": "second_section", "name": "Second section", "questions": [{ "question": 'First question', "depends": [{ "on": "lot", "being": ["SCS", "SaaS", "PaaS"] }] }] }, { "id": "third_section", "name": "Third section", "editable": True, "questions": [{ "question": 'First question', "depends": [{ "on": "lot", "being": ["SCS", "SaaS", "PaaS"] }] }] }, ]) assert content.get_next_section_id() == "first_section" assert content.get_next_section_id("first_section") == "second_section" assert content.get_next_section_id("second_section") == "third_section" assert content.get_next_section_id("third_section") is None assert content.get_next_editable_section_id() == "third_section" assert content.get_next_editable_section_id( "second_section") == "third_section"