def setUpClass(cls): """ Set up class-wide resources (test data) """ super(DashboardTests, cls).setUpClass() # TODO: refactor into a pytest fixture with create_app().app_context(): # get the submission test user sess = GlobalDB.db().session cls.session = sess submission_user = sess.query(User).filter( User.email == cls.test_users['admin_user']).one() cls.submission_user_id = submission_user.user_id other_user = sess.query(User).filter( User.email == cls.test_users['agency_user']).one() cls.other_user_id = other_user.user_id no_submissions_user = sess.query(User).filter( User.email == cls.test_users['no_permissions_user']).one() cls.no_submissions_user_email = no_submissions_user.email cls.no_submissions_user_id = no_submissions_user.user_id cls.quarter_sub = insert_submission(cls.session, cls.submission_user_id, cgac_code='SYS', start_date='01/2017', end_date='03/2017', is_quarter=True)
def setUpClass(cls): """Set up class-wide resources (test data)""" super(GenerationTests, cls).setUpClass() # TODO: refactor into a pytest fixture with create_app().app_context(): # get the submission test user sess = GlobalDB.db().session submission_user = sess.query(User).filter(User.email == cls.test_users['admin_user']).one() cls.submission_user_id = submission_user.user_id other_user = sess.query(User).filter(User.email == cls.test_users['agency_user']).one() cls.other_user_email = other_user.email cls.other_user_id = other_user.user_id # setup submission/jobs data for test_check_status cls.generation_submission_id = insert_submission(sess, cls.submission_user_id, cgac_code="SYS", start_date="07/2015", end_date="09/2015", is_quarter=True) cls.setup_file_generation_submission(sess) cls.test_fabs_submission_id = insert_submission(sess, cls.submission_user_id, cgac_code="SYS", start_date="10/2015", end_date="12/2015", is_quarter=False, number_of_errors=0, is_fabs=True)
def setUpClass(cls): """Set up class-wide resources (test data)""" super(GenerationTests, cls).setUpClass() # TODO: refactor into a pytest fixture with create_app().app_context(): # get the submission test user sess = GlobalDB.db().session submission_user = sess.query(User).filter(User.email == cls.test_users['admin_user']).one() cls.submission_user_id = submission_user.user_id other_user = sess.query(User).filter(User.email == cls.test_users['agency_user']).one() cls.other_user_email = other_user.email cls.other_user_id = other_user.user_id # setup submission/jobs data for test_check_status cls.generation_submission_id = insert_submission(sess, cls.submission_user_id, cgac_code="SYS", start_date="07/2015", end_date="09/2015", is_quarter=True) cls.setup_file_generation_submission(sess) cls.test_fabs_submission_id = insert_submission(sess, cls.submission_user_id, cgac_code="SYS", start_date="10/2015", end_date="12/2015", is_quarter=False, number_of_errors=0, is_fabs=True)
def setUpClass(cls): """Set up class-wide resources (test data)""" super(ListSubmissionTests, cls).setUpClass() # TODO: refactor into a pytest fixture with create_app().app_context(): # get an admin and non-admin user sess = GlobalDB.db().session cls.session = sess admin_user = sess.query(User).filter( User.email == cls.test_users['admin_user']).one() cls.admin_user_id = admin_user.user_id other_user = sess.query(User).filter( User.email == cls.test_users['agency_user']).one() cls.other_user_id = other_user.user_id # set up submissions for dabs cls.non_admin_dabs_sub_id = insert_submission( sess, cls.other_user_id, cgac_code="SYS", start_date="10/2015", end_date="12/2015", is_quarter=True, is_fabs=False, publish_status_id=PUBLISH_STATUS_DICT['unpublished'], updated_at='01/01/2010') cls.admin_dabs_sub_id = insert_submission( sess, cls.admin_user_id, cgac_code="000", start_date="10/2015", end_date="12/2015", is_quarter=True, is_fabs=False, publish_status_id=PUBLISH_STATUS_DICT['unpublished'], updated_at='01/01/2012') cls.certified_dabs_sub_id = insert_submission( sess, cls.admin_user_id, cgac_code="SYS", start_date="10/2015", end_date="12/2015", is_quarter=True, is_fabs=False, publish_status_id=PUBLISH_STATUS_DICT['published']) # Add a couple jobs for dabs files insert_job(sess, FILE_TYPE_DICT['appropriations'], FILE_STATUS_DICT['complete'], JOB_TYPE_DICT['file_upload'], cls.non_admin_dabs_sub_id, filename='/path/to/test/file_1.csv', file_size=123, num_rows=3) insert_job(sess, FILE_TYPE_DICT['award'], FILE_STATUS_DICT['complete'], JOB_TYPE_DICT['file_upload'], cls.non_admin_dabs_sub_id, filename='/path/to/test/file_2.csv', file_size=123, num_rows=3) insert_job(sess, FILE_TYPE_DICT['award'], FILE_STATUS_DICT['complete'], JOB_TYPE_DICT['file_upload'], cls.certified_dabs_sub_id, filename='/path/to/test/file_part_2.csv', file_size=123, num_rows=3) # set up submissions for fabs cls.non_admin_fabs_sub_id = insert_submission( sess, cls.admin_user_id, cgac_code="SYS", start_date="10/2015", end_date="12/2015", is_fabs=True, publish_status_id=PUBLISH_STATUS_DICT['unpublished']) cls.admin_fabs_sub_id = insert_submission( sess, cls.other_user_id, cgac_code="000", start_date="10/2015", end_date="12/2015", is_fabs=True, publish_status_id=PUBLISH_STATUS_DICT['unpublished']) cls.published_fabs_sub_id = insert_submission( sess, cls.other_user_id, cgac_code="000", start_date="10/2015", end_date="12/2015", is_fabs=True, publish_status_id=PUBLISH_STATUS_DICT['published']) # Add a job for a FABS submission insert_job(sess, FILE_TYPE_DICT['fabs'], FILE_STATUS_DICT['complete'], JOB_TYPE_DICT['file_upload'], cls.admin_fabs_sub_id, filename=str(cls.admin_fabs_sub_id) + '/test_file.csv', file_size=123, num_rows=3)
def setUpClass(cls): """Set up class-wide resources (test data)""" super(ListLatestPublishedFileTests, cls).setUpClass() # TODO: refactor into a pytest fixture with create_app().app_context(): # get the submission test user sess = GlobalDB.db().session cls.session = sess other_user = sess.query(User).filter( User.email == cls.test_users['agency_user']).one() cls.other_user_email = other_user.email cls.other_user_id = other_user.user_id cls.submission_user_id = other_user.user_id # ======= Reference ====== cgac = CGAC(cgac_id=11, cgac_code='111', agency_name='CGAC 1') frec = FREC(frec_id=12, cgac_id=11, frec_code='2222', agency_name='FREC 2') cgac2 = CGAC(cgac_id=13, cgac_code='333', agency_name='CGAC 3') sess.add_all([cgac, frec, cgac2]) sess.commit() year = 2020 period = 6 diff_year = 2021 diff_period = 7 # ======= DABS ======= cls.dabs_sub_unpub = insert_submission( sess, cls.submission_user_id, cgac_code=cgac2.cgac_code, reporting_fiscal_year=1999, reporting_fisacal_period=2, publish_status_id=PUBLISH_STATUS_DICT['unpublished'], is_fabs=False) cls.dabs_sub_pub_twice = insert_submission( sess, cls.submission_user_id, cgac_code=cgac.cgac_code, reporting_fiscal_year=year, reporting_fisacal_period=period, publish_status_id=PUBLISH_STATUS_DICT['published'], is_fabs=False) cls.setup_published_submission(sess, cls.dabs_sub_pub_twice, date='01/01/2020', is_fabs=False) cls.setup_published_submission(sess, cls.dabs_sub_pub_twice, date='01/02/2020', is_fabs=False) cls.dabs_sub_pub_diff_agency = insert_submission( sess, cls.submission_user_id, frec_code=frec.frec_code, reporting_fiscal_year=year, reporting_fisacal_period=period, publish_status_id=PUBLISH_STATUS_DICT['published'], is_fabs=False) cls.setup_published_submission(sess, cls.dabs_sub_pub_diff_agency, is_fabs=False) cls.dabs_sub_pub_diff_year = insert_submission( sess, cls.submission_user_id, cgac_code=cgac.cgac_code, reporting_fiscal_year=diff_year, reporting_fisacal_period=period, publish_status_id=PUBLISH_STATUS_DICT['published'], is_fabs=False) cls.setup_published_submission(sess, cls.dabs_sub_pub_diff_year, is_fabs=False) cls.dabs_sub_pub_diff_period = insert_submission( sess, cls.submission_user_id, cgac_code=cgac.cgac_code, reporting_fiscal_year=year, reporting_fisacal_period=diff_period, publish_status_id=PUBLISH_STATUS_DICT['published'], is_fabs=False) cls.setup_published_submission(sess, cls.dabs_sub_pub_diff_period, is_fabs=False) # ======= FABS ======= cls.fabs_sub_unpub = insert_submission( sess, cls.submission_user_id, cgac_code='333', reporting_fiscal_year=None, reporting_fisacal_period=None, publish_status_id=1, is_fabs=True) cls.fabs_sub_pub = insert_submission( sess, cls.submission_user_id, cgac_code=cgac.cgac_code, reporting_fiscal_year=None, reporting_fisacal_period=None, publish_status_id=PUBLISH_STATUS_DICT['published'], is_fabs=True) cls.setup_published_submission(sess, cls.fabs_sub_pub, date='10/01/2000', is_fabs=True) cls.fabs_sub_pub_2 = insert_submission( sess, cls.submission_user_id, cgac_code=cgac.cgac_code, reporting_fiscal_year=None, reporting_fisacal_period=None, publish_status_id=PUBLISH_STATUS_DICT['published'], is_fabs=True) cls.setup_published_submission(sess, cls.fabs_sub_pub_2, date='10/02/2000', is_fabs=True) cls.fabs_sub_pub_diff_agency = insert_submission( sess, cls.submission_user_id, frec_code=frec.frec_code, reporting_fiscal_year=None, reporting_fisacal_period=None, publish_status_id=PUBLISH_STATUS_DICT['published'], is_fabs=True) cls.setup_published_submission(sess, cls.fabs_sub_pub_diff_agency, date='10/01/2000', is_fabs=True) cls.fabs_sub_pub_diff_year = insert_submission( sess, cls.submission_user_id, cgac_code=cgac.cgac_code, reporting_fiscal_year=None, reporting_fisacal_period=None, publish_status_id=PUBLISH_STATUS_DICT['published'], is_fabs=True) cls.setup_published_submission(sess, cls.fabs_sub_pub_diff_year, date='10/01/2001', is_fabs=True) cls.fabs_sub_pub_diff_period = insert_submission( sess, cls.submission_user_id, cgac_code=cgac.cgac_code, reporting_fiscal_year=None, reporting_fisacal_period=None, publish_status_id=PUBLISH_STATUS_DICT['published'], is_fabs=True) cls.setup_published_submission(sess, cls.fabs_sub_pub_diff_period, date='01/01/2001', is_fabs=True)
def setUpClass(cls): """Set up class-wide resources (test data)""" super(ListSubmissionTests, cls).setUpClass() # TODO: refactor into a pytest fixture with create_app().app_context(): # get an admin and non-admin user sess = GlobalDB.db().session cls.session = sess admin_user = sess.query(User).filter( User.email == cls.test_users['admin_user']).one() cls.admin_user_id = admin_user.user_id other_user = sess.query(User).filter( User.email == cls.test_users['agency_user']).one() cls.other_user_id = other_user.user_id # set up submissions for dabs cls.non_admin_dabs_sub_id = insert_submission( sess, cls.other_user_id, cgac_code='SYS', start_date='10/2015', end_date='12/2015', is_quarter=True, is_fabs=False, publish_status_id=PUBLISH_STATUS_DICT['unpublished'], updated_at='01/01/2010') cls.admin_dabs_sub_id = insert_submission( sess, cls.admin_user_id, cgac_code='000', start_date='10/2015', end_date='12/2015', is_quarter=True, is_fabs=False, publish_status_id=PUBLISH_STATUS_DICT['unpublished'], updated_at='01/01/2012') cls.test_sub_id = insert_submission( sess, cls.admin_user_id, cgac_code='SYS', start_date='10/2015', end_date='12/2015', is_quarter=True, is_fabs=False, publish_status_id=PUBLISH_STATUS_DICT['unpublished'], updated_at='01/02/2012', test_submission=True) # This is the min date, but the date everything should be using is the one in the job (MAX_UPDATED_AT) cls.certified_dabs_sub_id = insert_submission( sess, cls.admin_user_id, cgac_code='SYS', start_date='10/2015', end_date='12/2015', is_quarter=True, is_fabs=False, publish_status_id=PUBLISH_STATUS_DICT['published'], updated_at='01/01/2000') # Add a couple jobs for dabs files, make sure the updated at is the same as or earlier than the one on # the submission itself insert_job(sess, FILE_TYPE_DICT['appropriations'], FILE_STATUS_DICT['complete'], JOB_TYPE_DICT['file_upload'], cls.non_admin_dabs_sub_id, filename='/path/to/test/file_1.csv', file_size=123, num_rows=3, updated_at='01/01/2009') insert_job(sess, FILE_TYPE_DICT['award'], FILE_STATUS_DICT['complete'], JOB_TYPE_DICT['file_upload'], cls.non_admin_dabs_sub_id, filename='/path/to/test/file_2.csv', file_size=123, num_rows=3, updated_at='01/01/2009') # Min updated at date insert_job(sess, FILE_TYPE_DICT['award'], FILE_STATUS_DICT['complete'], JOB_TYPE_DICT['file_upload'], cls.certified_dabs_sub_id, filename='/path/to/test/file_part_2.csv', file_size=123, num_rows=3, updated_at=cls.MAX_UPDATED_AT) # set up submissions for fabs cls.non_admin_fabs_sub_id = insert_submission( sess, cls.admin_user_id, cgac_code='SYS', start_date='10/2015', end_date='12/2015', is_fabs=True, publish_status_id=PUBLISH_STATUS_DICT['unpublished'], updated_at='01/01/2016') # This is the min date, but the date everything should be using is the one in the job (MAX_UPDATED_AT) cls.admin_fabs_sub_id = insert_submission( sess, cls.other_user_id, cgac_code='000', start_date='10/2015', end_date='12/2015', is_fabs=True, publish_status_id=PUBLISH_STATUS_DICT['unpublished'], updated_at='01/01/2000') cls.published_fabs_sub_id = insert_submission( sess, cls.other_user_id, cgac_code='000', start_date='10/2015', end_date='12/2015', is_fabs=True, publish_status_id=PUBLISH_STATUS_DICT['published'], updated_at='01/02/2000') # Add a job for a FABS submission insert_job(sess, FILE_TYPE_DICT['fabs'], FILE_STATUS_DICT['complete'], JOB_TYPE_DICT['file_upload'], cls.admin_fabs_sub_id, filename=str(cls.admin_fabs_sub_id) + '/test_file.csv', file_size=123, num_rows=3, updated_at=cls.MAX_UPDATED_AT)
def setUpClass(cls): """ Set up class-wide resources (test data) """ super(ErrorWarningTests, cls).setUpClass() logging.getLogger('dataactcore').setLevel(logging.ERROR) logging.getLogger('dataactvalidator').setLevel(logging.ERROR) with create_app().app_context(): # get the submission test users sess = GlobalDB.db().session cls.session = sess # set up default e-mails for tests admin_user = sess.query(User).filter( User.email == cls.test_users['admin_user']).one() cls.validator = ValidationManager( directory=CONFIG_SERVICES['error_report_path']) # Just have one valid submission and then keep on reloading files cls.submission_id = insert_submission(sess, admin_user.user_id, cgac_code='SYS', start_date='01/2001', end_date='03/2001', is_quarter=True) cls.submission = sess.query(Submission).filter_by( submission_id=cls.submission_id).one() cls.val_job = insert_job( cls.session, FILE_TYPE_DICT['appropriations'], JOB_STATUS_DICT['ready'], JOB_TYPE_DICT['csv_record_validation'], cls.submission_id, filename=JOB_TYPE_DICT['csv_record_validation']) cls.original_reports = set( os.listdir(CONFIG_SERVICES['error_report_path'])) # adding TAS to ensure valid file is valid tas1 = TASFactory(account_num=1, allocation_transfer_agency='019', agency_identifier='072', beginning_period_of_availa=None, ending_period_of_availabil=None, availability_type_code='X', main_account_code='0306', sub_account_code='000', internal_start_date='01-01-2000') tas2 = TASFactory(account_num=2, allocation_transfer_agency=None, agency_identifier='019', beginning_period_of_availa='2016', ending_period_of_availabil='2016', availability_type_code=None, main_account_code='0113', sub_account_code='000', internal_start_date='01-01-2000') tas3 = TASFactory(account_num=3, allocation_transfer_agency=None, agency_identifier='028', beginning_period_of_availa=None, ending_period_of_availabil=None, availability_type_code='X', main_account_code='0406', sub_account_code='000', internal_start_date='01-01-2000') tas4 = TASFactory(account_num=4, allocation_transfer_agency=None, agency_identifier='028', beginning_period_of_availa='2010', ending_period_of_availabil='2011', availability_type_code=None, main_account_code='0406', sub_account_code='000', internal_start_date='01-01-2000') tas5 = TASFactory(account_num=5, allocation_transfer_agency='069', agency_identifier='013', beginning_period_of_availa=None, ending_period_of_availabil=None, availability_type_code='X', main_account_code='2050', sub_account_code='005', internal_start_date='01-01-2000') tas6 = TASFactory(account_num=6, allocation_transfer_agency='028', agency_identifier='028', beginning_period_of_availa=None, ending_period_of_availabil=None, availability_type_code='X', main_account_code='8007', sub_account_code='000', internal_start_date='01-01-2000') tas7 = TASFactory(account_num=7, allocation_transfer_agency=None, agency_identifier='049', beginning_period_of_availa=None, ending_period_of_availabil=None, availability_type_code='X', main_account_code='0100', sub_account_code='000', internal_start_date='01-01-2000') tas8 = TASFactory(account_num=8, allocation_transfer_agency=None, agency_identifier='049', beginning_period_of_availa='2010', ending_period_of_availabil='2011', availability_type_code=None, main_account_code='0100', sub_account_code='000', internal_start_date='01-01-2000') tas9 = TASFactory(account_num=9, allocation_transfer_agency=None, agency_identifier='049', beginning_period_of_availa='2014', ending_period_of_availabil='2015', availability_type_code=None, main_account_code='0100', sub_account_code='000', internal_start_date='01-01-2000') tas10 = TASFactory(account_num=10, allocation_transfer_agency=None, agency_identifier='049', beginning_period_of_availa='2015', ending_period_of_availabil='2016', availability_type_code=None, main_account_code='0100', sub_account_code='000', internal_start_date='01-01-2000') sess.add_all( [tas1, tas2, tas3, tas4, tas5, tas6, tas7, tas8, tas9, tas10]) # adding GTAS to ensure valid file is valid gtas1 = SF133Factory(tas=concat_tas_dict(tas1.component_dict()), allocation_transfer_agency='019', agency_identifier='072', beginning_period_of_availa=None, line=1009, ending_period_of_availabil=None, availability_type_code='X', main_account_code='0306', sub_account_code='000', period=6, fiscal_year=2001) gtas2 = SF133Factory(tas=concat_tas_dict(tas2.component_dict()), allocation_transfer_agency=None, agency_identifier='019', beginning_period_of_availa='2016', line=1009, ending_period_of_availabil='2016', availability_type_code=None, main_account_code='0113', sub_account_code='000', period=6, fiscal_year=2001) gtas3 = SF133Factory(tas=concat_tas_dict(tas3.component_dict()), allocation_transfer_agency=None, agency_identifier='028', beginning_period_of_availa=None, line=1009, ending_period_of_availabil=None, availability_type_code='X', main_account_code='0406', sub_account_code='000', period=6, fiscal_year=2001) gtas4 = SF133Factory(tas=concat_tas_dict(tas4.component_dict()), allocation_transfer_agency=None, agency_identifier='028', beginning_period_of_availa='2010', line=1009, ending_period_of_availabil='2011', availability_type_code=None, main_account_code='0406', sub_account_code='000', period=6, fiscal_year=2001) gtas5 = SF133Factory(tas=concat_tas_dict(tas5.component_dict()), allocation_transfer_agency='069', agency_identifier='013', beginning_period_of_availa=None, line=1009, ending_period_of_availabil=None, availability_type_code='X', main_account_code='2050', sub_account_code='005', period=6, fiscal_year=2001) gtas6 = SF133Factory(tas=concat_tas_dict(tas6.component_dict()), allocation_transfer_agency='028', agency_identifier='028', beginning_period_of_availa=None, line=1009, ending_period_of_availabil=None, availability_type_code='X', main_account_code='8007', sub_account_code='000', period=6, fiscal_year=2001) gtas7 = SF133Factory(tas=concat_tas_dict(tas7.component_dict()), allocation_transfer_agency=None, agency_identifier='049', beginning_period_of_availa=None, line=1009, ending_period_of_availabil=None, availability_type_code='X', main_account_code='0100', sub_account_code='000', period=6, fiscal_year=2001) gtas8 = SF133Factory(tas=concat_tas_dict(tas8.component_dict()), allocation_transfer_agency=None, agency_identifier='049', beginning_period_of_availa='2010', line=1009, ending_period_of_availabil='2011', availability_type_code=None, main_account_code='0100', sub_account_code='000', period=6, fiscal_year=2001) gtas9 = SF133Factory(tas=concat_tas_dict(tas9.component_dict()), allocation_transfer_agency=None, agency_identifier='049', beginning_period_of_availa='2014', line=1009, ending_period_of_availabil='2015', availability_type_code=None, main_account_code='0100', sub_account_code='000', period=6, fiscal_year=2001) gtas10 = SF133Factory(tas=concat_tas_dict(tas10.component_dict()), allocation_transfer_agency=None, agency_identifier='049', beginning_period_of_availa='2015', line=1009, ending_period_of_availabil='2016', availability_type_code=None, main_account_code='0100', sub_account_code='000', period=6, fiscal_year=2001) sess.add_all([ gtas1, gtas2, gtas3, gtas4, gtas5, gtas6, gtas7, gtas8, gtas9, gtas10 ]) sess.commit()