How to use pyowm - 10 common examples

To help you get started, we’ve selected a few pyowm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github csparpa / pyowm / tests / unit / webapi25 / test_observationlistparser.py View on Github external
def test_parse_JSON_fails_when_JSON_data_is_None(self):
        self.assertRaises(ParseResponseError, ObservationListParser.parse_JSON,
                          self.__instance, None)
github csparpa / pyowm / tests / unit / webapi25 / parsers / test_so2indexparser.py View on Github external
def test_parse_JSON_fails_with_malformed_JSON_data(self):
        self.assertRaises(ParseResponseError, SO2IndexParser.parse_JSON,
                          self.__instance, SO2INDEX_MALFORMED_JSON)
github csparpa / pyowm / tests / unit / pollutionapi30 / test_parsers.py View on Github external
def test_parse_JSON_fails_with_malformed_JSON_data(self):
        self.assertRaises(ParseResponseError, SO2IndexParser.parse_JSON,
                          self.__instance, SO2INDEX_MALFORMED_JSON)
github csparpa / pyowm / tests / unit / stationsapi30 / parsers / test_aggregated_measurement_parser.py View on Github external
def test_parse_JSON_fails_with_none_input(self):
        instance = AggregatedMeasurementParser()
        with self.assertRaises(parse_response_error.ParseResponseError):
            instance.parse_JSON(None)
github csparpa / pyowm / tests / unit / commons / test_http_client.py View on Github external
def test_get_json_parse_error(self):

        def monkey_patched_get(uri, params=None, headers=None, timeout=None,
                               verify=False):
            return MockResponse(200, 123846237647236)

        requests.get = monkey_patched_get
        self.assertRaises(parse_response_error.ParseResponseError,
                          HttpClient().get_json,
                          'http://anyurl.com',
                          params=dict(a=1, b=2))
        requests.get = self.requests_original_get
github csparpa / pyowm / tests / unit / utils / test_timeutils.py View on Github external
def test_next_year(self):
        result = timeutils.next_year()
        expected = datetime.now() + timedelta(days=365)
        self.assertAlmostEqual(
            float(timeformatutils.to_UNIXtime(expected)),
            float(timeformatutils.to_UNIXtime(result)))
github csparpa / pyowm / tests / unit / utils / test_timeutils.py View on Github external
def test_last_week(self):
        result = timeutils.last_week()
        expected = datetime.now() + timedelta(days=-7)
        self.assertAlmostEqual(
           float(timeformatutils.to_UNIXtime(expected)),
           float(timeformatutils.to_UNIXtime(result)))
github csparpa / pyowm / tests / unit / utils / test_timeutils.py View on Github external
def test_last_week(self):
        result = timeutils.last_week()
        expected = datetime.now() + timedelta(days=-7)
        self.assertAlmostEqual(
           float(timeformatutils.to_UNIXtime(expected)),
           float(timeformatutils.to_UNIXtime(result)))
github csparpa / pyowm / tests / unit / utils / test_timeutils.py View on Github external
def test_next_hour(self):
        result = timeutils.next_hour()
        expected = datetime.now() + timedelta(hours=1)
        self.assertAlmostEqual(
           float(timeformatutils.to_UNIXtime(expected)),
           float(timeformatutils.to_UNIXtime(result)))
github csparpa / pyowm / tests / unit / utils / test_timeutils.py View on Github external
def test_next_year(self):
        result = timeutils.next_year()
        expected = datetime.now() + timedelta(days=365)
        self.assertAlmostEqual(
            float(timeformatutils.to_UNIXtime(expected)),
            float(timeformatutils.to_UNIXtime(result)))