How to use get_check_200 method in Django Test Plus

Best Python code snippet using django-test-plus_python

tests.py

Source:tests.py Github

copy

Full Screen

...57 # given58 # user = self.make_user(username='test', password='1234567!')59 # when60 with self.login(username='test', password='1234567!'):61 response = self.get_check_200('boards:create')62 # self.assertContains(response, '<form')63 # then64 self.assertIsInstance(response.context['form'], BoardForm)65 66 def test_02_get_create_login_required(self):67 self.assertLoginRequired('boards:create')68 69 def test_03_post_create(self):70 # given | 사용자와 작성한 글 데이터71 # when | 로그인을 해서 post 요청으로 해당 url에 보낸 경우72 # then | 글이 작성되고, detail로 redirect(302)73 74 # given75 # user = self.make_user(username='test', password='1234567!')76 data = {77 'title' : 'test title',78 'content' : 'test content'79 }80 81 # when82 with self.login(username='test', password='1234567!'):83 # then84 self.post('boards:create', data=data)85 self.response_302()86 # self.assertEqual(response.status_code, 302)87 88 def test_04_board_create_without_content(self):89 90 # given91 data = {92 'title' : 'test_title',93 }94 95 # when96 with self.login(username='test', password='1234567!'):97 response = self.post('boards:create', data=data)98 self.assertContains(response, '')99 100 # 디테일 페이지가 제대로 출력되는지 확인101 def test_05_detail_contains(self):102 # given103 board = Board.objects.create(title='제목', content='내용', user=self.user)104 # when105 self.get_check_200('boards:detail', board_pk=board.pk)106 107 # then108 self.assertResponseContains(board.title, html=False)109 self.assertResponseContains(board.content, html=False)110 111 def test_06_detail_templates(self):112 # given113 board = Board.objects.create(title='제목', content='내용', user=self.user)114 115 # when116 response = self.get_check_200('boards:detail', board_pk=board.pk)117 118 # then119 self.assertTemplateUsed(response, 'boards/detail.html')120 121 def test_07_get_index(self):122 # given when then123 self.get_check_200('boards:index')124 125 def test_08_index_template(self):126 response = self.get_check_200('boards:index')127 self.assertTemplateUsed(response, 'boards/index.html')128 129 def test_09_index_queryset(self):130 # given | 글 두개 작성131 Board.objects.create(title='제목', content='내용', user=self.user)132 Board.objects.create(title='제목', content='내용', user=self.user)133 boards = Board.objects.order_by('-pk')134 135 # when136 response = self.get_check_200('boards:index')137 138 # then139 self.assertQuerysetEqual(response.context['boards'], map(repr, boards))140 141 def test_10_delete(self):142 board = Board.objects.create(title='제목', content='내용', user=self.user)143 with self.login(username='test', password='1234567!'):144 self.get_check_200('boards:delete', board_pk=board.pk)145 146 def test_11_delete_post(self):147 board = Board.objects.create(title='제목', content='내용', user=self.user)148 with self.login(username='test', password='1234567!'):149 self.post('boards:delete', board_pk=board.pk)150 self.assertEqual(Board.objects.count(), 0)151 152 def test_12_delete_redirect(self):153 board = Board.objects.create(title='제목', content='내용', user=self.user)154 with self.login(username='test', password='1234567!'):155 response = self.post('boards:delete', board_pk=board.pk)156 self.assertRedirects(response, reverse('boards:index'))157 158 def test_13_get_update(self):159 board = Board.objects.create(title='제목', content='내용', user=self.user)160 with self.login(username='test', password='1234567!'):161 response = self.get_check_200('boards:update', board.pk)162 self.assertEqual(response.context['form'].instance.pk, board.pk)163 self.post('boards:update', board_pk=board.pk)164 165 def test_14_get_update_login_required(self):...

Full Screen

Full Screen

test_oauth_routes.py

Source:test_oauth_routes.py Github

copy

Full Screen

...18 )19 self.assertLoginRequired("oauth2_provider:list")20 self.assertLoginRequired("oauth2_provider:detail", pk=app.pk)21 with self.login(basic_user):22 self.get_check_200("oauth2_provider:list")23 self.assertResponseContains("Test333", html=False)24 self.get_check_200("oauth2_provider:detail", pk=app.pk)25 self.assertResponseContains("Test333", html=False)26 def test_application_creation_workflow(self):27 basic_user = self.make_user("basic_user@test.com")28 self.assertLoginRequired("oauth2_provider:register")29 with self.login(basic_user):30 self.get_check_200("oauth2_provider:register")31 form_data = {32 "name": "Test888",33 "client_id": "client_id",34 "client_secret": "client_secret",35 "client_type": OAuth_App.CLIENT_PUBLIC,36 "redirect_uris": "http://example.com",37 "authorization_grant_type": OAuth_App.GRANT_PASSWORD38 }39 self.post("oauth2_provider:register", data=form_data)40 self.response_302()41 self.assertTrue(OAuth_App.objects.filter(name="Test888").exists())42 self.get_check_200("oauth2_provider:list")43 self.assertResponseContains("Test888", html=False)44 app_pk = OAuth_App.objects.get(name="Test888").pk45 self.get_check_200("oauth2_provider:detail", pk=app_pk)46 def test_application_update_workflow(self):47 basic_user = self.make_user("basic_user@test.com")48 app = OAuth_App.objects.create(49 user=basic_user,50 name="Test111",51 client_type=OAuth_App.CLIENT_PUBLIC,52 authorization_grant_type=OAuth_App.GRANT_PASSWORD,53 redirect_uris="http://example.com",54 )55 self.assertLoginRequired("oauth2_provider:update", pk=app.pk)56 with self.login(basic_user):57 self.get_check_200("oauth2_provider:detail", pk=app.pk)58 self.assertResponseContains("Test111", html=False)59 self.get_check_200("oauth2_provider:update", pk=app.pk)60 form_data = {61 "user": basic_user.pk,62 "name": "Test222",63 "client_id": "client_id",64 "client_secret": "client_secret",65 "client_type": OAuth_App.CLIENT_PUBLIC,66 "redirect_uris": "http://example.com",67 "authorization_grant_type": OAuth_App.GRANT_PASSWORD68 }69 self.post("oauth2_provider:update", pk=app.pk, data=form_data)70 self.response_302()71 self.assertFalse(OAuth_App.objects.filter(name="Test111").exists())72 self.assertTrue(OAuth_App.objects.filter(name="Test222").exists())73 self.get_check_200("oauth2_provider:detail", pk=app.pk)74 self.assertResponseContains("Test222", html=False)75 self.assertResponseNotContains("Test111", html=False)76 def test_application_deletion(self):77 basic_user = self.make_user("basic_user@test.com")78 app = OAuth_App.objects.create(79 user=basic_user,80 name="Test555",81 client_type=OAuth_App.CLIENT_PUBLIC,82 authorization_grant_type=OAuth_App.GRANT_PASSWORD,83 redirect_uris="http://example.com",84 )85 self.assertLoginRequired("oauth2_provider:delete", pk=app.pk)86 with self.login(basic_user):87 self.get_check_200("oauth2_provider:detail", pk=app.pk)88 self.assertResponseContains("Test555", html=False)89 self.get_check_200("oauth2_provider:delete", pk=app.pk)90 self.post("oauth2_provider:delete", pk=app.pk)91 self.response_302()92 self.assertFalse(OAuth_App.objects.filter(pk=app.pk).exists())...

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