Exemple #1
0
    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')
Exemple #2
0
    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')
Exemple #3
0
    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')
Exemple #4
0
    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)
Exemple #5
0
    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]
                      )
Exemple #6
0
 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)
Exemple #7
0
 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)
Exemple #8
0
 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)
Exemple #10
0
	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)
Exemple #11
0
 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>'))
Exemple #13
0
	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)
Exemple #14
0
	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)				
Exemple #15
0
    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())
Exemple #16
0
    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/')
Exemple #17
0
    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())
Exemple #18
0
	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)
Exemple #19
0
    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
Exemple #20
0
	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>'))
Exemple #21
0
	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>'))
		
Exemple #22
0
	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())
Exemple #23
0
 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>'))
Exemple #24
0
	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'}
						)
Exemple #25
0
    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)
Exemple #26
0
    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)
Exemple #28
0
	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)
Exemple #29
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'],'/')
Exemple #30
0
 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())
Exemple #32
0
 def testWhenOpenHomepageThenShowRightHtml(self):
     request = HttpRequest()
     response = home_page(request)
     self.assertEqual(render_to_string('home.html'),
                      response.content.decode())
Exemple #33
0
 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>'))
Exemple #34
0
 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>')
Exemple #35
0
 def test_홈페이지는_필요할때만_아이템을_저장해야한다(self): #home_page_only_saves_items_when_necessary(self):
     request = HttpRequest()
     home_page(request)
     self.assertEquals(Item.objects.count(), 0)
Exemple #36
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)
Exemple #37
0
 def test_home_page_returns_correct_html(self):
     request = HttpRequest()
     response = home_page(request)
Exemple #38
0
 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())
Exemple #40
0
	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)
Exemple #41
0
 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)
Exemple #42
0
 def test_home_page_only_saves_items_when_necessary(self):
     request = HttpRequest()
     home_page(request)
     self.assertEqual(Item.objects.count(), 0)
Exemple #43
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))
Exemple #44
0
 def test_home_page_returns_correct_html(self):
     request = HttpRequest()
     response = home_page(request)
     expected_html = render_to_string('home.html',
                                      {'new_item_text': '신규 작업 아이템'})
Exemple #45
0
 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)
Exemple #46
0
 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)
Exemple #47
0
 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)
Exemple #49
0
 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)
Exemple #50
0
 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)
Exemple #51
0
	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>'))
Exemple #52
0
    def test_no_post(self):
        request = HttpRequest()
        response = home_page(request)

        self.assertEqual(Item.objects.count(), 0)
Exemple #53
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)
Exemple #54
0
 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>"))
Exemple #55
0
 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)
Exemple #56
0
    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
Exemple #57
0
    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)
Exemple #58
0
 def test_auto_comment(self):
     items = Item.objects.count()
     request = HttpRequest()
     response = home_page(request)
Exemple #59
0
 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'))