def test_get_ip_valid_request(self): resp = self.client.post( reverse('imageboard_thread_create', kwargs={'board': self.board.slug}), { 'post': faker.text(), 'name': faker.name() }) self.request = resp.wsgi_request #get_remote_address only gets the ip through a self.request object so one must be provided remote_address = self.get_remote_address() self.assertEqual(remote_address, '127.0.0.1')
def test_get_ip_no_valid_request(self): resp = self.client.post( reverse('imageboard_thread_create', kwargs={'board': self.board.slug}), { 'post': faker.text(), 'name': faker.name() }) remote_address = self.get_remote_address() self.assertEqual( remote_address, None) #Test that None is returned if no request object provided
def setUp(self): self.thread = ThreadFactory() self.ip_address = '127.0.0.1' self.url = reverse('api_post-list') get_captcha_resp = self.client.get(reverse('rest_validator_view')) self.key = get_captcha_resp.data['captcha_key'] self.captcha_value = CaptchaStore.objects.get(hashkey=self.key).challenge validate_resp = self.client.post(reverse('rest_validator_view'), {'captcha_key': self.key, 'captcha_value': self.captcha_value}) self.data = { 'name': faker.name(), 'post': faker.text(), 'thread': reverse('api_thread-detail', kwargs={'thread_number': self.thread.thread_number}), 'captcha_key': self.key, }
def setUp(self): self.board = BoardFactory() self.ip_address = '127.0.0.1' self.url = reverse('api_thread-list') get_captcha_resp = self.client.get(reverse('rest_validator_view')) self.key = get_captcha_resp.data['captcha_key'] self.captcha_value = CaptchaStore.objects.get(hashkey=self.key).challenge validate_resp = self.client.post(reverse('rest_validator_view'), {'captcha_key': self.key, 'captcha_value': self.captcha_value}) self.data = { 'subject': faker.name(), 'name': faker.name(), 'post': faker.text(), 'image': ImageFactory(), 'board': reverse('api_board-detail', kwargs={'slug': self.board.slug}), 'captcha_key': self.key, }
def test_thread_archived_threads_no_posting(self): resp = self.client.post(self.thread.get_post_create_url(), {'post': faker.text()}) self.assertTrue(resp.status_code, 405)
def test_thread_archived_no_posting( self): #Test that posting doesnt work when thread archived resp = self.client.post(self.thread.get_post_create_url(), {'post': faker.text()}) self.assertTrue(resp.status_code, 405)