Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 145 lines (100 sloc) 3.984 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
from django.test.client import Client
from django.test import TestCase

class MingusClientTests(TestCase):
    
    fixtures = ['test_data.json', ]

    def setUp(self):
        pass

    def tearDown(self):
        pass


    def test_HomePage(self):
        '''Test if the homepage renders.'''
        c = Client()
        response = c.get('/')
        self.failUnlessEqual(response.status_code, 200)

    def test_Homepage_Paging(self):
        '''
Test paging the homepage list.

'''

        #need to update blog Settings page size, it defaults to 20 but we
        #don't have 20 records to page. So we'll set it to 1 and we should be ok.
        from basic.blog.models import Settings
        settings = Settings.get_current()
        settings.page_size = 1
        settings.save()

        c = Client()
        response = c.get('/', {'page': 2},)
        self.failUnlessEqual(response.status_code, 200)

    def test_Search(self):
        '''Test search view.'''

        c = Client()
        response = c.get('/search/', {'q':'django'})

        #test success request
        self.failUnlessEqual(response.status_code, 200)

        #test result as expected
        self.assertEquals(response.context['object_list'][0].title, 'Django Community')

    def test_About(self):
        'Test if the about page renders.'
        c = Client()
        response = c.get('/about/')
        self.failUnlessEqual(response.status_code, 200)

    def test_Contact(self):
        'Test if the contact page renders.'
        c = Client()
        response = c.get('/contact/')

        self.failUnlessEqual(response.status_code, 200)

    def test_ContactSubmit(self):
        '''
Test submitting the contact form. Expect to return to the form sent
template.

The field 'fonzie_kungfu' is the honeypot field to protect you from
spam. This feature is provided by django-honeypot.

'''
        c = Client()
        response = c.post('/contact/', {'name': 'charles',
                    'email': 'foo@foo.com', 'body': 'hello.',
                    'fonzie_kungfu': ''},
                    follow=True)
        self.failUnlessEqual(response.status_code, 200)

    def test_ContactSubmit_WithHoneyPot(self):
        '''Test the @honeypot decorator which exists to reduce spam.

HoneyPot will return a 400 response if the honeypot field is
submited with a value.

'''
        c = Client()
        response = c.post('/contact/', {'name': 'charles', 'email':
                    'foo@foo.com', 'body': 'hello.', 'fonzie_kungfu': 'evil'},
                    follow=True)
        self.failUnlessEqual(response.status_code, 400)


    def test_QuoteList(self):
        '''Test quote list page renders.'''

        c = Client()
        response = c.get('/quotes/')
        self.failUnlessEqual(response.status_code, 200)

    def test_QuoteDetail(self):
        '''Test quote list page renders.'''

        from quoteme.models import Quote
        quote = Quote.objects.all()[0]

        c = Client()
        response = c.get(quote.get_absolute_url())
        self.failUnlessEqual(response.status_code, 200)


    def test_RSS(self):
        '''Test the latest posts feed displays.'''

        c = Client()
        response = c.get('/feeds/latest/')
        self.failUnlessEqual(response.status_code, 200)

    def test_SpringsteenFeed_Posts(self):
        '''
Test the latest Post springsteen feed for findjango integration
displays.
'''

        c = Client()
        response = c.get('/api/springsteen/posts/')
        self.failUnlessEqual(response.status_code, 200)


    def test_SpringsteenFeed_Posts_ByCategory(self):
        '''
Test the latest Post By Category springsteen feed for findjango
integration displays.

'''

        c = Client()
        response = c.get('/api/springsteen/category/django/')
        self.failUnlessEqual(response.status_code, 200)






Something went wrong with that request. Please try again.