def setUpTestData(cls): # User creation cls.user = UserFactory() cls.user_adri = UserFactory() entity_version = EntityVersionFactory(acronym='ADRI') PartnershipEntityManagerFactory(entity=entity_version.entity, person__user=cls.user_adri) cls.user_gf = UserFactory() entity_manager = PartnershipEntityManagerFactory( person__user=cls.user_gf) cls.user_other_gf = UserFactory() PartnershipEntityManagerFactory(person__user=cls.user_other_gf, entity=entity_manager.entity) # Partner creation cls.partner = PartnerFactory() cls.partner_gf = PartnerFactory(author=cls.user_gf.person) # Misc cls.contact_type = ContactType.objects.create(value='foobar') cls.country = CountryFactory() cls.media = MediaFactory() cls.partner.medias.add(cls.media) cls.url = reverse('partnerships:partners:medias:update', kwargs={ 'partner_pk': cls.partner.pk, 'pk': cls.media.pk })
def setUpTestData(cls): PartnerFactory(organization__name='foo') PartnerFactory(organization__name='Foobar') PartnerFactory(organization__name='FooBarBaz') cls.user = PartnershipEntityManagerFactory().person.user cls.url = reverse('partnerships:partners:similar') cls.template_name = 'partnerships/partners/includes/similar_partners_preview.html'
def setUpTestData(cls): cls.partner_erasmus_last = PartnerFactory( erasmus_code='ZZZ', ) cls.partner_name = PartnerFactory( organization__name='foobar', ) cls.partner_partner_type = PartnerFactory( organization__type=RESEARCH_CENTER, ) cls.partner_pic_code = PartnerFactory( pic_code='foobar', ) cls.partner_erasmus_code = PartnerFactory( erasmus_code='foobar', ) cls.partner_is_valid = PartnerFactory( is_valid=False, ) cls.partner_not_active = PartnerFactory( dates__end=timezone.now() - timedelta(days=1), ) cls.partner_not_active2 = PartnerFactory( dates__start=timezone.now() + timedelta(days=1), ) cls.partner_tag = PartnerTagFactory() cls.partner_tags = PartnerFactory( tags=[cls.partner_tag], ) cls.user = PartnershipEntityManagerFactory().person.user cls.url = reverse('partnerships:partners:list')
def setUpTestData(cls): cls.user = PartnershipEntityManagerFactory().person.user cls.url = reverse('partnerships:autocomplete:partner_entity') cls.partner = PartnerFactory(organization__name="Université de Nantes") cls.entity = PartnerEntityFactory(partner=cls.partner, name="Entity A") PartnerEntityFactory(partner=cls.partner, name="Entity B") PartnerEntityFactory(name="Other entity")
def setUpTestData(cls): cls.user = UserFactory() entity_version = EntityVersionFactory(acronym='ADRI') PartnershipEntityManagerFactory( entity=entity_version.entity, person__user=cls.user, scopes=[PartnershipType.GENERAL.name] ) cls.partner = PartnerFactory() cls.partner_entity = PartnerEntityFactory(partner=cls.partner) AcademicYearFactory.produce_in_future(quantity=3) cls.education_field = DomainIscedFactory() cls.education_level = PartnershipYearEducationLevelFactory() cls.url = resolve_url('partnerships:create', type=PartnershipType.GENERAL) # Ucl root = EntityVersionFactory(parent=None).entity sector = EntityVersionFactory(entity_type=SECTOR, parent=root).entity cls.ucl_university = EntityVersionFactory( parent=sector, entity_type=FACULTY, ).entity cls.ucl_university_labo = EntityVersionFactory( parent=cls.ucl_university, ).entity UCLManagementEntityFactory(entity=cls.ucl_university) cls.university_offer = EducationGroupYearFactory( administration_entity=cls.ucl_university_labo, ) cls.data = { 'partnership_type': PartnershipType.GENERAL.name, 'comment': '', 'partner': cls.partner.pk, 'partner_entities': [cls.partner_entity.entity_id], 'supervisor': PersonFactory().pk, 'ucl_entity': cls.ucl_university.pk, 'university_offers': [cls.university_offer.pk], 'start_date': date.today(), 'end_date': date.today() + timedelta(days=365), 'year-is_sms': True, 'year-is_smp': False, 'year-is_sta': True, 'year-is_stt': False, 'year-education_fields': [cls.education_field.pk], 'year-education_levels': [cls.education_level.pk], 'year-entities': [], 'year-offers': [], 'year-funding_type': FundingTypeFactory().pk, 'missions': PartnershipMissionFactory().pk, 'subtype': PartnershipSubtypeFactory().pk, }
def setUpTestData(cls): cls.user = UserFactory() entity_version = EntityVersionFactory(acronym='ADRI') PartnershipEntityManagerFactory( entity=entity_version.entity, person__user=cls.user, scopes=[PartnershipType.COURSE.name] ) cls.partner = PartnerFactory() cls.partner_entity = PartnerEntityFactory(partner=cls.partner) AcademicYearFactory.produce_in_future(quantity=3) cls.education_field = DomainIscedFactory() cls.education_level = PartnershipYearEducationLevelFactory() cls.url = reverse( 'partnerships:create', kwargs={'type': PartnershipType.COURSE}, ) cls.start_academic_year = AcademicYearFactory(year=2150) cls.end_academic_year = AcademicYearFactory(year=2151) # Ucl root = EntityVersionFactory(parent=None).entity sector = EntityVersionFactory(entity_type=SECTOR, parent=root).entity cls.ucl_university = EntityVersionFactory( parent=sector, entity_type=FACULTY, ).entity cls.ucl_university_labo = EntityVersionFactory( parent=cls.ucl_university, ).entity UCLManagementEntityFactory(entity=cls.ucl_university) cls.university_offer = EducationGroupYearFactory(administration_entity=cls.ucl_university_labo) cls.data = { 'partnership_type': PartnershipType.COURSE.name, 'comment': '', 'partner': cls.partner.pk, 'partner_entities': [cls.partner_entity.entity_id], 'supervisor': PersonFactory().pk, 'ucl_entity': cls.ucl_university.pk, 'university_offers': [cls.university_offer.pk], 'year-education_fields': [cls.education_field.pk], 'year-education_levels': [cls.education_level.pk], 'year-entities': [], 'year-offers': [], 'year-start_academic_year': cls.start_academic_year.pk, 'year-end_academic_year': cls.end_academic_year.pk, 'year-funding_type': FundingTypeFactory().pk, 'missions': PartnershipMissionFactory().pk, 'subtype': PartnershipSubtypeFactory().pk, }
def setUpTestData(cls): # User creation cls.user = UserFactory() cls.user_adri = UserFactory() entity_version = EntityVersionFactory(acronym='ADRI') PartnershipEntityManagerFactory(entity=entity_version.entity, person__user=cls.user_adri) cls.user_gf = UserFactory() entity_manager = PartnershipEntityManagerFactory(person__user=cls.user_gf) cls.user_other_gf = UserFactory() PartnershipEntityManagerFactory(person__user=cls.user_other_gf, entity=entity_manager.entity) # Partner creation cls.partner = PartnerFactory(organization__prefix='XABCDE') cls.partner_gf = PartnerFactory(author=cls.user_gf.person) # Misc cls.country = CountryFactory() cls.data = { 'organization-name': 'test', 'partner-is_valid': 'on', 'organization-start_date': cls.partner.organization.start_date, 'organization-end_date': '', 'organization-type': cls.partner.organization.type, 'organization-code': 'test', 'partner-pic_code': 'test', 'partner-erasmus_code': 'test', 'partner-is_nonprofit': 'True', 'partner-is_public': 'True', 'partner-use_egracons': 'on', 'partner-comment': 'test', 'partner-phone': 'test', 'organization-website': 'http://*****:*****@test.test', 'partner-tags': [PartnerTagFactory().id], 'contact_address-street': 'test', 'contact_address-postal_code': 'test', 'contact_address-city': 'test', 'contact_address-country': cls.country.pk, 'contact_address-location_0': 10, 'contact_address-location_1': -12, } cls.url = reverse('partnerships:partners:update', kwargs={'pk': cls.partner.pk})
def setUpTestData(cls): cls.partner_erasmus_last = PartnerFactory(erasmus_code='ZZZ') cls.partner_name = PartnerFactory(organization__name='foobar') cls.partner_partner_type = PartnerFactory() cls.partner_pic_code = PartnerFactory(pic_code='foobar') cls.partner_erasmus_code = PartnerFactory(erasmus_code='foobar') cls.partner_is_valid = PartnerFactory(is_valid=False) cls.partner_is_actif = PartnerFactory( dates__end=timezone.now() - timedelta(days=1), ) cls.partner_tags = PartnerFactory() cls.user = PartnershipEntityManagerFactory().person.user cls.url = reverse('partnerships:partners:export')
def test_post_invalid_partner(self): self.client.force_login(self.user_adri) data = self.data.copy() partner = PartnerFactory( dates__end=timezone.now() - timedelta(days=1), ) entity = EntityWithVersionFactory(organization=partner.organization) data['partner_entities'] = [entity.pk] response = self.client.post(self.url, data=data) msg = _('partnership_inactif_partner_error') self.assertFormError(response, 'form', 'partner_entities', msg)
def setUpTestData(cls): cls.user = UserFactory() entity_version = EntityVersionFactory(acronym='ADRI') PartnershipEntityManagerFactory(entity=entity_version.entity, person__user=cls.user, scopes=[PartnershipType.PROJECT.name]) cls.partner = PartnerFactory() cls.partner_entity = PartnerEntityFactory(partner=cls.partner) AcademicYearFactory.produce_in_future(quantity=3) cls.education_field = DomainIscedFactory() cls.education_level = PartnershipYearEducationLevelFactory() cls.url = reverse( 'partnerships:create', kwargs={'type': PartnershipType.PROJECT}, ) # Ucl root = EntityVersionFactory(parent=None).entity sector = EntityVersionFactory(entity_type=SECTOR, parent=root).entity cls.ucl_university = EntityVersionFactory( parent=sector, entity_type=FACULTY, ).entity cls.ucl_university_labo = EntityVersionFactory( parent=cls.ucl_university, ).entity UCLManagementEntityFactory(entity=cls.ucl_university) cls.university_offer = EducationGroupYearFactory( administration_entity=cls.ucl_university_labo) cls.data = { 'partnership_type': PartnershipType.PROJECT.name, 'comment': '', 'partner': cls.partner.pk, 'partner_entities': [cls.partner_entity.entity_id], 'supervisor': PersonFactory().pk, 'ucl_entity': cls.ucl_university.pk, 'university_offers': [cls.university_offer.pk], 'start_date': date.today(), 'end_date': date.today() + timedelta(days=365), 'year-education_fields': [cls.education_field.pk], 'year-education_levels': [cls.education_level.pk], 'missions': PartnershipMissionFactory().pk, 'year-funding': 'fundingtype-%s' % FundingTypeFactory().pk, 'project_title': "Project title 1", 'id_number': "#132456", 'ucl_status': "coordinator", } PartnershipMissionFactory()
def setUpTestData(cls): # ucl_university root = EntityVersionFactory(parent=None).entity parent = EntityVersionFactory( acronym='AAA', entity_type=SECTOR, parent=root, ).entity cls.ucl_university = EntityVersionFactory( parent=parent, entity_type=FACULTY, acronym='ZZZ', ).entity cls.ucl_university_labo = EntityVersionFactory( parent=cls.ucl_university, acronym='AAA', ).entity cls.user = PartnershipEntityManagerFactory().person.user cls.user_adri = UserFactory() root = EntityVersionFactory(parent=None).entity PartnershipEntityManagerFactory( entity=EntityVersionFactory(acronym='ADRI', parent=root).entity, person__user=cls.user_adri, ) PartnershipAgreementFactory( partnership__ucl_entity=cls.ucl_university_labo, ) PartnershipAgreementFactory( partnership__ucl_entity=cls.ucl_university_labo, ) cls.media = MediaFactory(file=ContentFile(b'', 'something.pdf')) cls.agreement = PartnershipAgreementFactory( partnership__ucl_entity=cls.ucl_university_labo, partnership__partnership_type=PartnershipType.COURSE.name, partnership__start_date=date(2017, 9, 1), partnership__end_date=date(2030, 9, 1), start_date=date(2017, 9, 1), end_date=date(2025, 9, 1), media=cls.media, ) # With multilateral entity = EntityWithVersionFactory(organization__type=ACADEMIC_PARTNER) cls.agreement.partnership.partner_entities.add(entity) PartnerFactory(organization=entity.organization) cls.url = reverse('partnerships:agreements-list') cls.export_url = reverse('partnerships:export_agreements')
def setUp(self): self.country = CountryFactory() # Partner creation self.partner = PartnerFactory( is_valid=False, erasmus_code=None, is_nonprofit=None, is_public=None, email=None, phone=None, contact_address__city='test', contact_address__country_id=self.country.pk, contact_address__location=Point(-12, 10), ) # For the start_date for the test self.start_date = self.partner.organization.start_date self.entity = self.partner.organization.entity_set.first() version = self.entity.get_latest_entity_version() version.start_date = date(2007, 7, 7) version.save() address = self.partner.contact_address self.assertEqual(self.entity.entityversion_set.count(), 1) self.start_date = self.partner.organization.start_date self.data = { 'organization-name': self.partner.organization.name, 'organization-start_date': self.start_date, 'organization-type': self.partner.organization.type, 'organization-end_date': '', 'partner-pic_code': self.partner.pic_code, 'organization-website': self.partner.organization.website, 'contact_address-city': 'test', 'contact_address-country': self.country.pk, 'contact_address-street_number': address.street_number, 'contact_address-street': address.street, 'contact_address-state': address.state, 'contact_address-postal_code': address.postal_code, 'contact_address-location_0': 10.0, 'contact_address-location_1': -12.0, } self.url = reverse('partnerships:partners:update', kwargs={'pk': self.partner.pk}) self.client.force_login(self.user_adri) self.assertEqual(self.entity.entityversion_set.count(), 1)
def test_update_main_partner(self): self.client.force_login(self.user_adri) partner_main = PartnerFactory(organization__type=MAIN) url = reverse('partnerships:partners:update', kwargs={'pk': partner_main.pk}) response = self.client.get(url) self.assertTemplateUsed(response, 'access_denied.html')
def setUpTestData(cls): cls.user = UserFactory() cls.user_adri = UserFactory() entity_version = EntityVersionFactory(acronym='ADRI') PartnershipEntityManagerFactory(entity=entity_version.entity, person__user=cls.user_adri) cls.user_gs = UserFactory() cls.user_gf = UserFactory() cls.user_other_gf = UserFactory() cls.user_project = UserFactory() PartnershipEntityManagerFactory( entity=entity_version.entity, person__user=cls.user_project, scopes=[PartnershipType.PROJECT.name] ) # Dates : cls.partner = PartnerFactory() cls.partner_entity = PartnerEntityFactory(partner=cls.partner) # Years cls.academic_year_2149 = AcademicYearFactory(year=2149) cls.start_academic_year = AcademicYearFactory(year=2150) cls.from_academic_year = AcademicYearFactory(year=2151) cls.end_academic_year = AcademicYearFactory(year=2152) cls.academic_year_2153 = AcademicYearFactory(year=2153) # Initialize config PartnershipConfiguration.objects.update( partnership_creation_update_min_year_id=cls.academic_year_2149.pk ) cls.education_field = DomainIscedFactory() cls.education_level = PartnershipYearEducationLevelFactory() # Ucl root = EntityVersionFactory(parent=None).entity sector = EntityVersionFactory( entity_type=SECTOR, parent=root, ).entity cls.ucl_university = EntityVersionFactory( parent=sector, entity_type=FACULTY, ).entity UCLManagementEntityFactory(entity=cls.ucl_university) cls.ucl_university_labo = EntityVersionFactory( parent=cls.ucl_university, ).entity UCLManagementEntityFactory(entity=cls.ucl_university_labo) cls.ucl_university_not_choice = EntityVersionFactory( entity_type=FACULTY, ).entity cls.ucl_university_labo_not_choice = EntityVersionFactory( parent=cls.ucl_university_not_choice, ).entity cls.university_offer = EducationGroupYearFactory(administration_entity=cls.ucl_university_labo) PartnershipEntityManagerFactory(person__user=cls.user_gs, entity=sector) PartnershipEntityManagerFactory(person__user=cls.user_gf, entity=cls.ucl_university) PartnershipEntityManagerFactory(person__user=cls.user_other_gf, entity=cls.ucl_university) mission = PartnershipMission.objects.filter( types__contains=[PartnershipType.MOBILITY.name], ).first() cls.partner_gf = PartnerFactory(author=cls.user_gf.person) cls.partnership = PartnershipFactory( partner=cls.partner, partner_entity=cls.partner_entity.entity, author=cls.user_gf.person, years=[], ucl_entity=cls.ucl_university, missions=[mission], ) PartnershipYearFactory( partnership=cls.partnership, academic_year=cls.start_academic_year, ) PartnershipYearFactory( partnership=cls.partnership, academic_year=cls.from_academic_year, ) PartnershipYearFactory( partnership=cls.partnership, academic_year=cls.end_academic_year, ) cls.url = resolve_url('partnerships:update', pk=cls.partnership.pk) cls.other_partnership = PartnershipFactory( partnership_type=PartnershipType.PROJECT.name, ) cls.other_url = resolve_url('partnerships:update', pk=cls.other_partnership.pk) cls.data = { 'partnership_type': PartnershipType.MOBILITY.name, 'comment': '', 'partner': cls.partner.pk, 'partner_entities': [cls.partner_entity.entity_id], 'supervisor': '', 'ucl_entity': cls.ucl_university_labo.pk, 'year-is_sms': True, 'year-is_smp': False, 'year-is_smst': True, 'year-is_sta': True, 'year-is_stt': False, 'year-education_fields': [cls.education_field.pk], 'year-education_levels': [cls.education_level.pk], 'year-entities': [], 'year-offers': [], 'year-start_academic_year': cls.start_academic_year.pk, 'year-from_academic_year': cls.from_academic_year.pk, 'year-end_academic_year': cls.end_academic_year.pk, }
def setUpTestData(cls): class EducationGroupYearFactory(BaseEducationGroupYearFactory): management_entity = None administration_entity = None enrollment_campus = None cls.url = reverse('partnership_api_v1:configuration') AcademicYearFactory.produce_in_future(quantity=2) current_academic_year = PartnershipConfiguration.get_configuration().get_current_academic_year_for_api() # Partnerships cls.supervisor_partnership = PersonFactory() cls.supervisor_management_entity = PersonFactory() partnership = PartnershipFactory( supervisor=cls.supervisor_partnership, years=[] ) year = PartnershipYearFactory( partnership=partnership, academic_year=current_academic_year, ) year.offers.add(EducationGroupYearFactory()) education_field = DomainIscedFactory(title_en='foo', title_fr='bar') year.education_fields.add(education_field) PartnershipAgreementFactory( partnership=partnership, start_academic_year=current_academic_year, end_academic_year__year=current_academic_year.year + 1, ) root = EntityWithVersionFactory() parent = EntityVersionFactory(acronym="SSH", entity_type=SECTOR, parent=root) partnership = PartnershipFactory( partner__contact_address=True, years__academic_year=current_academic_year, ucl_entity=EntityVersionFactory( acronym="FIAL", entity_type=FACULTY, parent=parent.entity, ).entity, ) PartnershipAgreementFactory( partnership=partnership, start_academic_year=current_academic_year, end_academic_year__year=current_academic_year.year + 1, ) UCLManagementEntityFactory( entity=partnership.ucl_entity, academic_responsible=cls.supervisor_management_entity ) FundingSource.objects.all().delete() FundingTypeFactory() # Some noises cls.noisy_partner = PartnerFactory() cls.noisy_partnership = PartnershipFactory() # Continents continent = Continent.objects.create(code='AA', name='aaaaa') CountryFactory(continent=continent) CountryFactory(continent=continent) CountryFactory()
def setUpTestData(cls): cls.url = reverse('partnership_api_v1:partnerships') AcademicYearFactory.produce_in_future(quantity=3) config = PartnershipConfiguration.get_configuration() current_academic_year = config.get_current_academic_year_for_api() cls.current_academic_year = current_academic_year # Continents cls.continent = Continent.objects.create(code='AA', name='aaaaa') cls.country = CountryFactory( name="Albania", iso_code='AL', continent=cls.continent, ) CountryFactory(continent=cls.continent) CountryFactory() # Partnerships root = EntityVersionFactory(parent=None, acronym="UCL").entity sector = EntityVersionFactory(parent=root, acronym="SSH").entity entity = EntityVersionFactory(parent=sector, acronym="FIAL").entity cls.supervisor_partnership = PersonFactory() cls.supervisor_management_entity = PersonFactory() cls.funding_type = FundingTypeFactory() cls.funding_program = cls.funding_type.program cls.funding_source = cls.funding_program.source cls.subtype = PartnershipSubtypeFactory() cls.partnership = PartnershipFactory( ucl_entity=entity, supervisor=cls.supervisor_partnership, years=[], partner__contact_address__country=cls.country, partner__contact_address__city="Tirana", subtype=cls.subtype, ) cls.partner = cls.partnership.partner_entities.first( ).organization.partner year = PartnershipYearFactory( partnership=cls.partnership, academic_year=current_academic_year, is_smp=True, eligible=False, funding_source=cls.funding_source, funding_program=cls.funding_program, funding_type=cls.funding_type, ) cls.education_field = DomainIscedFactory() year.education_fields.add(cls.education_field) PartnershipAgreementFactory( partnership=cls.partnership, start_academic_year=current_academic_year, end_academic_year__year=current_academic_year.year + 1, status=AgreementStatus.VALIDATED.name, media__is_visible_in_portal=False, ) cls.management_entity = UCLManagementEntityFactory( entity=cls.partnership.ucl_entity, ) partnership_without_funding = PartnershipFactory( ucl_entity=EntityVersionFactory(parent=sector, acronym="DRT").entity, years=[], ) PartnershipYearFactory( partnership=partnership_without_funding, academic_year=current_academic_year, ) PartnershipAgreementFactory( partnership=partnership_without_funding, start_academic_year=current_academic_year, end_academic_year__year=current_academic_year.year + 1, status=AgreementStatus.VALIDATED.name, ) UCLManagementEntityFactory( entity=partnership_without_funding.ucl_entity, contact_in_person=None, contact_out_person=None, ) cls.partnership_2 = PartnershipFactory( supervisor=None, years__academic_year=current_academic_year, partner__contact_address__country__name="Zambia", partner__contact_address__country__iso_code="ZM", partner__contact_address__city="Lusaka", partner__contact_address__location=Point(-15.4166, 28.2822), ) cls.partner_2 = cls.partnership_2.partner_entities.first( ).organization.partner PartnershipAgreementFactory( partnership=cls.partnership_2, start_academic_year=current_academic_year, end_academic_year__year=current_academic_year.year + 1, status=AgreementStatus.VALIDATED.name, ) cls.management_entity = UCLManagementEntityFactory( entity=cls.partnership_2.ucl_entity, academic_responsible=cls.supervisor_management_entity, contact_out_person=None, contact_in_person=None, ) cls.financing = FinancingFactory(academic_year=current_academic_year) cls.financing.countries.add(cls.partner_2.contact_address.country) # Other types cls.partnership_project = PartnershipFactory( partnership_type=PartnershipType.PROJECT.name, start_date=date(current_academic_year.year, 1, 1), end_date=date(current_academic_year.year, 10, 1), partner__contact_address__country__iso_code="ZM", partner__contact_address__city="Ndola", ) PartnershipYearFactory( partnership=cls.partnership_project, academic_year=current_academic_year, funding_source=FundingSourceFactory(), ) # Multilateral cls.partnership_course = PartnershipFactory( partnership_type=PartnershipType.COURSE.name, start_date=date(current_academic_year.year, 1, 1), end_date=date(current_academic_year.year + 1, 10, 1), ) entity = EntityWithVersionFactory(organization__type=ACADEMIC_PARTNER) cls.partnership_course.partner_entities.add(entity) PartnerFactory(organization=entity.organization) cls.partnership_general = PartnershipFactory( partnership_type=PartnershipType.GENERAL.name, start_date=date(current_academic_year.year - 1, 1, 1), end_date=date(current_academic_year.year + 3, 10, 1), partner__contact_address__country__iso_code="ZM", partner__contact_address__city="Kabwe", partner__contact_address__location=Point(-14.4415250, 28.4441831), years=[ PartnershipYearFactory(academic_year=current_academic_year) ], ) PartnershipAgreementFactory( partnership=cls.partnership_general, start_date=date(current_academic_year.year - 10, 10, 1), end_date=date(current_academic_year.year + 7, 10, 1), status=AgreementStatus.VALIDATED.name, ) # Some noises - Agreement not validated or not in status validated PartnerFactory() cls.partnership_without_agreement = PartnershipFactory() cls.partnership_not_public = PartnershipFactory(is_public=False) cls.partnership_with_agreement_not_validated = PartnershipFactory( supervisor=None, years__academic_year=current_academic_year, ) PartnershipAgreementFactory( partnership=cls.partnership_with_agreement_not_validated, start_academic_year=current_academic_year, end_academic_year__year=current_academic_year.year + 1, status=AgreementStatus.WAITING.name, )
def setUpTestData(cls): cls.user = UserFactory() cls.user_adri = UserFactory() cls.user_gs = UserFactory() cls.user_gf = UserFactory() cls.user_other_gf = UserFactory() cls.user_2_types = UserFactory() root = EntityVersionFactory(parent=None).entity entity_version = EntityVersionFactory(acronym='ADRI', parent=root) PartnershipEntityManagerFactory( entity=entity_version.entity, person__user=cls.user_adri, ) PartnershipEntityManagerFactory(entity=entity_version.entity, person__user=cls.user_2_types, scopes=[ PartnershipType.MOBILITY.name, PartnershipType.GENERAL.name ]) cls.partner = PartnerFactory() cls.partner_entity = PartnerEntityFactory(partner=cls.partner) cls.partner_entity_2 = PartnerEntityFactory(partner=cls.partner) cls.start_academic_year = AcademicYearFactory(year=2150) cls.end_academic_year = AcademicYearFactory(year=2151) AcademicYearFactory.produce_in_future(quantity=3) cls.education_field = DomainIscedFactory() cls.education_level = PartnershipYearEducationLevelFactory() cls.url = reverse('partnerships:create') cls.mobility_url = reverse( 'partnerships:create', kwargs={'type': PartnershipType.MOBILITY}, ) # Ucl sector = EntityVersionFactory( parent=root, entity_type=SECTOR, ).entity cls.ucl_university = EntityVersionFactory( parent=sector, entity_type=FACULTY, ).entity cls.ucl_university_labo = EntityVersionFactory( parent=cls.ucl_university, ).entity UCLManagementEntityFactory(entity=cls.ucl_university) UCLManagementEntityFactory() cls.ucl_university_not_choice = EntityVersionFactory( entity_type=FACULTY, ).entity cls.ucl_university_labo_not_choice = EntityVersionFactory( parent=cls.ucl_university_not_choice, ).entity cls.university_offer = EducationGroupYearFactory( administration_entity=cls.ucl_university_labo) PartnershipEntityManagerFactory(person__user=cls.user_gs, entity=sector) PartnershipEntityManagerFactory(person__user=cls.user_gf, entity=cls.ucl_university) PartnershipEntityManagerFactory(person__user=cls.user_other_gf, entity=cls.ucl_university) PartnershipEntityManagerFactory(person__user=cls.user_2_types, entity=cls.ucl_university) cls.data = { 'partnership_type': PartnershipType.MOBILITY.name, 'comment': '', 'partner': cls.partner.pk, 'partner_entities': [cls.partner_entity.entity_id], 'supervisor': '', 'ucl_entity': cls.ucl_university.pk, 'university_offers': [cls.university_offer.pk], 'year-is_sms': True, 'year-is_smp': False, 'year-is_sta': True, 'year-is_stt': False, 'year-education_fields': [cls.education_field.pk], 'year-education_levels': [cls.education_level.pk], 'year-entities': [], 'year-offers': [], 'year-start_academic_year': cls.start_academic_year.pk, 'year-end_academic_year': cls.end_academic_year.pk, 'missions': [PartnershipMissionFactory().pk], }
class PartnershipFactory(BasePartnershipFactory): partner = PartnerFactory() ucl_entity = EntityWithVersionFactory(organization=None)
def setUpTestData(cls): cls.user = UserFactory() entity_version = EntityVersionFactory(acronym='ADRI') PartnershipEntityManagerFactory( entity=entity_version.entity, person__user=cls.user, scopes=[PartnershipType.COURSE.name] ) # Dates : cls.partner = PartnerFactory() cls.partner_entity = PartnerEntityFactory(partner=cls.partner) # Years cls.start_academic_year = AcademicYearFactory(year=2150) cls.from_academic_year = AcademicYearFactory(year=2151) cls.end_academic_year = AcademicYearFactory(year=2152) cls.education_field = DomainIscedFactory() cls.education_level = PartnershipYearEducationLevelFactory() # Ucl root = EntityVersionFactory(parent=None).entity sector = EntityVersionFactory(entity_type=SECTOR, parent=root).entity cls.ucl_university = EntityVersionFactory( parent=sector, entity_type=FACULTY, ).entity UCLManagementEntityFactory(entity=cls.ucl_university) cls.ucl_university_labo = EntityVersionFactory( parent=cls.ucl_university, ).entity UCLManagementEntityFactory(entity=cls.ucl_university_labo) cls.partnership = PartnershipFactory( partnership_type=PartnershipType.COURSE.name, partner=cls.partner, partner_entity=cls.partner_entity.entity, author=cls.user.person, years=[], ucl_entity=cls.ucl_university, ) PartnershipYearFactory( partnership=cls.partnership, academic_year=cls.start_academic_year, ) PartnershipYearFactory( partnership=cls.partnership, academic_year=cls.from_academic_year, ) PartnershipYearFactory( partnership=cls.partnership, academic_year=cls.end_academic_year, ) cls.url = resolve_url('partnerships:update', pk=cls.partnership.pk) cls.data = { 'comment': '', 'partner': cls.partner.pk, 'partner_entities': [cls.partner_entity.entity_id], 'supervisor': cls.user.person.pk, 'ucl_entity': cls.ucl_university_labo.pk, 'year-start_academic_year': cls.start_academic_year.pk, 'year-end_academic_year': cls.end_academic_year.pk, 'year-from_academic_year': cls.from_academic_year.pk, 'year-education_fields': [cls.education_field.pk], 'year-education_levels': [cls.education_level.pk], 'year-entities': [], 'year-offers': [], 'year-funding_type': FundingTypeFactory().pk, 'missions': [ PartnershipMissionFactory().pk, PartnershipMissionFactory().pk, ], 'subtype': PartnershipSubtypeFactory().pk, }
def setUpTestData(cls): cls.partner = PartnerFactory(author=PersonFactory()) cls.user = PartnershipEntityManagerFactory().person.user cls.url = reverse('partnerships:partners:detail', kwargs={'pk': cls.partner.pk})