Ejemplo n.º 1
0
class PathRequestTest(BaseTestCase):

    def setUp(self):
        """
        Create a couple of path based tests.
        """
        super(PathRequestTest, self).setUp()
        self.path_test1 = PathTestModel.objects.create(path='/')
        self.path_test2 = PathTestModel.objects.create(path='/parent/')
        self.path_test3 = PathTestModel.objects.create(path='/parent/child/')
        self.test = PathTest()

    def test_match_root(self):
        request = self.req_factory.request()
        match = self.test.test(request)
        assert match == self.path_test1

    def test_match_exact_path(self):
        request = self.req_factory.request(PATH_INFO='/parent/')
        match = self.test.test(request)
        assert match == self.path_test2

    def test_match_doesnt_hit_child(self):
        request = self.req_factory.request(PATH_INFO='/parent/child')
        match = self.test.test(request)
        assert match is None
Ejemplo n.º 2
0
 def setUp(self):
     """
     Create a couple of path based tests.
     """
     super(PathRequestTest, self).setUp()
     self.path_test1 = PathTestModel.objects.create(path='/')
     self.path_test2 = PathTestModel.objects.create(path='/parent/')
     self.path_test3 = PathTestModel.objects.create(path='/parent/child/')
     self.test = PathTest()