Ejemplo n.º 1
0
    def test_course_with_multiple_english_and_welsh_locations(self):
        input_course = {
            "locations": [
                {
                    "name": {
                        "english": "Cardiff University",
                        "welsh": "Prifysgol Caerdydd",
                    }
                },
                {
                    "name": {
                        "english": "Cardiff Campus",
                        "welsh": "Campus Caerdydd"
                    }
                },
            ]
        }

        expected_search_locations = [
            {
                "name": {
                    "english": "Cardiff University",
                    "welsh": "Prifysgol Caerdydd"
                }
            },
            {
                "name": {
                    "english": "Cardiff Campus",
                    "welsh": "Campus Caerdydd"
                }
            },
        ]

        search_locations = build_locations(input_course)
        self.assertEqual(expected_search_locations, search_locations)
Ejemplo n.º 2
0
    def test_course_with_single_full_fat_location(self):
        input_course = {
            "locations": [{
                "name": {
                    "english": "Cardiff University",
                    "welsh": "Prifysgol Caerdydd",
                },
                "latitude": "-1.45638",
                "longitude": "14.9431",
            }]
        }

        expected_search_locations = [{
            "name": {
                "english": "Cardiff University",
                "welsh": "Prifysgol Caerdydd",
            },
            "geo": {
                "type": "Point",
                "coordinates": [14.9431, -1.45638]
            },
        }]

        search_locations = build_locations(input_course)
        self.assertEqual(expected_search_locations, search_locations)
Ejemplo n.º 3
0
    def test_course_with_multiple_geo_long_lats(self):
        input_course = {
            "locations": [
                {
                    "latitude": "-1.45638",
                    "longitude": "14.9431"
                },
                {
                    "latitude": "-1.84578",
                    "longitude": "12.4536"
                },
            ]
        }

        expected_search_locations = [
            {
                "geo": {
                    "type": "Point",
                    "coordinates": [14.9431, -1.45638]
                }
            },
            {
                "geo": {
                    "type": "Point",
                    "coordinates": [12.4536, -1.84578]
                }
            },
        ]

        search_locations = build_locations(input_course)
        self.assertEqual(expected_search_locations, search_locations)
Ejemplo n.º 4
0
    def test_course_with_one_welsh_location_only(self):
        input_course = {
            "locations": [{
                "name": {
                    "welsh": "Prifysgol Caerdydd"
                }
            }]
        }

        expected_search_locations = [{"name": {"welsh": "Prifysgol Caerdydd"}}]

        search_locations = build_locations(input_course)
        self.assertEqual(expected_search_locations, search_locations)
Ejemplo n.º 5
0
    def test_course_with_one_english_location_only(self):
        input_course = {
            "locations": [{
                "name": {
                    "english": "Bradford Campus"
                }
            }]
        }

        expected_search_locations = [{"name": {"english": "Bradford Campus"}}]

        search_locations = build_locations(input_course)
        self.assertEqual(expected_search_locations, search_locations)
Ejemplo n.º 6
0
    def test_course_with_geo_long_lats_only(self):
        input_course = {
            "locations": [{
                "latitude": "-1.45638",
                "longitude": "14.9431"
            }]
        }

        expected_search_locations = [{
            "geo": {
                "type": "Point",
                "coordinates": [14.9431, -1.45638]
            }
        }]

        search_locations = build_locations(input_course)
        self.assertEqual(expected_search_locations, search_locations)
Ejemplo n.º 7
0
    def test_course_with_empty_locations_object(self):
        input_course = {"locations": []}
        expected_search_locations = []

        search_locations = build_locations(input_course)
        self.assertEqual(expected_search_locations, search_locations)
Ejemplo n.º 8
0
    def test_course_without_locations(self):
        input_course = {}
        expected_search_locations = []

        search_locations = build_locations(input_course)
        self.assertEqual(expected_search_locations, search_locations)
Ejemplo n.º 9
0
    def test_course_with_only_lat_only(self):
        input_course = {"locations": [{"latitude": "-1.45638"}]}
        expected_search_locations = [{}]

        search_locations = build_locations(input_course)
        self.assertEqual(expected_search_locations, search_locations)
Ejemplo n.º 10
0
    def test_course_with_only_long_only(self):
        input_course = {"locations": [{"longitude": "14.9431"}]}
        expected_search_locations = [{}]

        search_locations = build_locations(input_course)
        self.assertEqual(expected_search_locations, search_locations)