def get(self, messageid): application_identity = NOWApplicationIdentity.find_by_messageid(messageid) if not application_identity: raise NotFound('Application not found') code = application_identity.now_application.now_application_status_code return NOWApplicationStatus.find_by_now_application_status_code(code)
class NOWApplicationNDAFactory(BaseFactory): class Meta: model = NOWApplicationNDA class Params: mine = factory.SubFactory('tests.factories.MineFactory', minimal=True) applicant = factory.SubFactory('tests.factories.NOWClientFactory') submitter = factory.SubFactory('tests.factories.NOWClientFactory') #now_application_identity = factory.SubFactory('tests.factories.NOWApplicationIdentityFactory') application_nda_guid = GUID mine_guid = factory.SelfAttribute('mine.mine_guid') messageid = factory.Sequence(lambda n: n) applicantclientid = factory.SelfAttribute('applicant.clientid') submitterclientid = factory.SelfAttribute('submitter.clientid') status = factory.LazyFunction(lambda: random.choice( [x.description for x in NOWApplicationStatus.get_active()])) submitteddate = factory.Faker('past_datetime') receiveddate = factory.Faker('past_datetime') minenumber = factory.SelfAttribute('mine.mine_no') originating_system = random.choice(['NROS', 'VFCBC']) @factory.post_generation def documents(obj, create, extracted, **kwargs): if not create: return if not isinstance(extracted, int): extracted = 1 NOWDocumentFactory.create_batch(size=extracted, application=obj, **kwargs)
def get(self, now_number): application_identity = NOWApplicationIdentity.find_by_now_number(now_number) if not application_identity: raise NotFound('Application not found') code = application_identity.now_application.now_application_status_code return NOWApplicationStatus.find_by_now_application_status_code(code)
def test_get_application_status_codes(self, test_client, db_session, auth_headers): """Should return the correct number of records with a 200 response code""" get_resp = test_client.get( f'/now-applications/application-status-codes', headers=auth_headers['full_auth_header']) get_data = json.loads(get_resp.data.decode()) assert get_resp.status_code == 200 assert len(get_data['records']) == len(NOWApplicationStatus.get_all())
def get(self): status_updated_date_since = request.args.get('status_updated_date_since') if not status_updated_date_since: raise BadRequest('status_updated_date_since is a required query parameter') now_applications = NOWApplication.query.filter( NOWApplication.status_updated_date >= status_updated_date_since).order_by( NOWApplication.status_updated_date.desc()).all() updated_status_records = [] for now_application in now_applications: updated_status_record = { "messageid": now_application.now_application_identity.messageid, "status_updated_date": now_application.status_updated_date, "status": NOWApplicationStatus.find_by_now_application_status_code( now_application.now_application_status_code) } updated_status_records.append(updated_status_record) return updated_status_records
def get(self): return NOWApplicationStatus.active()
def RandomNOWStatusCode(): return random.choice([ x.now_application_status_code for x in NOWApplicationStatus.get_all() ])