def setUp(self): self.user = w_factories.TolaUserFactory() self.client = test.Client() self.client.force_login(self.user.user) self.response = None self.program = w_factories.ProgramFactory( reporting_period_start=datetime.date(2017, 2, 1), reporting_period_end=datetime.date(2019, 10, 31))
def setUp(self): self.user = w_factories.UserFactory(first_name="FN", last_name="LN", username="******", is_superuser=True) self.user.set_password('password') self.user.save() self.tola_user = w_factories.TolaUserFactory(user=self.user) self.tola_user.save() self.client = test.Client(enforce_csrf_checks=False) self.client.login(username='******', password='******')
def setUp(self): country = w_factories.CountryFactory() self.program = w_factories.RFProgramFactory(tiers=True, levels=2) self.program.country.add(country) for level in self.program.levels.all(): i_factories.RFIndicatorFactory(program=self.program, level=level, targets=500, results=400) tola_user = w_factories.TolaUserFactory(country=country) w_factories.grant_program_access(tola_user, self.program, country, 'high') self.client.force_login(tola_user.user)
def setUp(self): country = w_factories.CountryFactory() self.program = w_factories.RFProgramFactory(migrated=False) self.program.country.add(country) for _, level in Indicator.OLD_LEVELS: i_factories.RFIndicatorFactory(program=self.program, old_level=level, targets=500, results=400) tola_user = w_factories.TolaUserFactory(country=country) w_factories.grant_program_access(tola_user, self.program, country, 'high') self.client.force_login(tola_user.user)
def setUp(self): country = w_factories.CountryFactory() self.program = w_factories.RFProgramFactory(migrated=False) self.program.country.add(country) self.indicator = i_factories.RFIndicatorFactory( program=self.program, target_frequency=Indicator.ANNUAL, targets=500, results=True) tola_user = w_factories.TolaUserFactory(country=country) w_factories.grant_program_access(tola_user, self.program, country, 'high') self.client.force_login(tola_user.user)
def setUp(self): country = w_factories.CountryFactory() self.program_empty = w_factories.RFProgramFactory() self.program_empty.country.add(country) self.program_full = w_factories.RFProgramFactory(tiers=True, levels=1) self.program_full.country.add(country) for level in self.program_full.levels.all(): indicator = i_factories.RFIndicatorFactory(program=self.program_full, level=level, targets=True) site = w_factories.SiteProfileFactory(country=country) result = i_factories.ResultFactory(indicator=indicator, achieved=100) result.site.set([site]) self.site = site tola_user = w_factories.TolaUserFactory(country=country) w_factories.grant_program_access(tola_user, self.program_empty, country, 'high') self.client.force_login(tola_user.user)
def setUp(self): self.program = w_factories.ProgramFactory() self.indicator = i_factories.IndicatorFactory( program=self.program, target_frequency=Indicator.ANNUAL) self.result = i_factories.ResultFactory(indicator=self.indicator, ) self.result.record_name = 'record name' self.result.evidence_url = 'evidence url' self.blank_result = i_factories.ResultFactory(indicator=self.indicator) self.tola_user = w_factories.TolaUserFactory() self.user = self.tola_user.user self.request = type('Request', (object, ), { 'has_write_access': True, 'user': self.user })()
def setUp(self): self.program = w_factories.ProgramFactory() self.indicator = i_factories.IndicatorFactory(program=self.program) self.result = i_factories.ResultFactory(indicator=self.indicator) self.user = w_factories.UserFactory(first_name="FN", last_name="LN", username="******", is_superuser=True) self.user.set_password('password') self.user.save() self.tola_user = w_factories.TolaUserFactory(user=self.user) self.tola_user.save() self.client = test.Client(enforce_csrf_checks=False) self.client.login(username='******', password='******')
def setUp(self): country = w_factories.CountryFactory() self.program = w_factories.RFProgramFactory( migrated=True, tiers=[u'Spécîal Chåracters1', u'###!@#$', 'asdf'], levels=2) self.program.country.add(country) self.indicator = i_factories.RFIndicatorFactory( program=self.program, target_frequency=Indicator.ANNUAL, targets=500, results=True, level=self.program.levels.all()[3]) tola_user = w_factories.TolaUserFactory(country=country) w_factories.grant_program_access(tola_user, self.program, country, 'high') self.client.force_login(tola_user.user)
def setUp(self): self.program = w_factories.ProgramFactory( reporting_period_start=datetime.date(2016, 1, 1), reporting_period_end=datetime.date(2016, 12, 31), ) self.indicator = i_factories.IndicatorFactory( program=self.program, target_frequency=Indicator.LOP) self.tola_user = w_factories.TolaUserFactory() self.user = self.tola_user.user self.request = type('Request', (object, ), { 'has_write_access': True, 'user': self.user })() self.form_kwargs = { 'user': self.user, 'indicator': self.indicator, 'program': self.program, 'request': self.request, }
def setUpTestData(cls): cls.country = w_factories.CountryFactory() cls.user = w_factories.TolaUserFactory() cls.user.countries.add(cls.country) for case in cls.expected_cases: program = w_factories.ProgramFactory( reporting_period_start=cls.program_start_date, reporting_period_end=cls.program_end_date, funding_status='Funded', name=case['name']) program.country.add(cls.country) for c in range(case['indicator_count']): data_count = 0 indicator = do_add_indicator(program) if c < case['targets_defined']: do_add_defined_target(indicator) if c < case['reported_results']: collect_date = cls.collect_date + datetime.timedelta( days=data_count) data_count += 1 result = do_add_reported_result(indicator, collect_date, program) if c < case['results_evidence']: do_add_evidence(result, program)
def setUp(self): self.tola_user = w_factories.TolaUserFactory() self.client = test.Client() self.client.force_login(self.tola_user.user)
def init(self): self.home_country = w_factories.CountryFactory(country='HOME country', code='HM') self.in_country = w_factories.CountryFactory(country='IN country', code='IN') self.out_country = w_factories.CountryFactory(country='OUT country', code='OUT') self.program_in_country = w_factories.ProgramFactory( name='program in IN country', gaitid='inpr', country=self.in_country, reporting_period_start=datetime.date(2016, 1, 1), reporting_period_end=datetime.date(2016, 12, 31)) self.program_in_country.country.add(self.in_country) self.program_out_of_country = w_factories.ProgramFactory( name='program in OUT country', gaitid='outpr', country=self.out_country, reporting_period_start=datetime.date(2016, 1, 1), reporting_period_end=datetime.date(2016, 12, 31)) self.program_out_of_country.country.clear() self.program_out_of_country.country.add(self.out_country) self.add_indicators() self.add_results() if Organization.objects.filter(pk=1).count() == 1: self.mercy_corps_organization = Organization.objects.get(pk=1) else: self.mercy_corps_organization = w_factories.OrganizationFactory( pk=1) self.partner_organization = w_factories.OrganizationFactory( name="Partner Org") user = d_factories.UserFactory(first_name='mercy corps', last_name='country low') self.mercy_corps_country_low = w_factories.TolaUserFactory( name="mercy corps country low", organization=self.mercy_corps_organization, country=self.home_country, user=user) w_factories.grant_country_access(self.mercy_corps_country_low, self.in_country, COUNTRY_ROLE_CHOICES[0][0]) user = d_factories.UserFactory(first_name='mercy corps', last_name='country admin') self.mercy_corps_country_admin = w_factories.TolaUserFactory( name="mercy corps country admin", organization=self.mercy_corps_organization, country=self.home_country, user=user) w_factories.grant_country_access(self.mercy_corps_country_admin, self.in_country, COUNTRY_ROLE_CHOICES[1][0]) user = d_factories.UserFactory(first_name='mercy corps', last_name='program low') self.mercy_corps_low = w_factories.TolaUserFactory( name="mercy corps low", organization=self.mercy_corps_organization, country=self.home_country, user=user) w_factories.grant_program_access(self.mercy_corps_low, self.program_in_country, self.in_country, PROGRAM_ROLE_CHOICES[0][0]) user = d_factories.UserFactory(first_name='mercy corps', last_name='program medium') self.mercy_corps_medium = w_factories.TolaUserFactory( name="mercy corps medium", organization=self.mercy_corps_organization, country=self.home_country, user=user) w_factories.grant_program_access(self.mercy_corps_medium, self.program_in_country, self.in_country, PROGRAM_ROLE_CHOICES[1][0]) user = d_factories.UserFactory(first_name='mercy corps', last_name='program high') self.mercy_corps_high = w_factories.TolaUserFactory( name="mercy corps high", organization=self.mercy_corps_organization, country=self.home_country, user=user) w_factories.grant_program_access(self.mercy_corps_high, self.program_in_country, self.in_country, PROGRAM_ROLE_CHOICES[2][0]) user = d_factories.UserFactory(first_name='mercy corps', last_name='super admin') self.mercy_corps_super_admin = w_factories.TolaUserFactory( name="mercy corps super admin", organization=self.mercy_corps_organization, country=self.home_country, user=user) self.mercy_corps_super_admin.user.is_superuser = True self.mercy_corps_super_admin.user.save() user = d_factories.UserFactory(first_name='non mercy corps', last_name='program low') self.non_mercy_corps_low = w_factories.TolaUserFactory( name="non-MC low", organization=self.partner_organization, country=self.home_country, user=user) w_factories.grant_program_access(self.non_mercy_corps_low, self.program_in_country, self.in_country, PROGRAM_ROLE_CHOICES[0][0]) user = d_factories.UserFactory(first_name='non mercy corps', last_name='program medium') self.non_mercy_corps_medium = w_factories.TolaUserFactory( name="non-MC medium", organization=self.partner_organization, country=self.home_country, user=user) w_factories.grant_program_access(self.non_mercy_corps_medium, self.program_in_country, self.in_country, PROGRAM_ROLE_CHOICES[1][0]) user = d_factories.UserFactory(first_name='non mercy corps', last_name='program high') self.non_mercy_corps_high = w_factories.TolaUserFactory( name="non-MC medium", organization=self.partner_organization, country=self.home_country, user=user) w_factories.grant_program_access(self.non_mercy_corps_high, self.program_in_country, self.in_country, PROGRAM_ROLE_CHOICES[2][0]) self.external_service = i_factories.ExternalServiceFactory()