Best Python code snippet using mailosaur-python_python
test_views.py
Source:test_views.py
...26 def test_get(self):27 url = reverse('reader:series', kwargs={'slug': 'series'})28 r = self.client.get(url)29 assert r.status_code == 20030 def test_get_not_found(self):31 url = reverse('reader:series', kwargs={'slug': 'not-found'})32 r = self.client.get(url)33 assert r.status_code == 40434 def test_get_unavailable(self):35 self.series.chapters.all().delete()36 self.client.logout()37 url = reverse('reader:series', kwargs={'slug': 'series'})38 r = self.client.get(url)39 assert r.status_code == 40340class TestChapterPage(ReaderViewTestBase):41 _values = [('series', 0), ('series', 3), ('series2', 1)]42 def test_get(self):43 url = reverse('reader:page', kwargs={44 'slug': 'series', 'vol': 0, 'num': 1, 'page': 145 })46 r = self.client.get(url)47 assert r.status_code == 20048 @mark.parametrize('values', _values)49 def test_get_not_found(self, values):50 url = reverse('reader:page', kwargs={51 'slug': values[0], 'vol': 1, 'num': 1, 'page': values[1]52 })53 r = self.client.get(url)54 assert r.status_code == 40455class TestChapterRedirect(ReaderViewTestBase):56 def test_get(self):57 url = reverse('reader:chapter', kwargs={58 'slug': 'series', 'vol': 0, 'num': 159 })60 page_url = reverse('reader:page', kwargs={61 'slug': 'series', 'vol': 0, 'num': 1, 'page': 162 })63 r1 = self.client.get(url, follow=True)64 assert r1.status_code == 20065 r2 = self.client.get(page_url)66 assert r2.status_code == 20067 assert str(r1.content) == str(r2.content)68class TestChapterDownload(ReaderViewTestBase):69 def test_get(self):70 url = reverse('reader:cbz', kwargs={71 'slug': 'series', 'vol': 0, 'num': 172 })73 self.client.force_login(self.user)74 r = self.client.get(url)75 assert r.status_code == 20076 assert isinstance(r, FileResponse)77 assert r.filename.endswith('c1.cbz')78 def test_get_not_found(self):79 self.series.chapters.all().delete()80 url = reverse('reader:cbz', kwargs={81 'slug': 'series', 'vol': 0, 'num': 182 })83 self.client.force_login(self.user)84 r = self.client.get(url)85 assert r.status_code == 40486 def test_get_unauthorized(self):87 url = reverse('reader:cbz', kwargs={88 'slug': 'series', 'vol': 0, 'num': 189 })90 self.client.logout()91 r = self.client.get(url)92 assert r.status_code == 401
test_functional.py
Source:test_functional.py
...11 assert response.headers['Location'] == (12 'https://pecan.readthedocs.io/en/latest/search.html'13 '?q=RestController'14 )15 def test_get_not_found(self):16 response = self.app.get('/a/bogus/url', expect_errors=True)...
test_response.py
Source:test_response.py
...10 self.dict = {self.key: self.value}11 def test_get_found(self):12 value = response.get(self.key, self.dict)13 self.assertEqual(value, self.value)14 def test_get_not_found(self):15 value = response.get(self.key_not_found, self.dict, default=self.default_not_found)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!