def test_scan_result_view_anonymous_user_post_request(self):
request = RequestFactory().post('/urlscan/', {'url': 'https://github.com/'})
request.user = AnonymousUser()
response = UrlScanView.as_view()(request)
url = response.url
digits_in_url = url[12:]
scan_id = ''
for character in digits_in_url:
try:
scan_id = scan_id + str(int(character))
except:
pass
scan_id = int(scan_id)
request = RequestFactory().post('/scanresult/', {'post_apple': 'Apple'})
response = ScanResults.as_view()(request, pk=scan_id)
self.assertEqual(405, response.status_code)
评论列表
文章目录