def test_index(self): encoding = 'UTF-8' credentials = Credentials() shopify = Shopify(shop_name='test', credentials=credentials) data = '{"test_models": [{"id": 1, "name": "test"}]}' response = requests.Response() response.encoding = encoding response._content = data.encode(encoding) response.status_code = 200 shopify.session.get = mock.Mock(return_value=response) result = shopify.index(TestModel) self.assertIsInstance(result, Collection) result = shopify.index(TestModel, auto_instance=False) self.assertIsInstance(result, dict) self.assertTrue("test_models" in result) try: response = requests.Response() response.encoding = encoding response._content = data.encode(encoding) response.status_code = 404 shopify.session.get = mock.Mock(return_value=response) result = shopify.index(TestModel) self.fail() except ShopifyException: pass