def command(cycle): data = Cycle.objects.filter(title=cycle) for cycle in data: report = FreeFormReport(None, cycle.title).build_form_db(cycle) run_checks(report) persist_scores(report) export_results()
def test_web_based_results(self): file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', 'tests', 'fixtures', "new_format.xlsx") report = FreeFormReport(file_path, "May - Jun").load() report.cycle = "Jul - Aug 2015" cases = [ {'test': WebBasedCheck, 'expected': 96.0, 'score': WEB} ] for case in cases: check = case['test']() for combination in check.combinations: report.locs[0]['scores'][check.test][combination[NAME]] = check.for_each_facility(report.locs[0], combination) persist_scores(report) self.assertEquals(Score.objects.count(), 24) self.assertEquals(Score.objects.all()[0].WEB_BASED[DEFAULT], WEB)
def test_web_based_results(self): file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', 'tests', 'fixtures', "new_format.xlsx") report = FreeFormReport(file_path, "May - Jun").load() report.cycle = "Jul - Aug 2015" cases = [{'test': WebBasedCheck, 'expected': 96.0, 'score': WEB}] for case in cases: check = case['test']() for combination in check.combinations: report.locs[0]['scores'][check.test][ combination[NAME]] = check.for_each_facility( report.locs[0], combination) persist_scores(report) self.assertEquals(Score.objects.count(), 24) self.assertEquals(Score.objects.all()[0].WEB_BASED[DEFAULT], WEB)
def perform_checks(): cycle = "Sep - Oct 2015" data = Cycle.objects.filter(title=cycle) for cycle in data: report = FreeFormReport(None, cycle.title).build_form_db(cycle) run_checks(report) persist_scores(report) checks = [ {'combination': F1, 'test': STABLE_PATIENT_VOLUMES, 'cycle': cycle, YES: 793, NO: 405, NOT_REPORTING: 632}, {'combination': DEFAULT, 'test': NNRTI_NEW_PAED, 'cycle': cycle, YES: 681, NO: 644, NOT_REPORTING: 509}, {'combination': DEFAULT, 'test': NNRTI_NEW_ADULTS, 'cycle': cycle, YES: 799, NO: 573, NOT_REPORTING: 462}, {'combination': DEFAULT, 'test': NNRTI_CURRENT_PAED, 'cycle': cycle, YES: 548, NO: 780, NOT_REPORTING: 506}, {'combination': DEFAULT, 'test': NNRTI_CURRENT_ADULTS, 'cycle': cycle, YES: 937, NO: 439, NOT_REPORTING: 458}, ] for check in checks: if check.get('combination') == DEFAULT: yes_condition = {DEFAULT: YES} no_condition = {DEFAULT: NO} not_reporting_condition = {(DEFAULT): NOT_REPORTING} else: yes_condition = {check.get('combination'): YES} no_condition = {check.get('combination'): NO} not_reporting_condition = {check.get('combination'): NOT_REPORTING} for key, condition in {YES: yes_condition, NO: no_condition, NOT_REPORTING: not_reporting_condition}.items(): test_description = "%s %s" % (check['test'], key) filter_key = "%s__icontains" % check.get('test') filter_by = {filter_key: make_cond(condition)} count = Score.objects.filter(cycle=check['cycle'], **filter_by).count() expected = check[key] actual = count if expected == actual: print colored(test_description + " Passed", "green") else: tolerance = 10 diff = abs(float(expected) - float(actual)) c = "yellow" if diff <= tolerance else "red" print colored(test_description + " Failed", c), colored("Got %s instead of %s " % (actual, expected), c), colored("diff: %s" % diff, "blue") print "\n"
def test_should_record_scores_for_each_facility(self): report = FakeReport() report.cycle = "May - Jun 2015" report.locs = [{ 'name': 'location_one', 'IP': 'ip_one', 'District': 'district_one', 'Warehouse': 'warehouse_one', 'scores': { 'WEB_BASED': { 'DEFAULT': 'YES' }, 'REPORTING': { 'DEFAULT': 'NO' }, } }, { 'name': 'location_two', 'District': 'district_one', 'IP': 'ip_one', 'Warehouse': 'warehouse_one', 'scores': { 'WEB_BASED': { 'DEFAULT': 'YES' }, 'REPORTING': { 'DEFAULT': 'NO' }, } }] self.assertEqual(Score.objects.count(), 0) persist_scores(report) persist_scores(report) self.assertEqual(Score.objects.count(), 2) first_score = Score.objects.all()[0] self.assertEqual(first_score.default_pass_count, 1) self.assertEqual(first_score.default_fail_count, 1)
def perform_checks(): cycle = "Sep - Oct 2015" data = Cycle.objects.filter(title=cycle) for cycle in data: report = FreeFormReport(None, cycle.title).build_form_db(cycle) run_checks(report) persist_scores(report) checks = [ { 'combination': F1, 'test': STABLE_PATIENT_VOLUMES, 'cycle': cycle, YES: 793, NO: 405, NOT_REPORTING: 632 }, { 'combination': DEFAULT, 'test': NNRTI_NEW_PAED, 'cycle': cycle, YES: 681, NO: 644, NOT_REPORTING: 509 }, { 'combination': DEFAULT, 'test': NNRTI_NEW_ADULTS, 'cycle': cycle, YES: 799, NO: 573, NOT_REPORTING: 462 }, { 'combination': DEFAULT, 'test': NNRTI_CURRENT_PAED, 'cycle': cycle, YES: 548, NO: 780, NOT_REPORTING: 506 }, { 'combination': DEFAULT, 'test': NNRTI_CURRENT_ADULTS, 'cycle': cycle, YES: 937, NO: 439, NOT_REPORTING: 458 }, ] for check in checks: if check.get('combination') == DEFAULT: yes_condition = {DEFAULT: YES} no_condition = {DEFAULT: NO} not_reporting_condition = {(DEFAULT): NOT_REPORTING} else: yes_condition = {check.get('combination'): YES} no_condition = {check.get('combination'): NO} not_reporting_condition = {check.get('combination'): NOT_REPORTING} for key, condition in { YES: yes_condition, NO: no_condition, NOT_REPORTING: not_reporting_condition }.items(): test_description = "%s %s" % (check['test'], key) filter_key = "%s__icontains" % check.get('test') filter_by = {filter_key: make_cond(condition)} count = Score.objects.filter(cycle=check['cycle'], **filter_by).count() expected = check[key] actual = count if expected == actual: print colored(test_description + " Passed", "green") else: tolerance = 10 diff = abs(float(expected) - float(actual)) c = "yellow" if diff <= tolerance else "red" print colored(test_description + " Failed", c), colored( "Got %s instead of %s " % (actual, expected), c), colored("diff: %s" % diff, "blue") print "\n"