Exemple #1
0
 def initialize(self) -> None:
     """
     Initialize database with dictionary rows in dict tables
     """
     with self.session_manager.session_scope() as s:
         for request_type in RequestTypes:
             if not s.query(DBRequestType).filter(
                     DBRequestType.name == request_type.value).first():
                 db_request_type = DBRequestType(name=request_type.value)
                 s.add(db_request_type)
         for state in RequestStates:
             if not s.query(DBRequestState).filter(
                     DBRequestState.name == state.value).first():
                 request_state = DBRequestState(name=state.value)
                 s.add(request_state)
         for state in GrantStates:
             if not s.query(DBGrantState).filter(
                     DBGrantState.name == state.value).first():
                 grant_state = DBGrantState(name=state.value)
                 s.add(grant_state)
         for state in CbsdStates:
             if not s.query(DBCbsdState).filter(
                     DBCbsdState.name == state.value).first():
                 cbsd_state = DBCbsdState(name=state.value)
                 s.add(cbsd_state)
         s.commit()
Exemple #2
0
 def setUp(self):
     super().setUp()
     cbsd_state = DBCbsdState(name='some_cbsd_state')
     cbsd = DBCbsd(
         state=cbsd_state,
         fcc_id=SOME_FCC_ID,
         cbsd_serial_number=SOME_SERIAL_NUMBER,
         network_id=SOME_NETWORK_ID,
     )
     self.session.add(cbsd)
     self.session.commit()
Exemple #3
0
 def setUp(self):
     super().setUp()
     cbsd_state = DBCbsdState(name='some_cbsd_state')
     cbsd = DBCbsd(
         state=cbsd_state,
         fcc_id=SOME_FCC_ID,
         cbsd_serial_number=SOME_SERIAL_NUMBER,
         network_id=SOME_NETWORK_ID,
     )
     req_type = DBRequestType(name=HEARTBEAT_REQUEST)
     self.session.add_all([cbsd, req_type])
     self.session.commit()
 def _prepare_two_pending_and_one_processed_request(self):
     test_state = DBCbsdState(name="test_state")
     cbsds = []
     for i in range(1, 4):
         cbsds.append(
             DBCbsd(
                 id=int(i),
                 cbsd_id=f"foo{i}",
                 state=test_state,
                 user_id="test_user",
                 fcc_id=f"test_fcc_id{i}",
                 cbsd_serial_number=f"test_serial_nr{i}",
             ), )
     req_type = DBRequestType(name="someRequest")
     pending_status = DBRequestState(name="pending")
     processed_status = DBRequestState(name="processed")
     req1 = DBRequest(
         cbsd=cbsds[0],
         type=req_type,
         state=pending_status,
         payload={
             "some": "payload1",
         },
     )
     req2 = DBRequest(
         cbsd=cbsds[1],
         type=req_type,
         state=pending_status,
         payload={
             "some": "payload2",
         },
     )
     req3 = DBRequest(
         cbsd=cbsds[2],
         type=req_type,
         state=processed_status,
         payload={
             "some": "payload3",
         },
     )
     self.session.add_all([req1, req2, req3])
     self.session.commit()