def test_delete(self): self.client.post('/accounts/login/', { 'username': '******', 'password': '******' }, follow=True) response = self.client.get('/submissions/', follow=True) # print(response.content) TC.assertContains(self, response=response, text='Story-Three') response = self.client.post('/submissions/delete/3/', follow=True) TC.assertNotContains(self, response=response, text='Story-Three')
def test_search(self): response = self.client.post('/accounts/login/', { 'username': '******', 'password': '******' }, follow=True) TC.assertContains(self, response=response, text='Story-One') response = self.client.post('/submissions/search/', { 'publisher_id': 2, 'disposition_id': 2 }, follow=True) TC.assertContains(self, response=response, text='Story-Two') TC.assertNotContains(self, response=response, text='Story-One')
def test_catch_unauth_add(self): self.client.post('/accounts/login/', { 'username': '******', 'password': '******' }, follow=True) response = self.client.get('/submissions/user/add/', follow=True) TC.assertContains(self, response=response, text='Add New User') self.client.logout() self.client.post('/accounts/login/', { 'username': '******', 'password': '******' }, follow=True) response = self.client.get('/submissions/user/add/', follow=True) TC.assertNotContains(self, response=response, text="Add New User") TC.assertContains(self, response=response, text='Only a superuser can add')
def test_catch_unauth_edit(self): self.client.post('/accounts/login/', { 'username': '******', 'password': '******' }, follow=True) response = self.client.get('/submissions/user/2', follow=True) TC.assertContains(self, response=response, text='Update User Information') self.client.logout() self.client.post('/accounts/login/', { 'username': '******', 'password': '******' }, follow=True) response = self.client.get('/submissions/user/1', follow=True) TC.assertNotContains(self, response=response, text="Update User Information") TC.assertContains(self, response=response, text='Only a superuser can update')
def test_create_submission(self): # Must be logged in. 'get' brings up entry page. 'post', submits data and brings up submissions page self.client.post('/accounts/login/', { 'username': '******', 'password': '******' }, follow=True) response = self.client.get('/submissions/add/', follow=True) TC.assertContains(self, response=response, text='Add New submission') response = self.client.post('/submissions/add/', { "pk": 4, "story": "Story-Four", "word_count": 4000, "file": "story-four.01.docx", "date_submitted": "1999-06-29", "disposition_date": "1999-06-29", "publisher": 3, "disposition": 3, "user": 2 }, follow=True) # print(response.content) TC.assertContains(self, response=response, text='Story-Four') TC.assertNotContains(self, response=response, text='Story-One')
def test_available_publishers(self): # Test initial view response = self.client.get( '/submissions/publishers/?wp_file=story-one.01.docx', follow=True) TC.assertNotContains(self, response=response, text='Analog') # Test with update from initial view # response = self.client.get('/submissions/publisher/2/?wp_file=story-one.01.docx', follow = True) response = self.client.post( '/submissions/publisher/2/?wp_file=story-one.01.docx', { "publisher": "F&SF", "web_address": "https://www.sfsite.com/fsf/glines.htm", "min_words": 1000, "max_words": 25000, "remarks": "F&SF has no formula for fiction. The speculative element may be slight, but it should be present." }, follow=True) TC.assertNotContains(self, response=response, text='Analog')