def test_load_series_no_tag_list(self): """load_series will return an empty generator when called with no tags""" iroc_reader = IrocReader(client=None, threads=1) res = list( iroc_reader.load_series( from_ts=isoparse("2018-05-02T01:56:00+00:00"), to_ts=isoparse("2018-05-03T01:56:00+00:00"), tag_list=[], )) self.assertEqual([], res)
def test_load_series_no_data(self, _mocked_method): """load_series will raise ValueError if it does not find any tags""" iroc_reader = IrocReader(client=None, threads=1) with self.assertRaises(ValueError): list( iroc_reader.load_series( from_ts=isoparse("2018-05-02T01:56:00+00:00"), to_ts=isoparse("2018-05-03T01:56:00+00:00"), tag_list=[SensorTag("jalla", None)], # Not a tag in the input ) )
def test_load_series_checks_date(self): """load_series will raise ValueError if to_ts<from_ts""" iroc_reader = IrocReader(client=None, threads=1) with self.assertRaises(ValueError): list( iroc_reader.load_series( from_ts=isoparse("2018-05-03T01:56:00+00:00"), to_ts=isoparse("2018-05-02T01:56:00+00:00"), tag_list=[SensorTag("jalla", None)], # Not a tag in the input ) )
def test_load_series_dry_run_raises(self): iroc_reader = IrocReader(client=None) with self.assertRaises(NotImplementedError): list( iroc_reader.load_series( from_ts=isoparse("2018-05-02T01:56:00+02:00"), to_ts=isoparse("2018-05-03T01:56:00+00:00"), tag_list=IROC_HAPPY_TAG_LIST, dry_run=True, ))
def test_load_series_happy_path_different_timezones(self, _mocked_method): """Happy-path testing of load_dataframe""" iroc_reader = IrocReader(client=None, threads=1) res = list( iroc_reader.load_series( from_ts=isoparse("2018-05-02T01:56:00+02:00"), to_ts=isoparse("2018-05-03T01:56:00+00:00"), tag_list=IROC_HAPPY_TAG_LIST, )) # We get one dataframe per tag, so 3 self.assertEqual(3, len(res))
def test_load_series_no_asset_found(self): """load_series will return an empty generator when called with tags that cannot be related to any asset""" iroc_reader = IrocReader(client=None, threads=1) with self.assertRaises(ValueError): list( iroc_reader.load_series( from_ts=isoparse("2018-05-02T01:56:00+00:00"), to_ts=isoparse("2018-05-03T01:56:00+00:00"), tag_list=IROC_NO_ASSET_TAG_LIST, # Not a tag in the input ))
def test_load_series_missing_columns_data(self, _mocked_method): """load_series will raise ValueError if there is a single tag it can not find""" iroc_reader = IrocReader(client=None, threads=1) with self.assertRaises(ValueError): list( iroc_reader.load_series( from_ts=isoparse("2018-05-02T01:56:00+00:00"), to_ts=isoparse("2018-05-03T01:56:00+00:00"), tag_list=IROC_HAPPY_TAG_LIST + [SensorTag("jalla", None)], # "jalla" is not a tag ))
def test_load_series_many_assets(self): """load_series will return an empty generator when called with tags related to several assets""" iroc_reader = IrocReader(client=None, threads=1) with self.assertRaises(ValueError): list( iroc_reader.load_series( from_ts=isoparse("2018-05-02T01:56:00+00:00"), to_ts=isoparse("2018-05-03T01:56:00+00:00"), tag_list= IROC_MANY_ASSETS_SENSOR_TAG_LIST, # Not a tag in the input ))
def test_can_handle_tag_no_asset(self): iroc_reader = IrocReader(client=None, threads=1) assert not iroc_reader.can_handle_tag(SensorTag("UON_EF.xxx", None))
def test_can_handle_tag_unknown_asset(self): iroc_reader = IrocReader(client=None, threads=1) assert not iroc_reader.can_handle_tag( SensorTag("UON_EF.xxx", "UNKNOWǸ_ASSET"))
def test_can_handle_tag_ok(self): iroc_reader = IrocReader(client=None, threads=1) assert iroc_reader.can_handle_tag(SensorTag("UON_EF.xxx", "UON_EF"))