def test_compliant_report_download(flask_app): """Test if report not found""" task = CeleryTasks.get_summary([ '01206400000001', '35332206000303', '12344321000020', '35499405000401', '35236005000001', '01368900000001' ], 0) response = flask_app.post('/api/v1/download/' + task['response']['compliant_report_name']) assert response.status_code == 200 assert response.mimetype == 'text/tab-separated-values'
def test_compliant_report(app): """Tests DVS compliant report contents""" task = CeleryTasks.get_summary([ '01206400000001', '35332206000303', '12344321000020', '35499405000401', '35236005000001', '01368900000001' ], 0) report = os.path.join(app.config['dev_config']['UPLOADS']['report_dir'], task['response']['compliant_report_name']) task_file = pd.read_csv(report, sep='\t', index_col=0) task_list = task_file.to_dict(orient='records') assert len(task_list) > 0
def test_dvs_bulk_summary(): """Tests DVS bulk summary JSON response and counts.""" task = CeleryTasks.get_summary([ '01206400000001', '35332206000303', '12344321000020', '35499405000401', '35236005000001', '01368900000001' ], 0) task = task['response'] assert task['pending_registration'] == 8 and task['invalid_imei'] == 0 and task['no_condition'] == 2 and \ task['pending_stolen_verification'] == 7 and task['unprocessed_imeis'] == 0 and \ task['count_per_condition']['gsma_not_found'] == 7 and task['count_per_condition']['local_stolen'] == 7 and \ task['count_per_condition']['duplicate'] == 6 and task['count_per_condition']['not_on_registration_list'] == 7\ and task['non_complaint'] > 0 and task['verified_imei'] == 18
def test_report_deletion(): """Tests report deletion process""" CeleryTasks.delete_files()
def test_dvs_bulk_empty_summary(): """Tests DVS bulk summary with empty list.""" summary = CeleryTasks.get_summary([], 0) assert len(summary['response']) is 0