예제 #1
0
    def test_next_with_conditional_path(self):
        survey = load_schema_file("0_star_wars.json")

        expected_path = [
            "f22b1ba4-d15f-48b8-a1f3-db62b6f34cc0",
            "96682325-47ab-41e4-a56e-8315a19ffe2a",
            "cd3b74d1-b687-4051-9634-a8f9ce10a27d",
            "an3b74d1-b687-4051-9634-a8f9ce10ard",
            "846f8514-fed2-4bd7-8fb2-4b5fcb1622b1"
        ]

        answers = {
            "ca3ce3a3-ae44-4e30-8f85-5b6a7a2fb23c": "Light Side",
            "2e0989b8-5185-4ba6-b73f-c126e3a06ba7": "No"
        }

        current_block_id = expected_path[1]
        expected_next_block_id = expected_path[2]

        navigator = Navigator(survey)
        actual_next_block_id = navigator.get_next_location(answers, current_block_id)

        self.assertEqual(actual_next_block_id, expected_next_block_id)

        current_block_id = expected_path[2]
        expected_next_block_id = expected_path[3]
        actual_next_block_id = navigator.get_next_location(answers, current_block_id)

        self.assertEqual(actual_next_block_id, expected_next_block_id)
예제 #2
0
    def test_next_location_empty_routing_rules(self):
        survey = load_schema_file("test_checkbox.json")
        navigator = Navigator(survey)

        # Force some empty routing rules
        navigator.blocks[0]['routing_rules'] = []

        expected_path = [
          'introduction',
          'f22b1ba4-d15f-48b8-a1f3-db62b6f34cc0',
          'f22b1ba4-d15f-48b8-a1f3-db62b6f34cc1',
          'summary'
        ]

        answers = {
          "ca3ce3a3-ae44-4e30-8f85-5b6a7a2fb23c": "Cheese",
          "ca3ce3a3-ae44-4e30-8f85-5b6a7a2fb23": "deep pan",
        }

        current_location_id = expected_path[1]
        expected_next_location_id = expected_path[2]

        next_location_id = navigator.get_next_location(answers, current_location_id)

        self.assertEqual(next_location_id, expected_next_location_id)
예제 #3
0
    def test_next_block(self):
        survey = load_schema_file("1_0102.json")

        current_block_id = "7418732e-12fb-4270-8307-5682ac63bfae"
        next_block_id = "02ed26ad-4cfc-4e29-a946-630476228b2c"

        navigator = Navigator(survey)
        self.assertEqual(navigator.get_next_location(current_location_id=current_block_id), next_block_id)
예제 #4
0
    def test_get_next_location_introduction(self):
        survey = load_schema_file("0_star_wars.json")

        navigator = Navigator(survey)

        next_location = navigator.get_next_location(current_location_id='introduction')

        self.assertEqual('f22b1ba4-d15f-48b8-a1f3-db62b6f34cc0', next_location)
class TestConfirmationPage(unittest.TestCase):
    def setUp(self):
        survey = load_schema_file("0_rogue_one.json")

        self.navigator = Navigator(survey)

    def test_get_next_location_confirmation(self):
        current_location_id = "5e633f04-073a-44c0-a9da-a7cc2116b937"
        answers = {"ca3ce3a3-ae44-4e30-8f85-5b6a7a2fb23c": "Orson Krennic"}
        next_location = self.navigator.get_next_location(answers, current_location_id)
        self.assertEqual("summary", next_location)
예제 #6
0
    def test_get_next_location_summary(self):
        survey = load_schema_file("0_star_wars.json")

        navigator = Navigator(survey)

        answers = {
            "ca3ce3a3-ae44-4e30-8f85-5b6a7a2fb23c": "Light Side",
            "2e0989b8-5185-4ba6-b73f-c126e3a06ba7": "No"
        }

        current_location_id = 'an3b74d1-b687-4051-9634-a8f9ce10ard'
        next_location_id = navigator.get_next_location(answers, current_location_id)
        expected_next_location_id = '846f8514-fed2-4bd7-8fb2-4b5fcb1622b1'

        self.assertEqual(expected_next_location_id, next_location_id)

        current_location_id = '846f8514-fed2-4bd7-8fb2-4b5fcb1622b1'
        next_location_id = navigator.get_next_location(answers, current_location_id)
        expected_next_location_id = 'summary'

        self.assertEqual(expected_next_location_id, next_location_id)
예제 #7
0
    def test_next_location_goto_summary(self):
        survey = load_schema_file("0_star_wars.json")
        navigator = Navigator(survey)

        expected_path = [
            'introduction',
            'f22b1ba4-d15f-48b8-a1f3-db62b6f34cc0',
            'summary'
        ]

        answers = {
            "ca3ce3a3-ae44-4e30-8f85-5b6a7a2fb23c": "I prefer Star Trek"
        }

        current_location_id = expected_path[1]
        expected_next_location_id = expected_path[2]

        next_location_id = navigator.get_next_location(answers, current_location_id)

        self.assertEqual(next_location_id, expected_next_location_id)