How to use test_get_check_200 method in Django Test Plus

Best Python code snippet using django-test-plus_python

test_unittests.py

Source:test_unittests.py Github

copy

Full Screen

...198 # with response199 self._test_http_response(method, res, url=res_url)200 # without response201 self._test_http_response(method, url=res_url)202 def test_get_check_200(self):203 res = self.get_check_200('view-200')204 self.assertTrue(res.status_code, 200)205 def test_response_200(self):206 res = self.get('view-200')207 self.response_200(res)208 # Test without response option209 self.response_200()210 def test_response_201(self):211 res = self.get('view-201')212 self.response_201(res)213 # Test without response option214 self.response_201()215 def test_response_204(self):216 res = self.get('view-204')217 self.response_204(res)218 # Test without response option219 self.response_204()220 def test_response_301(self):221 res = self.get('view-301')222 self.response_301(res)223 # Test without response option224 self.response_301()225 def test_response_302(self):226 res = self.get('view-302')227 self.response_302(res)228 # Test without response option229 self.response_302()230 def test_response_400(self):231 res = self.get('view-400')232 self.response_400(res)233 # Test without response option234 self.response_400()235 def test_response_401(self):236 res = self.get('view-401')237 self.response_401(res)238 # Test without response option239 self.response_401()240 def test_response_403(self):241 res = self.get('view-403')242 self.response_403(res)243 # Test without response option244 self.response_403()245 def test_response_404(self):246 res = self.get('view-404')247 self.response_404(res)248 # Test without response option249 self.response_404()250 def test_response_405(self):251 res = self.get('view-405')252 self.response_405(res)253 # Test without response option254 self.response_405()255 def test_response_409(self):256 res = self.get('view-409')257 self.response_409(res)258 # Test without response option259 self.response_409()260 def test_response_410(self):261 res = self.get('view-410')262 self.response_410(res)263 # Test without response option264 self.response_410()265 def test_make_user(self):266 """ Test make_user using django.contrib.auth defaults """267 u1 = self.make_user('u1')268 self.assertEqual(u1.username, 'u1')269 def test_make_user_with_perms(self):270 u1 = self.make_user('u1', perms=['auth.*'])271 if django.VERSION < (2, 1):272 expected_perms = [u'add_group', u'change_group', u'delete_group',273 u'add_permission', u'change_permission', u'delete_permission',274 u'add_user', u'change_user', u'delete_user']275 else:276 expected_perms = [u'add_group', u'change_group', u'delete_group', u'view_group',277 u'add_permission', u'change_permission', u'delete_permission',278 u'view_permission', u'add_user', u'change_user', u'delete_user',279 u'view_user']280 self.assertEqual(list(u1.user_permissions.values_list('codename', flat=True)), expected_perms)281 u2 = self.make_user('u2', perms=['auth.add_group'])282 self.assertEqual(list(u2.user_permissions.values_list('codename', flat=True)), [u'add_group'])283 def test_login_required(self):284 self.assertLoginRequired('view-needs-login')285 # Make a user and login with our login context286 self.make_user('test')287 with self.login(username='test', password='password'):288 self.get_check_200('view-needs-login')289 def test_login_other_password(self):290 # Make a user with a different password291 user = self.make_user('test', password='revsys')292 with self.login(user, password='revsys'):293 self.get_check_200('view-needs-login')294 def test_login_no_password(self):295 user = self.make_user('test')296 with self.login(username=user.username):297 self.get_check_200('view-needs-login')298 def test_login_user_object(self):299 user = self.make_user('test')300 with self.login(user):301 self.get_check_200('view-needs-login')302 def test_reverse(self):303 self.assertEqual(self.reverse('view-200'), '/view/200/')304 def test_assertgoodview(self):305 self.assertGoodView('view-200')306 def test_assertnumqueries(self):307 with self.assertNumQueriesLessThan(1):308 self.get('view-needs-login')309 def test_assertnumqueries_data_1(self):310 with self.assertNumQueriesLessThan(2):311 self.get('view-data-1')312 def test_assertnumqueries_data_5(self):313 with self.assertNumQueriesLessThan(6):314 self.get('view-data-5')315 def test_invalid_request_method(self):316 with self.assertRaises(LookupError):317 self.request('foobar', 'some-url')318 @unittest.expectedFailure319 def test_assertnumqueries_failure(self):320 with self.assertNumQueriesLessThan(1):321 self.get('view-data-5')322 def test_assertincontext(self):323 response = self.get('view-context-with')324 self.assertTrue('testvalue' in response.context)325 self.assertInContext('testvalue')326 self.assertTrue(self.context['testvalue'], response.context['testvalue'])327 def test_get_context(self):328 response = self.get('view-context-with')329 self.assertTrue('testvalue' in response.context)330 value = self.get_context('testvalue')331 self.assertEqual(value, True)332 def test_assert_context(self):333 response = self.get('view-context-with')334 self.assertTrue('testvalue' in response.context)335 self.assertContext('testvalue', True)336 @unittest.expectedFailure337 def test_assertnotincontext(self):338 self.get('view-context-without')339 self.assertInContext('testvalue')340 def test_no_response(self):341 with self.assertRaises(NoPreviousResponse):342 self.assertInContext('testvalue')343 def test_no_response_context(self):344 with self.assertRaises(NoPreviousResponse):345 self.assertContext('testvalue', False)346 def test_get_context_raises(self):347 with self.assertRaises(NoPreviousResponse):348 self.get_context('testvalue')349 def test_get_is_ajax(self):350 response = self.get('view-is-ajax',351 extra={'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'})352 self.response_200(response)353 def test_post_is_ajax(self):354 response = self.post('view-is-ajax',355 data={'item': 1},356 extra={'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest'})357 self.response_200(response)358 def test_assertresponsecontains(self):359 self.get('view-contains')360 self.assertResponseContains('<p>Hello world</p>')361 self.assertResponseNotContains('<p>Hello Frank</p>')362 def test_assert_response_headers(self):363 self.get('view-headers')364 self.assertResponseHeaders({'Content-Type': 'text/plain'})365 self.assertResponseHeaders({'X-Custom': '1'})366 self.assertResponseHeaders({'X-Custom': '1', 'X-Non-Existent': None})367 self.assertResponseHeaders({'X-Non-Existent': None})368class TestPlusCBViewTests(CBVTestCase):369 def test_get(self):370 self.get(CBView)371 self.response_200()372 def test_post(self):373 data = {'testing': True}374 self.post(CBView, data=data)375 self.response_200()376 # Test without data377 self.post(CBView)378 self.response_200()379 def test_get_check_200(self):380 self.get_check_200('cbview')381 def test_assert_good_view(self):382 self.assertGoodView('cbview')383 def test_login_required(self):384 self.assertLoginRequired('cbview-needs-login')385 # Make a user and login with our login context386 self.make_user('test')387 with self.login(username='test', password='password'):388 self.get_check_200('cbview-needs-login')389class TestPlusCBDataViewTests(CBVTestCase):390 """391 Provide usage examples for CBVTestCase392 """393 def setUp(self):...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Django Test Plus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful