def test_custom_post(self):
        encoding = 'UTF-8'
        credentials = Credentials()
        shopify = Shopify(shop_name='test', credentials=credentials)

        data = '{"test_model": {"id": 1, "name": "test"}}'
        response = requests.Response()
        response.encoding = encoding
        response._content = data.encode(encoding)
        response.status_code = 200

        shopify.session.post = mock.Mock(return_value=response)
        result = shopify.custom_post(TestModel, "/custom")
        self.assertEquals(result, json.loads(data))

        instance = TestModel(id="test")
        try:
            response = requests.Response()
            response.encoding = encoding
            response._content = data.encode(encoding)
            response.status_code = 404
            shopify.session.post = mock.Mock(return_value=response)
            shopify.custom_post(instance, "/custom")
            self.fail()
        except ShopifyException:
            pass
    def test_custom_post(self):
        encoding = 'UTF-8'
        credentials = Credentials()
        shopify = Shopify(shop_name='test', credentials=credentials)

        data = '{"test_model": {"id": 1, "name": "test"}}'
        response = requests.Response()
        response.encoding = encoding
        response._content = data.encode(encoding)
        response.status_code = 200

        shopify.session.post = mock.Mock(return_value=response)
        result = shopify.custom_post(TestModel, "/custom")
        self.assertEquals(result, json.loads(data))

        instance = TestModel(id="test")
        try:
            response = requests.Response()
            response.encoding = encoding
            response._content = data.encode(encoding)
            response.status_code = 404
            shopify.session.post = mock.Mock(return_value=response)
            shopify.custom_post(instance, "/custom")
            self.fail()
        except ShopifyException:
            pass