Beispiel #1
0
    def test_get_traffic_calls_gmaps_if_needed(self):
        traffic = Traffic("foo", "bar")
        traffic.get_dynamo_data = MagicMock(return_value=None)
        traffic.make_google_api_call = MagicMock()

        traffic.get_traffic_data()

        traffic.make_google_api_call.assert_called()
Beispiel #2
0
    def test_get_traffic_data_skips_gmaps_if_not_needed(self):
        traffic = Traffic("foo", "bar")
        traffic.get_dynamo_data = MagicMock(return_value={
            "time": time.time(),
            "hours": "1",
            "minutes": "75"
        })
        traffic.make_google_api_call = MagicMock()

        traffic.get_traffic_data()

        traffic.make_google_api_call.assert_not_called()
        self.assertEqual(traffic.duration, {"hours": "1", "minutes": "75"})