Hello,
I'd like to write a test script for my django app.
Example, if within business hour, my django app will render:
"It's working time!"
And if not within business hour, my django app will render:
"Happy holiday!"
So the views, will check when the url is accessed.
How do I write the test script?
Following django docs here[1], I started to write my test code.
from django.test import Client, TestCase
class TestPage(TestCase):
def test_holiday(self):
response = self.client.get('/day/')
self.assertEqual(response.status_code, 200)
self.assertContains(response, "It's working time!")
This test code will success if I run within business hour. But If I
run it not within business hour, the test code will fail.
* How to write a better test code?
* How do I use mock/patch?
* How to write test code that will check the within and not within
business hour in one file that both will success whenever I run the
test code?
[1]
https://docs.djangoproject.com/en/1.7/topics/testing/tools/#testing-responses
Thanks,
--
Zaki Akhmad