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 test_delete_qualifications(self): saqas = [ ModelFactories.get_saqa_qualification_test_object(), SAQAQualification.objects.create( name='Hello World', nqf_level='42', saqa_id=42, sub_field_of_study=( ModelFactories.get_sub_field_of_study_test_object( new_id=42)), ) ] # build form data form_data = {'saqa_ids': '{} {}'.format(saqas[0].id, saqas[1].id)} self.campus.save_qualifications(form_data, self.user) self.assertEqual(len(self.campus.qualifications), 2) # add those two qualifications to another campus self.other_campus = ModelFactories.get_campus_test_object(new_id=421) self.other_campus.save_qualifications(form_data, self.user) form_data = {'saqa_ids': '{}'.format(saqas[1].id)} # it should remove the first saqa for the first campus. self.campus.delete_qualifications(form_data) self.assertEqual(len(self.campus.qualifications), 1) self.assertEqual( self.campus.qualifications[0]['saqa_qualification__saqa_id'], 42) # it should not remove qualifications for the second campus. self.assertEqual(len(self.other_campus.qualifications), 2)
def setUp(self): self.campus = ModelFactories.get_campus_test_object() provider_url = reverse( 'show-provider', args=[str(self.campus.provider.id)]) self.driver.get(f'{self.live_server_url}{provider_url}')
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 test_is_new_provider(self): self.assertTrue(self.new_provider.is_new_provider) campus = ModelFactories.get_campus_test_object() campus.provider_id = self.new_provider.id campus.save() self.assertEqual(self.new_provider.id, campus.provider_id) self.assertFalse(self.new_provider.is_new_provider)
def setUp(self): self.campus = ModelFactories.get_campus_test_object() self.url = reverse('create-or-update-event', args=[str(self.campus.id), 'campus']) self.data = { 'name': 'TestName', 'date_start': '2999-10-14', 'date_end': '2999-10-15', 'http_link': '' }
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 setUp(self): self.campus = ModelFactories.get_campus_test_object() self.provider = self.campus.provider self.requirement_subject = ModelFactories.get_qualification_entrance_requirement_to( ) # noqa self.qualification = self.requirement_subject.qualification self.qualification.campus = self.campus self.qualification.provider = self.provider self.qualification.save() output_data = providerView.excel_dump(self.provider.id) named_tempfile = NamedTemporaryFile(suffix='.xlsx') with open(named_tempfile.name, 'wb') as file: file.write(output_data) excel = SmartExcel( definition=OPENEDU_EXCEL_DEFINITION, data=OpenEduSmartExcelData(provider_id=self.provider.id), path=named_tempfile.name) # provider.dump(None, provider.id) self.data = excel.parse()
def setUp(self): self.campus = ModelFactories.get_campus_test_object(new_id=420)
def setUp(self): self.campus = ModelFactories.get_campus_test_object(new_id=420) self.user = User.objects.get(pk=3)
def test_campus_page_add_events_empty_date(self): campus_object = Campus.objects.all().first() if len(str(campus_object)) > 0: pass else: campus_object = ModelFactories.get_campus_test_object() self.driver.get(self.campus_form_url) # User sees the first page's title title = self.driver.find_element_by_tag_name('h2').text self.assertIn('Campus Details', title) # and the footer shows him what page he is on self.assert_footer('Page 1 of') # User clicks next self.get_next_button().click() # User sees they are on the 2nd page from the footer self.assert_footer('Page 2 of') # User clicks next self.get_next_button().click() # User sees they are on the 3rd page from the footer self.assert_footer('Page 3 of') # User sees the 4 form fields - 1 of each and there are 2 hidden inputs form_content = self.driver.find_element_by_css_selector( '.form-group') # Get inputs form_inputs = form_content.find_elements_by_tag_name('input') self.assertEqual(len(form_inputs), 6) # 4 form fields + 2 hidden self.driver.find_element_by_id( 'add-campus-event').click() form_inputs = form_content.find_elements_by_tag_name('input') self.assertEqual(len(form_inputs), 10) # The existing 6 + 4 new # There should now be 2 of each input name_inputs = form_content.find_elements_by_name( 'campus-dates-event_name') self.assertEqual(len(name_inputs), 2) date_start_inputs = form_content.find_elements_by_name( 'campus-dates-date_start') self.assertEqual(len(date_start_inputs), 2) date_end_inputs = form_content.find_elements_by_name( 'campus-dates-date_end') self.assertEqual(len(date_end_inputs), 2) http_link_inputs = form_content.find_elements_by_name( 'campus-dates-http_link') self.assertEqual(len(http_link_inputs), 2) # The user fills in the data for each field name1 = 'Sel Test Name 1' name2 = 'Sel Test Name 2' name_inputs[0].send_keys(name1) date_start_inputs[0].send_keys('04/09/2019') date_end_inputs[0].send_keys('05/09/2019') http_link_inputs[0].send_keys('*****@*****.**') name_inputs[1].send_keys(name2) date_start_inputs[1].send_keys('07/11/2119') date_end_inputs[1].send_keys('') http_link_inputs[1].send_keys('*****@*****.**') # They click next self.get_next_button().click() # The form responds with a validation error self.assertIn(self.driver.title, 'FORD3') validation_message = self.driver.find_elements_by_name( 'campus-dates-date_end')[1].get_attribute('validationMessage') self.assertEqual(validation_message, 'Please fill out this field.')