def test_index_returns_correct_html(self): request = HttpRequest() response = index(request) expected_html = render_to_string('index.html') # ## 더 높은 수준의 assert가 필요함. template의 {{ variable }} 은 적용되지 않아 오류 발생. # ## 사실 not 하지말고, 이게 같은지 확인해야 하는데.. self.assertNotEqual(response.content.decode(), expected_html) self.assertEqual(True, True)
def test_index_can_save_a_POST_request(self): request = HttpRequest() request.method = 'POST' request.POST['issue_subject'] = '8시 멘토링' request.POST['issue_date'] = '2015-01-01' response = index(request) self.assertEqual(Issue.objects.count(), 1) new_issue = Issue.objects.first() self.assertEqual(new_issue.subject, '8시 멘토링') self.assertEqual(str(new_issue.idate), '2015-01-01') date = datetime.datetime(2015, 1, 1) year = date.isocalendar()[0] week = date.isocalendar()[1] redirect_url = "/" + str(year) + "/" + str(week) # 저장 후 리다이렉트 잘 하는지 self.assertEqual(response.status_code, 302) self.assertEqual(response['location'], redirect_url)