def test_count(self): encoding = 'UTF-8' credentials = Credentials() shopify = Shopify(shop_name='test', credentials=credentials) data = '{"count": 2}' 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.count(TestModel) self.assertEquals(result, 2) 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.count(TestModel) self.fail() except ShopifyException: pass