def setUp(self): self.provider = ModelFactories.get_provider_test_object( new_id=42) self.campus = ModelFactories.get_campus_test_object( new_id=420) campus_form_url = reverse( 'edit-campus', args=( self.provider.id, self.campus.id)) self.campus_form_url = f'{self.live_server_url}{campus_form_url}' # logged in first to access any other urls self.user = User.objects.create_user( 'bobby2', '*****@*****.**', 'bob') self.client.login(username="******", password="******") # logged in, set session so the browser knows it has logged in cookie = self.client.cookies['sessionid'] # selenium will set cookie domain based on current page domain self.driver.get(self.live_server_url + '/admin/') self.driver.add_cookie({ 'name': 'sessionid', 'value': cookie.value, 'secure': False, 'path': '/'}) # need to update page for logged in user self.driver.refresh() self.driver.get(self.live_server_url + '/admin/')
def setUp(self): self.provider = ModelFactories.get_provider_test_object() self.fos = ModelFactories.get_field_of_study_test_object() self.data = { 'name': 'Non-official Bachelor of Arts', 'provider_id': self.provider.id, 'fos_id': self.fos.id }
def setUp(self): self.provider = ModelFactories.get_provider_test_object(new_id=42) self.campus = ModelFactories.get_campus_test_object(new_id=420) self.qualification = ModelFactories.get_qualification_test_object() self.qualification.campus = self.campus qualification_form_url = reverse('edit-qualification', args=(self.provider.id, self.campus.id, self.qualification.id)) self.qualification_form_url = ( f'{self.live_server_url}{qualification_form_url}')
def test_create_duplicate_campus(self): provider = ModelFactories.get_provider_test_object() campus = Campus(name='My Campus', provider=provider) campus.save() with self.assertRaisesMessage(ValidationError, 'Name is already taken'): campus_2 = Campus(name='My Campus', provider=provider) campus_2.save() provider_2 = ModelFactories.get_provider_test_object() campus_3 = Campus(name='My Campus', provider=provider_2) campus_3.save() self.assertEqual(campus.name, 'My Campus') self.assertEqual(campus_3.name, 'My Campus') with self.assertRaisesMessage(ValidationError, 'Name is already taken'): campus_4 = Campus(name='my campus', provider=provider) campus_4.save()
def setUp(self): self.url = reverse('create-saqa-qualification') self.provider = ModelFactories.get_provider_test_object() self.fos = ModelFactories.get_field_of_study_test_object() self.saqa_qualification_name = 'Master Degree in Wine and Champagne' self.data = { 'saqa_qualification': { 'saqa_qualification_name': self.saqa_qualification_name, 'provider_id': self.provider.id, 'fos_id': self.fos.id } }
def setUp(self): self.provider = ModelFactories.get_provider_test_object() self.campus1 = ModelFactories.get_campus_test_object() self.campus2 = ModelFactories.get_campus_test_object() self.qualification1 = ModelFactories.get_qualification_test_object() self.qualification2 = ModelFactories.get_qualification_test_object() self.qualification3 = ModelFactories.get_qualification_test_object() self.campus1.provider = self.provider self.campus2.provider = self.provider self.qualification1.campus = self.campus1 self.qualification2.campus = self.campus2 self.qualification3.campus = self.campus2 self.campus1.save() self.campus2.save() self.qualification1.save() self.qualification2.save() self.qualification3.save()
def setUp(self): self.client = Client() self.user = User.objects.create_user( '*****@*****.**', 'password', is_provider=True, is_active=True) self.user.groups.add(Group.objects.get(name='PROVIDER-ADMINS')) self.user.user_permissions.add( Permission.objects.get(codename='add_campus')) self.provider = ModelFactories.get_provider_test_object() self.provider.created_by = self.user self.provider.save() self.url = reverse('create-campus', args=[str(self.provider.id)]) self.data = { 'campus_name': 'My Campus' } self.client.login( email=self.user.email, password='******')
def test_create_campus(self): provider = ModelFactories.get_provider_test_object() provider.campus_set.create(name='My Campus') self.assertEqual(Campus.objects.count(), 1)
def setUp(self): self.provider = ModelFactories.get_provider_test_object() self.url = reverse('show-providers-api', kwargs={'version': 'v1'})
def test_create_duplicate_model(self): self.provider2 = ModelFactories.get_provider_test_object() self.provider1 = ModelFactories.get_provider_test_object() self.provider1.name = self.provider2.name with self.assertRaises(ValidationError): self.provider1.save()
def setUp(self): self.new_provider = ModelFactories.get_provider_test_object() self.user = User('bobby', '*****@*****.**', 'bob')