def setUp(self): super().setUp() self.amc_service = ActiveModeControllerService( SessionManager(self.engine), ) DBInitializer(SessionManager(self.engine)).initialize() grant_states = { x.name: x.id for x in self.session.query(DBGrantState).all() } cbsd_states = { x.name: x.id for x in self.session.query(DBCbsdState).all() } request_types = { x.name: x.id for x in self.session.query(DBRequestType).all() } self.unregistered = cbsd_states[CbsdStates.UNREGISTERED.value] self.registered = cbsd_states[CbsdStates.REGISTERED.value] self.granted = grant_states[GrantStates.GRANTED.value] self.authorized = grant_states[GrantStates.AUTHORIZED.value] self.grant = request_types[RequestTypes.GRANT.value]
def setUp(self): super().setUp() DBInitializer(SessionManager(self.engine)).initialize() grpc_channel = grpc.insecure_channel( f"{config.GRPC_SERVICE}:{config.GRPC_PORT}", ) self.dp_client = DPServiceStub(grpc_channel)
def setUp(self): super().setUp() self.rc_service = RadioControllerService(SessionManager(self.engine)) DBInitializer(SessionManager(self.engine)).initialize() self.unregistered_state = self.session.query(DBCbsdState).\ filter(DBCbsdState.name == CbsdStates.UNREGISTERED.value).scalar()
def setUp(self): super().setUp() DBInitializer(SessionManager(self.engine)).initialize() grpc_channel = grpc.insecure_channel( f"{config.GRPC_SERVICE}:{config.GRPC_PORT}", ) self.dp_client = DPServiceStub(grpc_channel) when_elastic_indexes_data() _delete_dp_elasticsearch_indices()
def setUp(self): super().setUp() grpc_channel = grpc.insecure_channel( f"{config.GRPC_SERVICE}:{config.GRPC_PORT}", ) self.dp_client = DPServiceStub(grpc_channel) DBInitializer(SessionManager(self.engine)).initialize() # Indexing from previous test may not have been finished yet sleep(5) self._delete_dp_elasticsearch_indices()
def setUp(self): super().setUp() self.dp_service = DPService(SessionManager(self.engine), self._now) DBInitializer(SessionManager(self.engine)).initialize() self.cbsd_states = { x.name: x.id for x in self.session.query(DBCbsdState).all() } self.grant_states = { x.name: x.id for x in self.session.query(DBGrantState).all() }
def setUp(self): super().setUp() DBInitializer(SessionManager(self.engine)).initialize() self.cbsd_states = { state.name: state.id for state in self.session.query(DBCbsdState).all() } self.request_types = { req_type.name: req_type.id for req_type in self.session.query(DBRequestType).all() } self.rc_service = RadioControllerService( SessionManager(self.engine), cbsd_states_map=self.cbsd_states, request_types_map=self.request_types, )
class DBInitializationTestCase(LocalDBTestCase): def setUp(self): super().setUp() self.initializer = DBInitializer(SessionManager(db_engine=self.engine)) @parameterized.expand([ (DBRequestType, 6), (DBRequestState, 2), (DBGrantState, 4), (DBCbsdState, 2), ]) def test_db_is_initialized_with_db_states_and_types(self, model, expected_post_init_count): # Given model_entities_pre_init = self.session.query(model).all() # When self.initializer.initialize() model_entities_post_init = self.session.query(model).all() # Then self.assertEqual(0, len(model_entities_pre_init)) self.assertEqual( expected_post_init_count, len(model_entities_post_init), ) @parameterized.expand([ (DBRequestType,), (DBRequestState,), (DBGrantState,), (DBCbsdState,), ]) def test_db_is_initialized_only_once(self, model): # Given / When self.initializer.initialize() model_entities_post_init_1 = self.session.query(model).all() self.initializer.initialize() model_entities_post_init_2 = self.session.query(model).all() # Then self.assertListEqual( model_entities_post_init_1, model_entities_post_init_2, )
def setUp(self): super().setUp() DBInitializer(SessionManager(self.engine)).initialize()
def setUp(self): super().setUp() self.initializer = DBInitializer(SessionManager(db_engine=self.engine))