Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'))
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)
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)
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)
def __getattr__(self, item):
return ApiResourceWrapper(item, self)