def test_view_compare_with_run_registry(): create_runs(3, 1, "collisions", "express", date="2018-05-14") req = RequestFactory().get("shiftleader/") req.GET = req.GET.copy() req.GET['date__gte']="2018-5-13" req.GET['date__lte']="2018-5-16" req.user = mixer.blend(get_user_model()) resp = shiftleader_view(req) assert resp.status_code == 200
def test_flag_changed(self): today = timezone.now().date create_runs(3, 321171, "collisions", "express", good=False, date=today) create_runs(3, 321171, "collisions", "prompt", date=today) runs = TrackerCertification.objects.all() report = ShiftLeaderReportDay(runs) assert [321171, 321171, 321172, 321172, 321173, 321173] == report.flag_changed().run_numbers()
def test_fills(self): create_runs(1, 321171, "cosmics", "express") create_runs(1, 321179, "cosmics", "express") create_runs(1, 321181, "cosmics", "express") create_runs(1, 321182, "cosmics", "express") create_runs(1, 321185, "cosmics", "express") runs = TrackerCertification.objects.all().order_by("run_number") report = ShiftLeaderReport(runs) assert [{ 'fill_number': 7049, 'run_number': [321185, 321182] }, { 'fill_number': 7048, 'run_number': [321181, 321179, 321171] }] == report.cosmics().express().good().fills()
def test_fill_numbers(self): create_runs(1, 321177, "cosmics", "express") create_runs(1, 321178, "cosmics", "express") create_runs(1, 321218, "cosmics", "express") create_runs(1, 323500, "cosmics", "express") runs = TrackerCertification.objects.all().order_by("run_number") report = ShiftLeaderReport(runs) assert [7048, 7052] == report.cosmics().express().good().fill_numbers()
def test_collisions_prompt(self): create_runs(5, 1, "collisions", "express") create_runs(3, 5, "collisions", "prompt") create_runs(5, 20, "cosmics", "express") create_runs(4, 26, "cosmics", "express") runs = TrackerCertification.objects.all().collisions() assert 8 == len(runs) for run in runs: assert "collisions" == run.runreconstruction.run.run_type runs = TrackerCertification.objects.all().collisions().prompt() assert 3 == len(runs) runs = TrackerCertification.objects.all().collisions().express() assert 5 == len(runs)
def test_list_of_run_certified(self): create_runs(2, 1, "collisions", "express", good=True, date="2018-05-14") create_runs(2, 6, "collisions", "express", good=False, date="2018-05-14") create_runs(2, 10, "collisions", "prompt", good=True, date="2018-05-15") create_runs(2, 15, "collisions", "prompt", good=False, date="2018-05-15") create_runs(2, 21, "cosmics", "express", good=True, date="2018-05-14") create_runs(2, 26, "cosmics", "express", good=False, date="2018-05-16") create_runs(2, 30, "cosmics", "prompt", good=True, date="2018-05-14") create_runs(2, 35, "cosmics", "prompt", good=False, date="2018-05-14") runs = TrackerCertification.objects.all().order_by( "runreconstruction__run__run_number") report = ShiftLeaderReport(runs) days = report.day_by_day() assert [1, 2, 6, 7] == days[0].express().collisions().run_numbers() assert [21, 22] == days[0].express().cosmics().run_numbers() assert [26, 27] == days[2].express().cosmics().run_numbers() assert [10, 11, 15, 16] == days[1].prompt().collisions().run_numbers() assert [30, 31, 35, 36] == days[0].prompt().cosmics().run_numbers()
def test_list_of_run_numbers(self): create_runs(5, 1, "collisions", "express", good=True) create_runs(4, 6, "collisions", "express", good=False) create_runs(3, 10, "collisions", "prompt", good=True) create_runs(3, 15, "collisions", "prompt", good=False) create_runs(5, 21, "cosmics", "express", good=True) create_runs(4, 26, "cosmics", "express", good=False) create_runs(3, 30, "cosmics", "prompt", good=True) create_runs(3, 35, "cosmics", "prompt", good=False) create_runs(2, 38, "cosmics", "rereco", good=False) create_runs(2, 40, "cosmics", "rereco", good=False) runs = TrackerCertification.objects.all().order_by("run_number") report = ShiftLeaderReport(runs) assert [ 1, 2, 3, 4, 5, 6, 7, 8, 9, ] == report.collisions().express().run_numbers() assert [10, 11, 12, 15, 16, 17] == report.collisions().prompt().run_numbers() assert [ 21, 22, 23, 24, 25, 26, 27, 28, 29, ] == report.cosmics().express().run_numbers() assert [30, 31, 32, 35, 36, 37] == report.cosmics().prompt().run_numbers() assert [1, 2, 3, 4, 5] == report.collisions().express().good().run_numbers() assert [10, 11, 12] == report.collisions().prompt().good().run_numbers() assert [21, 22, 23, 24, 25] == report.cosmics().express().good().run_numbers() assert [30, 31, 32] == report.cosmics().prompt().good().run_numbers() assert [6, 7, 8, 9] == report.collisions().express().bad().run_numbers() assert [15, 16, 17] == report.collisions().prompt().bad().run_numbers() assert [26, 27, 28, 29] == report.cosmics().express().bad().run_numbers() assert [35, 36, 37] == report.cosmics().prompt().bad().run_numbers() assert [38, 39, 40, 41] == report.cosmics().rereco().bad().run_numbers() assert [38, 39, 40, 41] == report.cosmics().rereco().bad().run_numbers()
def test_matches_with_run_registry(self): create_runs(2, 1, "collisions", "express") runs = TrackerCertification.objects.all() ret = runs.matches_with_run_registry() assert False == ret
def test_compare_with_run_registry(self): create_runs(3, 1, "collisions", "express") runs = TrackerCertification.objects.all() deviating, corresponding = runs.compare_with_run_registry() assert 3 == len(deviating) assert 3 == len(corresponding)
def test_collisions_prompt_bad(self): create_runs(5, 1, "collisions", "express", good=True) create_runs(4, 6, "collisions", "express", good=False) create_runs(3, 10, "collisions", "prompt", good=True) create_runs(3, 15, "collisions", "prompt", good=False) create_runs(5, 21, "cosmics", "express", good=True) create_runs(4, 26, "cosmics", "express", good=False) create_runs(3, 30, "cosmics", "prompt", good=True) create_runs(3, 35, "cosmics", "prompt", good=False) runs = TrackerCertification.objects.all().collisions().prompt() assert 6 == len(runs)