def test_add_users_to_unsaved_organization(self, editor_user): data = { 'title': "Organization title", 'slug': "organization-title", 'institution_type': 'local', 'postal_code': "00-001", 'city': "Warszawa", 'street': "Królewska", 'street_number': 1, 'flat_number': 1, 'street_type': "ul", 'email': "*****@*****.**", 'fax': "123123123", 'tel': "123123123", 'epuap': "123123123", 'regon': "123456785", 'website': "http://test.pl", 'status': 'draft', 'users': [ editor_user.id, ] } form = OrganizationForm(data=data) assert form.is_valid() saved_org = form.save(commit=False) with pytest.raises(ValueError): saved_org.users.all()
def test_save_add_users_to_existing_organization(self, valid_organization, editor_user): data = { 'title': "Organization title", 'slug': "organization-title-2", 'institution_type': 'local', 'postal_code': "00-001", 'city': "Warszawa", 'street': "Królewska", 'street_number': 1, 'flat_number': 1, 'street_type': "ul", 'email': "*****@*****.**", 'fax': "123123123", 'tel': "123123123", 'epuap': "123123123", 'regon': "123456785", 'website': "http://test.pl", 'status': 'draft', 'users': [ editor_user.id, ] } assert editor_user not in valid_organization.users.all() form = OrganizationForm(data=data, instance=valid_organization) assert form.instance.pk assert form.is_valid() saved_org = form.save(commit=False) assert editor_user in saved_org.users.all()
def test_create_organization_and_add_users(self, active_editor): data = { 'title': "Organization title", 'slug': "organization-title-10", 'institution_type': 'local', 'postal_code': "00-001", 'city': "Warszawa", 'street': "Królewska", 'street_number': 1, 'flat_number': 1, 'street_type': "ul", 'email': "*****@*****.**", 'fax': "123123123", 'tel': "123123123", 'epuap': "123123123", 'regon': "123456785", 'website': "http://test.pl", 'status': 'draft', 'users': [ active_editor.id, ] } form = OrganizationForm(data=data) assert form.is_valid() saved_org = form.save() assert active_editor in saved_org.users.all()
def test_dataset_form_validity( self, slug, title, institution_type, postal_code, city, street, street_number, flat_number, street_type, email, fax, tel, epuap, regon, website, status, validity, ): form = OrganizationForm( data={ 'slug': slug, 'title': title, 'institution_type': institution_type, 'postal_code': postal_code, 'city': city, 'street': street, 'street_number': street_number, 'flat_number': flat_number, 'street_type': street_type, 'email': email, 'fax': fax, 'tel': tel, 'epuap': epuap, 'regon': regon, 'website': website, 'status': status, }) assert form.is_valid() is validity
def test_create_and_save(self): data = { 'title': "Organization title", 'slug': "organization-title-1", 'institution_type': 'local', 'postal_code': "00-001", 'city': "Warszawa", 'street': "Królewska", 'street_number': 1, 'flat_number': 1, 'street_type': "ul", 'email': "*****@*****.**", 'fax': "123123123", 'tel': "123123123", 'epuap': "123123123", 'regon': "123456785", 'website': "http://test.pl", } form = OrganizationForm(data=data) assert form.is_valid() form.save() last_ds = Organization.objects.last() assert last_ds.title == data['title']