How to use the bigcommerce.api.ApiResourceWrapper function in bigcommerce

To help you get started, we’ve selected a few bigcommerce examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bigcommerce / bigcommerce-api-python / tests / test_api.py View on Github external
def test_str_to_class(self):
        cls = bigcommerce.api.ApiResourceWrapper.str_to_class('ApiResource')
        self.assertEqual(cls, ApiResource)

        self.assertRaises(AttributeError, lambda: bigcommerce.api.ApiResourceWrapper.str_to_class('ApiResourceWhichDoesNotExist'))
github bigcommerce / bigcommerce-api-python / tests / test_api.py View on Github external
def test_create(self):
        api = MagicMock()
        api.connection = MagicMock()

        wrapper = bigcommerce.api.ApiResourceWrapper('ApiResource', api)
        self.assertEqual(api.connection, wrapper.connection)
        self.assertEqual(wrapper.resource_class, ApiResource)

        wrapper = bigcommerce.api.ApiResourceWrapper(ApiResource, api)
        self.assertEqual(wrapper.resource_class, ApiResource)
github bigcommerce / bigcommerce-api-python / tests / test_api.py View on Github external
def test_get_attr(self, patcher):
        api = MagicMock()
        api.connection = MagicMock()

        result = {'id': 1}
        patcher.return_value = result

        wrapper = bigcommerce.api.ApiResourceWrapper('ApiResource', api)
        self.assertEqual(wrapper.get(1), result)
        patcher.assert_called_once_with(1, connection=api.connection)
github bigcommerce / bigcommerce-api-python / tests / test_api.py View on Github external
def test_create(self):
        api = MagicMock()
        api.connection = MagicMock()

        wrapper = bigcommerce.api.ApiResourceWrapper('ApiResource', api)
        self.assertEqual(api.connection, wrapper.connection)
        self.assertEqual(wrapper.resource_class, ApiResource)

        wrapper = bigcommerce.api.ApiResourceWrapper(ApiResource, api)
        self.assertEqual(wrapper.resource_class, ApiResource)
github bigcommerce / bigcommerce-api-python / bigcommerce / api.py View on Github external
def __getattr__(self, item):
        return ApiResourceWrapper(item, self)