def test_home_page_can_save_POST_request(self): request = self.create_item_post_request('New Item') home_page(request) items = Item.objects.all() self.assertEqual(items.count(), 1) self.assertEqual(items[0].text, 'New Item')
def test_home_page_can_save_a_post_request(self): self.request.method = 'POST' self.request.POST["item_text"] = 'A new list item' home_page(self.request) self.assertEqual(Item.objects.count(), 1) newItem = Item.objects.first() self.assertEqual(newItem.text, 'A new list item')
def test_home_page_can_save_a_POST_request(self): request = HttpRequest() request.method = 'POST' request.POST['item_text'] = 'A new list item' home_page(request) self.assertEqual(Item.objects.count(), 1) new_item = Item.objects.first() self.assertEqual(new_item.text, 'A new list item')
def test_home_page_can_save_a_POST_request(self): request = HttpRequest() request.method = "POST" item_text = "A new list item" request.POST["item_text"] = item_text home_page(request) self.assertEqual(Item.objects.count(), 1) new_item = Item.objects.first() self.assertEqual(new_item.text, item_text)
def test_home_page_can_save_a_POST_request(self): request = HttpRequest() request.method = 'POST' request.POST['item_text'] = "A new list item" home_page(request) items_list = Item.objects.all() self.assertEqual(items_list.count(), 1) self.assertIn(request.POST['item_text'], [item.text for item in items_list] )
def test_home_page_uses_home_template(self): request = HttpRequest() response = home_page(request) csrf_regex = r'<input[^>]+csrfmiddlewaretoken[^>]+>' observed_content = re.sub(csrf_regex,'',response.content.decode('utf8')) expected_content = render_to_string('home.html') self.assertEqual(observed_content, expected_content)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html') # note: conent is in raw bytes # use decode() to convert bytes into python self.assertEqual(response.content.decode(), expected_html)
def test_home_page_displays_all_list_items(self): Item.objects.create(text='itemey 1') Item.objects.create(text='itemey 2') request = HttpRequest() response = home_page(request) self.assertIn('itemey 1',response.content.decode()) self.assertIn('itemey 2',response.content.decode())
def test_home_page_renders_home_template(self): request = HttpRequest() response = home_page(request) #Verify extra characters that might come along #print(repr(response.content)) expected_html = render_to_string('home.html', {'form': ItemForm()}) self.assertMultiLineEqual(response.content.decode(), expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) # view 함수(home_page)에서 리턴된 결과와 html 결과가 같은 지 테스트 expected_html = render_to_string('home.html') self.assertEqual(response.content.decode(), expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html') #print("expected_html:",len(expected_html)) #print("response: ", type(response)) self.assertEqual(response.content.decode(), expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html') self.assertTrue(response.content.strip().startswith(b'<html>')) self.assertEqual(response.content.decode(), expected_html) self.assertTrue(response.content.strip().endswith(b'</html>'))
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html', { 'comment': 'Yey, waktunya berlibur' } ) self.assertEqual(response.content.decode(), expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) c = {} c.update(csrf(request)) expected_html = render_to_string('home.html',c) self.assertEqual(response.content.decode(),expected_html)
def test_comment_partial(self): _list = List.objects.create() Item.objects.create(text="test 1", list=_list) request = HttpRequest() response = home_page(request) self.assertIn("sibuk tapi santai", response.content.decode())
def test_home_page_should_redirect_after_POST(self): request = self.create_item_post_request('New Item') response = home_page(request) self.assertEqual(response.status_code, 302) self.assertEqual(response['location'], '/lists/the-only-list-in-the-world/')
def test_home_page_returns_correct_html(self): request = HttpRequest() # Creating a HttpRequest object response = home_page(request) # Pass the request to home_page view and get a response self.assertIn('A new list item', response.content.decode())
def test_home_page_returns_correct_html(self): #this is what Django will see when a user's browser asks for a page request = HttpRequest() #pass this request to our home_page view response = home_page(request) expected_html = render_to_string('home.html') self.assertEqual(response.content.decode(), expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() # given response = home_page(request) # when expected_html = render_to_string('home.html') self.assertEqual(response.content.decode(), expected_html) # then
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html') self.assertEqual(response.content.decode(), expected_html) self.assertIn(b'<title>To-Do lists</title>', response.content) self.assertTrue(response.content.endswith(b'</html>'))
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) self.assertTrue(response.content.startswith(b'<html>')) self.assertIn(b'<title>To-Do lists</title>', response.content) self.assertTrue(response.content.endswith(b'</html>'))
def test_home_page_can_save_a_POST_request(self): request = HttpRequest() request.method = 'POST' request.POST['item_text'] = 'Nuevo Alumno' response = home_page(request) self.assertIn('Nuevo Alumno', response.content.decode())
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) html = response.content.decode('utf8') self.assertTrue(html.startswith('<html>')) self.assertIn('<title>To-Do lists</title>', html) self.assertTrue(html.endswith('</html>'))
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string( 'home.html', {'new_item_text': 'A new list item'} )
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html') self.assertTrue(response.content.decode(), expected_html)
def test_returns_correct_html(self): request = HttpRequest() response = home_page(request) # Смотрим что нам пришла html-страница с нужным содержимым. expected_html = render_to_string('lists/home.html') self.assertEqual(response.content.decode(), expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html', { 'new_item_text': '' }) self.assertEqual(response.content.decode(), expected_html)
def test_home_page_only_saves_items_when_necessary(self): new_list_item_text = 'A new list item' (request, rc) = self.setup_request(new_list_item_text, '') response = home_page(request) self.assertEqual(Item.objects.count(), 0)
def test_home_page_redirects_after_POST(self): request = HttpRequest() request.method = 'POST' request.POST['item_text'] = 'A new list item' response = home_page(request) self.assertEqual(response.status_code,302) self.assertEqual(response['location'],'/')
def test_home_page_returns_correct_html(self): # This calls the home_page function, passing a request # then checks the returned response for the correct info. request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html') self.assertEqual(response.content.decode(), expected_html)
def test_home_page_is_about_to_do_lists(self): request = HttpRequest() response = home_page(request) self.assertIn("to-do item", response.content.decode())
def testWhenOpenHomepageThenShowRightHtml(self): request = HttpRequest() response = home_page(request) self.assertEqual(render_to_string('home.html'), response.content.decode())
def test_home_page_returns_correct_html(self): request = HttpRequest() # response = home_page(request) # self.assertTrue(response.content.startswith(b'<html>')) # self.assertIn(b'<h1>Yogi Perdana</h1>', response.content) self.assertTrue(response.content.endswith(b'</html>'))
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) assert response.content.startswith(b'<html>') assert b'<title>To-Do lists</title>' in response.content assert response.content.endswith(b'</html>')
def test_홈페이지는_필요할때만_아이템을_저장해야한다(self): #home_page_only_saves_items_when_necessary(self): request = HttpRequest() home_page(request) self.assertEquals(Item.objects.count(), 0)
def test_home_page_returns_correct_html(self): request = HttpRequest( ) # create an HttpRequest object, which is what Django will see when a user’s browser asks for a page. response = home_page(request) expected_html = render_to_string('home.html') self.assertEqual(response.content.decode(), expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request)
def test_home_returns_correct_html(self): request = HttpRequest() response = home_page(request) html = response.content.decode('utf8') self.assertTrue(html.startswith('<html>')) self.assertIn('<title>To-Do lists</title>', html)
def test_home_page_can_save_a_POST_request(self): request = HttpRequest() request.method = 'POST' request.POST['item_text'] = 'A new list item' response = home_page(request) self.assertIn('A new list item', response.content.decode())
def test_home_page_returns_right_html(self): new_list_item_text = 'A new list item' (request, rc) = self.setup_request(new_list_item_text, 'POST') response = home_page(request)
def test_home_page_html_return_text_muhammad_feril_bagus_p(self): request = HttpRequest() response = home_page(request) html = response.content.decode('utf8') self.assertIn('<p class="text_full_name">muhammad feril bagus p</p>', html)
def test_home_page_only_saves_items_when_necessary(self): request = HttpRequest() home_page(request) self.assertEqual(Item.objects.count(), 0)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string("home.html", request=request) self.assertEqual(self.remove_csrf(response.content.decode()), self.remove_csrf(expected_html))
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html', {'new_item_text': '신규 작업 아이템'})
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html', {'form': ItemForm()}, request=request) self.assertMultiLineEqual(response.content.decode(), expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html', {'comment': 'yey, waktunya berlibur'}) self.assertEqual(response.content.decode(), expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html')
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) self.assertNotIn('A new list item', response.content)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html') self.assertEqual(response.content.decode(), expected_html)
def _home_page_returns_correct_html_via_render_to_string(self): request = HttpRequest() response = home_page(request) html = response.content.decode('utf8') expected_html = render_to_string('home.html') self.assertEqual(html, expected_html)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) self.assertTrue(response.content.startswith(b'<html>')) self.assertIn(b'<title>To-Do lists</title>', response.content) self.assertTrue(response.content.strip().endswith(b'</html>'))
def test_no_post(self): request = HttpRequest() response = home_page(request) self.assertEqual(Item.objects.count(), 0)
def test_root_url_resolves_to_home_page_view(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html') print(repr(expected_html)) self.assertEqual(response.content.decode(), expected_html)
def test_home_page_with_response(self): req = HttpRequest() res = home_page(req) html_page = res.content.decode('utf8') self.assertTrue(html_page.startswith("<html>"))
def test_foo_in_body(self): request = HttpRequest() response = home_page(request) html = response.content.decode('utf8') self.assertIn('<body><p>foo</p></body>', html)
def test_home_page_returns_correct_html(self): request = HttpRequest() # print(request) #scheme :http or https, # POST:QueryDict:{},path:,method,resolver_match,''' get_host()''' response = home_page(request) # home_page view returns HttpResponse
def test_home_page(self): request = HttpRequest() response = home_page(request) self.assertTrue(response.content.startswith(b'<!doctype html>')) self.assertIn(b'<title>To-Do Lists</title>', response.content)
def test_auto_comment(self): items = Item.objects.count() request = HttpRequest() response = home_page(request)
def test_home_page_returns_correct_html(self): request = HttpRequest() response = home_page(request) expected_html = render_to_string('home.html', {'new_item_text': 'A new list item'}) self.assertTrue(1)
def test_home_page_can_store_post_requests(self): request = HttpRequest() request.method = 'POST' request.POST['item_text'] = 'new item' response = home_page(request) self.assertIn('<td>new item</td>', response.content.decode('utf8'))