def test_get_applications(self): with self.assertRaises(NotImplementedError) as ctx: repository = BaseRepository(self.CONN) repository.get_applications() self.assertEqual(ctx.exception.args[0], "To implement in child classes.")
def test_fetch(self): with self.assertRaises(NotImplementedError) as ctx: repository = BaseRepository(self.CONN) repository.fetch(self.APP, self.FROM, self.TO) self.assertEqual(ctx.exception.args[0], "To implement in child classes.")
def test_initialize(self): with self.assertRaises(NotImplementedError) as ctx: repository = BaseRepository(self.CONN) repository.initialize() self.assertEqual(ctx.exception.args[0], "To implement in child classes.")
def test_insert(self): with self.assertRaises(NotImplementedError) as ctx: repository = BaseRepository(self.CONN) repository.insert( OutputMessage(self.APP, None, 0, AggregationFunction.NONE, 0, self.FROM)) self.assertEqual(ctx.exception.args[0], "To implement in child classes.")
def test_constructor(self): observable_repository = ObservableRepository(BaseRepository(None), self.APP, self.FROM, self.TO) self.assertIsInstance(observable_repository.repository, BaseRepository) self.assertEqual(observable_repository.application, self.APP) self.assertEqual(observable_repository.from_ts, self.FROM) self.assertEqual(observable_repository.to_ts, self.TO)
def test__get_observable(self): with self.assertRaises(NotImplementedError) as ctx: repository = BaseRepository(self.CONN) observable_repo = BaseObservableRepository(repository) observable_repo._get_observable() self.assertEqual(ctx.exception.args[0], "To implement in child classes.")
def test_get_observable(self, _get_observable_method): def mocked__get_observable_method(*args, **kwargs): return Observable.from_(self.VALUES) _get_observable_method.side_effect = mocked__get_observable_method repository = BaseRepository(self.CONN) observable_repo = BaseObservableRepository(repository) self.assertIsInstance(observable_repo.get_observable(), Observable)
def test__get_observable(self, fetch_method): def mocked_fetch_method(*args, **kwargs): return self.VALUES fetch_method.side_effect = mocked_fetch_method observable_repository = ObservableRepository(BaseRepository(None), self.APP, self.FROM, self.TO) obs = [ x for x in observable_repository._get_observable().to_blocking() ] self.assertListEqual(obs, self.VALUES)
def test_get_max(self, map_method, _get_observable_method): def mocked__get_observable_method(*args, **kwargs): return Observable.from_(self.VALUES) _get_observable_method.side_effect = mocked__get_observable_method def mocked_map_method(*args, **kwargs): return OutputMessage("app", None, 0, AggregationFunction.NONE, args[0], datetime.now()) map_method.side_effect = mocked_map_method repository = BaseRepository(self.CONN) observable_repo = BaseObservableRepository(repository) self.assertEqual(observable_repo.get_max(), 6)
def test_constructor(self): repository = BaseRepository(self.CONN) observable_repo = BaseObservableRepository(repository) self.assertEqual(repository.conn, observable_repo.repository.conn)
def test_constructor(self): repository = BaseRepository(self.CONN) self.assertEqual(repository.conn, self.CONN)