def test_auth_no_perm(self, logged_in_client): # Arrange sc_name = "ceramics" dep = GovDepartmentFactory() sc = SupplyChainFactory(gov_department=dep, name=sc_name) sa = StrategicActionFactory.create(supply_chain=sc) sau = StrategicActionUpdateFactory( status=Status.SUBMITTED, submission_date=date.today(), strategic_action=sa, supply_chain=sc, ) # Act resp = logged_in_client.get( reverse( "monthly-update-review", kwargs={ "supply_chain_slug": slugify(sc_name), "action_slug": sa.slug, "update_slug": sau.slug, }, )) # Assert assert resp.status_code == 403
def test_update_details_ongoing(self, logged_in_client, test_user): # Arrange sc_name = "ceramics" sa_name = "action 01" update_slug = "05-2021" sc = SupplyChainFactory.create( name=sc_name, gov_department=test_user.gov_department, last_submission_date=date.today(), ) sa = StrategicActionFactory.create(name=sa_name, supply_chain=sc, is_ongoing=True) StrategicActionUpdateFactory( slug=update_slug, status=Status.SUBMITTED, submission_date=date.today(), strategic_action=sa, supply_chain=sc, ) # Act resp = logged_in_client.get( reverse( "monthly-update-review", kwargs={ "supply_chain_slug": sc_name, "action_slug": slugify(sa_name), "update_slug": update_slug, }, )) # Assert assert resp.context["supply_chain_name"] == sc_name assert resp.context["completion_estimation"] == "Ongoing"
def test_since_with_filter(self): # Arrange sc = SupplyChainFactory.create(name="Supply Chain 1") sa = StrategicActionFactory.create(name="SA 01", supply_chain=sc) sau = StrategicActionUpdateFactory.create( status=StrategicActionUpdate.Status.IN_PROGRESS, supply_chain=sc, strategic_action=sa, ) # Act sau_prog = StrategicActionUpdate.objects.since( deadline=date.today() - timedelta(days=1), supply_chain=sc, status=StrategicActionUpdate.Status.IN_PROGRESS, ) sau_comp = StrategicActionUpdate.objects.since( deadline=date.today() - timedelta(days=1), supply_chain=sc, status=StrategicActionUpdate.Status.READY_TO_SUBMIT, ) # Assert assert sau_prog[0] == sau assert sau_comp.count() == 0
def taskcomp_stub(test_user): sc_name = "Supply Chain 1" sc = SupplyChainFactory.create( name=sc_name, gov_department=test_user.gov_department, last_submission_date=date.today(), ) scs = SupplyChainFactory.create_batch( 2, gov_department=test_user.gov_department) sa = StrategicActionFactory.create(supply_chain=sc) StrategicActionUpdateFactory( status=Status.SUBMITTED, submission_date=date.today(), strategic_action=sa, supply_chain=sc, ) yield { "sc_name": sc_name, "url": reverse( "supply-chain-update-complete", kwargs={"supply_chain_slug": slugify(sc_name)}, ), }
def update_stub(test_user): sc_name = "Supply Chain 1" sa_name = "action 01" sa_completion = "2021-02-01" update_slug = "05-2021" sau_rag = "Amber" sau_reason = "Brexit negotiations" sc = SupplyChainFactory.create( name=sc_name, gov_department=test_user.gov_department, last_submission_date=date.today(), ) sa = StrategicActionFactory.create(name=sa_name, supply_chain=sc, target_completion_date=sa_completion) StrategicActionUpdateFactory( slug=update_slug, status=Status.SUBMITTED, submission_date=date.today(), strategic_action=sa, supply_chain=sc, implementation_rag_rating=sau_rag, reason_for_delays=sau_reason, ) yield { "sc": sc, "sa": sa, "sc_name": sc_name, "sa_name": sa_name, "sa_completion": sa_completion, "sau_rag": sau_rag, "sau_reason": sau_reason, "update_slug": update_slug, "url": reverse( "monthly-update-review", kwargs={ "supply_chain_slug": slugify(sc_name), "action_slug": slugify(sa_name), "update_slug": update_slug, }, ), }
def model_stub(test_user): sc = SupplyChainFactory.create( name=sc_name, gov_department=test_user.gov_department, last_submission_date=date.today(), ) sa = StrategicActionFactory.create(supply_chain=sc, name=sa_name) StrategicActionUpdateFactory( status=Status.SUBMITTED, submission_date=date(day=1, month=1, year=2020), strategic_action=sa, supply_chain=sc, )