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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE7Ck-Ri8KUkhzHddmOqHoWMmm8%2BPBdTFjAt1yQDT9FbSvhnpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to