コード例 #1
0
    def test_path_or_resource(self):
        c = Client()
        obj = TestModel()
        obj.test = 'TESTING'
        obj.save()

        resource = resources1.Test_1_1_Resource()

        list_path = resource.get_resource_list_uri()
        object_path = resource.get_resource_uri(obj)

        result = c._path_or_resource(list_path)
        expected = list_path
        self.assertEqual(
            result, expected,
            "Bare path.\nResult:%s\nExpected:%s" % (result, expected))

        result = c._path_or_resource(list_path, obj)
        expected = list_path
        self.assertEqual(
            result, expected,
            "Bare path w/obj.\nResult:%s\nExpected:%s" % (result, expected))

        result = c._path_or_resource(resource)
        expected = list_path
        self.assertEqual(
            result, expected,
            "Empty resource.\nResult:%s\nExpected:%s" % (result, expected))

        result = c._path_or_resource(resource, obj)
        expected = object_path
        self.assertEqual(
            result, expected,
            "Populated resource.\nResult:%s\nExpected:%s" % (result, expected))
コード例 #2
0
 def test_testdata(self):
     """The API is able to register a testdata class"""
     self.api.register(resources1.Test_1_1_Resource())
     self.api.register_testdata(testdata1.Test_1_1_TestData)
     td = self.api.resource("test_1_1")._meta.testdata
     msg = "%s is not subclass of ResourceTestData" % td.__class__
     self.assertTrue(issubclass(td.__class__, ResourceTestData), msg)
     res = self.api.resource("test_1_1").create_test_resource()
コード例 #3
0
    def test_testdata_list(self):
        """The API is able to register a list of testdata classes"""
        resources = [
            resources1.Test_1_1_Resource(),
            resources1.Test_1_2_Resource()
        ]
        self.api.register(resources=resources)
        testdata_list = [
            testdata1.Test_1_1_TestData, testdata1.Test_1_2_TestData
        ]
        self.api.register_testdata(list=testdata_list)

        for r in ["test_1_1", "test_1_2"]:
            td = self.api.resource(r)._meta.testdata
            msg = "%s is not subclass of ResourceTestData" % td.__class__
            self.assertTrue(issubclass(td.__class__, ResourceTestData), msg)
            res = self.api.resource(r).create_test_resource()
コード例 #4
0
 def test_resource_importing(self):
     """The Api class is able to import a single resource"""
     self.api.register(resources1.Test_1_1_Resource())
     self._assert_in_registry(["test_1_1"])