def setUp(self): super().setUp() self.instance0 = FactoryFloor.TripFactory() self.instance1 = FactoryFloor.TripFactory() self.instance2 = FactoryFloor.TripFactory(lead=RegionFactory()) self.instance3 = FactoryFloor.TripFactory( is_adm_approval_required=True) self.test_url0 = reverse_lazy('travel:trip_delete', kwargs={ "pk": self.instance0.pk, "type": "adm-hit-list" }) self.test_url1 = reverse_lazy('travel:trip_delete', kwargs={ "pk": self.instance1.pk, "type": "region-1" }) self.test_url2 = reverse_lazy('travel:trip_delete', kwargs={ "pk": self.instance2.pk, "type": "back_to_verify" }) self.test_url3 = reverse_lazy('travel:trip_delete', kwargs={ "pk": self.instance3.pk, "type": "all" }) self.expected_template = 'travel/confirm_delete.html'
def test_submit(self): fy = shared_models.FiscalYear.objects.all()[faker.random_int( 0, shared_models.FiscalYear.objects.count() - 1)] region = RegionFactory().id data = {"region": region, "fy": fy} self.assert_success_url(self.test_url, data=data)
def get_valid_data(): start_date = faker.future_datetime( tzinfo=timezone.get_current_timezone()) end_date = start_date + datetime.timedelta( days=faker.random_int(1, 10)) return { 'trip_subcategory': models.TripSubcategory.objects.all()[faker.random_int( 0, models.TripSubcategory.objects.count() - 1)].id, 'name': faker.catch_phrase(), 'location': faker.catch_phrase(), "start_date": start_date.strftime("%Y-%m-%d %H:%M"), "end_date": end_date.strftime("%Y-%m-%d %H:%M"), 'is_virtual': faker.pybool(), 'is_adm_approval_required': faker.pybool(), 'lead': RegionFactory().id, }
def get_valid_data(): return { 'status': models.Status.objects.all()[faker.random_int(0, models.Status.objects.count() - 1)].id, 'entry_type': models.EntryType.objects.all()[faker.random_int(0, models.EntryType.objects.count() - 1)].id, 'title': faker.catch_phrase(), 'regions': RegionFactory().id, 'sectors': SectorFactory().id, }
def test_12m_expenditure_initiation_region(self): # a `default_reviewer` that is attached to a given `expenditure_initiation_region` should be accessible by the reverse name `default_reviewers` expenditure_initiation_region = RegionFactory() my_instance = self.instance my_instance.expenditure_initiation_region = expenditure_initiation_region my_instance.save() self.assertIn( my_instance, expenditure_initiation_region.travel_default_reviewers.all())
def get_valid_data(): return { 'region': RegionFactory().id, 'description_en': faker.text(), 'date': faker.date_time_this_year(tzinfo=timezone.get_current_timezone()), }
def setUp(self): super().setUp() self.test_urls = [ reverse_lazy('travel:export_trip_list', kwargs={ "fy": fiscal_year(sap_style=True), "region": "None", "adm": "None", "from_date": "None", "to_date": "None", }), reverse_lazy('travel:export_trip_list', kwargs={ "fy": "None", "region": RegionFactory().id, "adm": "None", "from_date": "None", "to_date": "None", }), reverse_lazy('travel:export_trip_list', kwargs={ "fy": "None", "region": "None", "adm": faker.pybool(), "from_date": "None", "to_date": "None", }), reverse_lazy('travel:export_trip_list', kwargs={ "fy": "None", "region": "None", "adm": "None", "from_date": faker.date_time_this_year().strftime("%Y-%m-%d"), "to_date": "None", }), reverse_lazy('travel:export_trip_list', kwargs={ "fy": "None", "region": "None", "adm": "None", "from_date": "None", "to_date": faker.date_time_this_year().strftime("%Y-%m-%d"), }), ] self.view = views.export_trip_list
def setUp(self): super().setUp() fy = shared_models.FiscalYear.objects.all()[faker.random_int( 0, shared_models.FiscalYear.objects.count() - 1)].id region = RegionFactory().id self.test_url = reverse_lazy('projects:admin_project_approval', kwargs={ "region": region, "fy": fy }) self.expected_template = 'projects/formset.html' self.user = self.get_and_login_user(in_group="projects_admin")
def get_valid_data(): start_date = faker.future_datetime(tzinfo=timezone.get_current_timezone()) end_date = start_date + datetime.timedelta(days=faker.random_int(1, 10)) valid_data = { "is_adm_approval_required": False, "location": faker.city(), "lead": RegionFactory().id, "name": faker.catch_phrase(), "start_date": start_date.strftime("%Y-%m-%d %H:%M"), "end_date": end_date.strftime("%Y-%m-%d %H:%M"), "trip_subcategory": models.TripSubcategory.objects.all()[faker.random_int(0, models.TripSubcategory.objects.count() - 1)].id, } return valid_data
def setUp(self): super().setUp() self.test_urls = [ reverse_lazy('travel:export_cfts_list', kwargs={ "fy": "None", "region": "None", "trip": "None", "user": "******", "from_date": "None", "to_date": "None", }), reverse_lazy('travel:export_cfts_list', kwargs={ "fy": fiscal_year(sap_style=True), "region": "None", "trip": "None", "user": "******", "from_date": "None", "to_date": "None", }), reverse_lazy('travel:export_cfts_list', kwargs={ "fy": "None", "region": RegionFactory().id, "trip": "None", "user": "******", "from_date": "None", "to_date": "None", }), reverse_lazy('travel:export_cfts_list', kwargs={ "fy": "None", "region": "None", "trip": TripFactory().id, "user": "******", "from_date": "None", "to_date": "None", }), reverse_lazy('travel:export_cfts_list', kwargs={ "fy": "None", "region": "None", "trip": "None", "user": UserFactory().id, "from_date": "None", "to_date": "None", }), ] self.view = views.export_cfts_list
def create_test_data(self): self.reg = RegionFactory() self.bra = BranchFactory(region=self.reg) self.div_1 = DivisionFactory(name="Div 1", branch=self.bra) self.div_2 = DivisionFactory(name="Div 2", branch=self.bra) self.sec_1 = SectionFactory(division=self.div_1) self.sec_2 = SectionFactory(division=self.div_2) self.fy_current = shared_models.FiscalYear.objects.get(pk=2020) self.fy_previous = shared_models.FiscalYear.objects.get(pk=2018) self.prj_1 = FactoryFloor.ProjectFactory(project_title="Test Project", year=self.fy_current, section=self.sec_1) self.prj_2 = FactoryFloor.ProjectFactory( project_title="Test Project 2", year=self.fy_previous, section=self.sec_2) self.om_1 = FactoryFloor.OMCostTravelFactory(project=self.prj_1) self.om_2 = FactoryFloor.OMCostEquipmentFactory(project=self.prj_2) # create two DFO and one non-DFO staff for columns 5 and 6 FactoryFloor.IndeterminateStaffFactory(project=self.prj_1, lead=True) FactoryFloor.IndeterminateStaffFactory(project=self.prj_1) FactoryFloor.StudentStaffFactory(project=self.prj_1)
def get_and_login_regional_admin(self): user = self.get_and_login_user() admin, created = TravelUser.objects.get_or_create(user=user) admin.region = RegionFactory() admin.save() return user
def get_valid_data(): return { 'region': RegionFactory().id, 'file_en': faker.url(), 'name': faker.catch_phrase(), }