Beispiel #1
0
    def test_output_not_identical_for_different_cities(self):
        """
        For selected systems, request information for two different cities
        supported and make sure they're not the same.

        Checks for silly errors like always returning data for the same city,
        no matter which city is requested.
        """
        for city in self.test_different_cities:
            first_city = systems.get_city_by_name(city[0], city[1][0])
            first_text, session = download.download_one_city(first_city)

            second_city = systems.get_city_by_name(city[0], city[1][1])
            second_text, session = download.download_one_city(second_city,
                                                              session=session)
            session.close()

            self.assertNotEqual(first_city, second_city)
Beispiel #2
0
    def test_car2go_get_text(self):
        for city in self.test_cities:
            city_data = systems.get_city_by_name(city[0], city[1])

            text, session = download.download_one_city(city_data)
            session.close()

            # could throw exception if JSON is malformed, test if it does
            info = json.loads(text)

            # assert there is something
            self.assertGreater(len(info), 0)
Beispiel #3
0
    def test_get_api_output_as_json(self):
        """
        Test that all systems specified successfully return a JSON object.

        NOTE: this currently assumes all systems output JSON.
        This assumption is baked fairly deeply into the project,
        in web_helper.get_electric_cars and
        in analysis.normalize.Electric2goDataArchive
        """
        for city in self.test_cities:
            city_data = systems.get_city_by_name(city[0], city[1])

            text, session = download.download_one_city(city_data)
            session.close()

            self._assert_api_output_is_valid_json(text)