def setUp(self):
        self.request_factory = RequestFactory()
        self.riff = self.get_riff()

        #TODO it would be nice if django's test case could just use this!
        self.resolver = GenericURLResolver(r'^', self.riff.get_urls())

        def reverse(name, *args, **kwargs):
            ret = self.resolver.reverse(name, *args, **kwargs)
            return ret

        self.riff.reverse = reverse
Beispiel #2
0
    def setUp(self):
        self.request_factory = SuperUserRequestFactory()
        self.riff = self.get_riff()

        #TODO it would be nice if django's test case could just use this!
        self.resolver = GenericURLResolver(r'^', self.riff.get_urls())

        def reverse(name, *args, **kwargs):
            ret = self.resolver.reverse(name, *args, **kwargs)
            return ret

        self.riff.reverse = reverse

        class form_class(forms.ModelForm):
            class Meta:
                model = ContentType

        self.form_class = form_class
Beispiel #3
0
 def setUp(self):
     self.request_factory = RequestFactory()
     self.riff = self.get_test_riff()
     
     #TODO it would be nice if django's test case could just use this!
     self.resolver = GenericURLResolver(r'^', self.riff.get_urls())
     
     def reverse(name, *args, **kwargs):
         ret = self.resolver.reverse(name, *args, **kwargs)
         return ret
     
     self.riff.reverse = reverse
Beispiel #4
0
 def setUp(self):
     self.request_factory = SuperUserRequestFactory()
     self.riff = self.get_riff()
     
     #TODO it would be nice if django's test case could just use this!
     self.resolver = GenericURLResolver(r'^', self.riff.get_urls())
     
     def reverse(name, *args, **kwargs):
         ret = self.resolver.reverse(name, *args, **kwargs)
         return ret
     
     self.riff.reverse = reverse
     
     class form_class(forms.ModelForm):
         class Meta:
             model = ContentType
     
     self.form_class = form_class
class ModelRiffTestCase(TestCase):
    def setUp(self):
        self.request_factory = RequestFactory()
        self.riff = self.get_riff()

        #TODO it would be nice if django's test case could just use this!
        self.resolver = GenericURLResolver(r'^', self.riff.get_urls())

        def reverse(name, *args, **kwargs):
            ret = self.resolver.reverse(name, *args, **kwargs)
            return ret

        self.riff.reverse = reverse

    def get_riff(self):
        return TestRiff()

    def test_get_urls(self):
        urls = self.riff.get_urls()

    def get_form_class(self):
        form_cls = self.riff.get_form_class()
        self.assertEqual(form_cls._meta.model, ContentType)
class BaseRiffTestCase(TestCase):
    def setUp(self):
        self.request_factory = RequestFactory()
        self.riff = self.get_test_riff()
        
        #TODO it would be nice if django's test case could just use this!
        self.resolver = GenericURLResolver(r'^', self.riff.get_urls())
        
        def reverse(name, *args, **kwargs):
            ret = self.resolver.reverse(name, *args, **kwargs)
            return ret
        
        self.riff.reverse = reverse
    
    def get_test_riff(self):
        return TestRiff()

    def test_riff_requires_verbose_name(self):
        self.assertRaises(ImproperlyConfigured, Riff)

    def test_get_urls(self):
        urls = self.riff.get_urls()

        purls, appname, namespace = self.riff.get_urls_tuple()

        #self.assertEquals(urls, purls)
        self.assertEquals(self.riff.namespace, namespace)

    def test_reverse(self):
        url = self.riff.reverse('login')
        self.assertEqual('login/', url)
    
    def test_get_unauthorized_response(self):
        request = self.request_factory.get('/')
        response = self.riff.get_unauthorized_response(request)
        self.assertEqual(response.status_code, 403)