def test_add_section(self): """ View: add_section """ from models import Journal from models import Section journal = Journal.objects.all()[0] #empty form response = self.client.get(reverse('section.add', args=[journal.pk])) self.assertEqual(response.status_code, 200) #add section response = self.client.post(reverse('section.add', args=[journal.pk]), tests_assets.get_sample_section_dataform()) self.assertRedirects(response, reverse('section.index', args=[journal.pk])) #edit section testing_section = Section.objects.get(title='Artigo Original') previous_code = testing_section.code response = self.client.post(reverse('section.edit', args=[journal.pk, testing_section.pk]), tests_assets.get_sample_section_dataform(title='Modified Original Article', code='qwerty')) self.assertRedirects(response, reverse('section.index', args=[journal.pk])) modified_section = Section.objects.get(title='Modified Original Article') self.assertEqual(testing_section, modified_section) self.assertEqual(modified_section.code, previous_code) #code must be read-only
def test_add_section(self): """ View: add_section """ from models import Journal from models import Section journal = Journal.objects.all()[0] sample_language = tests_assets.get_sample_language() sample_language.save() journal.languages.add(sample_language) #empty form response = self.client.get(reverse('section.add', args=[journal.pk])) self.assertEqual(response.status_code, 200) #add section response = self.client.post(reverse('section.add', args=[journal.pk]), tests_assets.get_sample_section_dataform(**{ 'journal': journal.pk, 'titles-0-language': sample_language.pk, })) self.assertRedirects(response, reverse('section.index', args=[journal.pk])) #edit section testing_section = Section.objects.get(sectiontitle__title='TITLES FORMSET TEST') previous_code = testing_section.code response = self.client.post(reverse('section.edit', args=[journal.pk, testing_section.pk]), tests_assets.get_sample_section_dataform(**{ 'titles-0-title':'Modified Original Article', 'titles-0-language': sample_language.pk, 'code': 'qwerty'})) self.assertRedirects(response, reverse('section.index', args=[journal.pk])) modified_section = Section.objects.get(sectiontitle__title='Modified Original Article') self.assertEqual(testing_section, modified_section) self.assertEqual(modified_section.code, previous_code) #code must be read-only
def test_add_section(self): """ View: add_section """ from models import Journal from models import Section journal = Journal.objects.all()[0] #empty form response = self.client.get(reverse('section.add', args=[journal.pk])) self.assertEqual(response.status_code, 200) #add section response = self.client.post(reverse('section.add', args=[journal.pk]), tests_assets.get_sample_section_dataform()) self.assertRedirects(response, reverse('section.index', args=[journal.pk])) #edit section testing_section = Section.objects.get(title='Artigo Original') previous_code = testing_section.code response = self.client.post( reverse('section.edit', args=[journal.pk, testing_section.pk]), tests_assets.get_sample_section_dataform( title='Modified Original Article', code='qwerty')) self.assertRedirects(response, reverse('section.index', args=[journal.pk])) modified_section = Section.objects.get( title='Modified Original Article') self.assertEqual(testing_section, modified_section) self.assertEqual(modified_section.code, previous_code) #code must be read-only