# Path: paystackapi/tests/base_test_case.py
# class BaseTestCase(unittest.TestCase):
# 		
# 	def endpoint_url(self, path):
# 		if path[0] == '/':
# 			return 'https://api.paystack.co{}'.format(path)
# 		return 'https://api.paystack.co/{}'.format(path)
# 
# Path: paystackapi/product.py
# class Product(PayStackBase):
#     """docstring for Product."""
# 
#     @classmethod
#     def create(cls, **kwargs):
#         """
#         Function defined to create product.
# 
#         Args:
#             name: name of the product
#             description: description of product
#             price: price of the product, in kobo(Integer)
#             currency: currency in which amount should be charged
#             **kwargs
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.post('product', data=kwargs,)
# 
#     @classmethod
#     def list(cls):
#         """
#         List Products.
# 
#         Args:
#             No argument required.
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.get('product')
# 
#     @classmethod
#     def fetch(cls, product_id):
#         """
#         Get a single product by id.
# 
#         Args:
#             product_id: Product id(integer).
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.get(f"product/{product_id}")
# 
#     @classmethod
#     def update(cls, product_id, **kwargs):
#         """
#         Static method defined to update product by id.
# 
#         Args:
#             product_id: paystack product id.
#             name: name of the product
#             description: description of product
#             price: price of the product, in kobo(Integer)
#             currency: currency in which amount should be charged
#             **kwargs
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.put(f"product/{product_id}", data=kwargs,)


import httpretty
from paystackapi.tests.base_test_case import BaseTestCase
from paystackapi.product import Product
class TestProduct(BaseTestCase):

    @httpretty.activate
    def test_product_create(self):
        """Method defined to test product creation."""
        httpretty.register_uri(
            httpretty.POST,
            self.endpoint_url("/product"),
            content_type='text/json',
            body='{"status": true,  "message": "Product successfully created"}',
            status=201,
        )

        response = Product.create(
            name="Product pypaystack test", description="my test description",
            price=500000, currency="NGN"
        )
        self.assertTrue(response['status'])

    @httpretty.activate
    def test_product_list(self):
        """Method defined to test Product list."""
        httpretty.register_uri(
            httpretty.GET,
            self.endpoint_url("/product"),
            content_type='text/json',
            body='{"status": true, "message": "Products retrieved", "data":[{}], "meta":{}}',
            status=201,
        )


# Path: paystackapi/tests/base_test_case.py
# class BaseTestCase(unittest.TestCase):
# 		
# 	def endpoint_url(self, path):
# 		if path[0] == '/':
# 			return 'https://api.paystack.co{}'.format(path)
# 		return 'https://api.paystack.co/{}'.format(path)
# 
# Path: paystackapi/product.py
# class Product(PayStackBase):
#     """docstring for Product."""
# 
#     @classmethod
#     def create(cls, **kwargs):
#         """
#         Function defined to create product.
# 
#         Args:
#             name: name of the product
#             description: description of product
#             price: price of the product, in kobo(Integer)
#             currency: currency in which amount should be charged
#             **kwargs
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.post('product', data=kwargs,)
# 
#     @classmethod
#     def list(cls):
#         """
#         List Products.
# 
#         Args:
#             No argument required.
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.get('product')
# 
#     @classmethod
#     def fetch(cls, product_id):
#         """
#         Get a single product by id.
# 
#         Args:
#             product_id: Product id(integer).
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.get(f"product/{product_id}")
# 
#     @classmethod
#     def update(cls, product_id, **kwargs):
#         """
#         Static method defined to update product by id.
# 
#         Args:
#             product_id: paystack product id.
#             name: name of the product
#             description: description of product
#             price: price of the product, in kobo(Integer)
#             currency: currency in which amount should be charged
#             **kwargs
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.put(f"product/{product_id}", data=kwargs,)


# Path: paystackapi/tests/test_product.py
import httpretty
from paystackapi.tests.base_test_case import BaseTestCase
from paystackapi.product import Product

class TestProduct(BaseTestCase):

    @httpretty.activate
    def test_product_create(self):
        """Method defined to test product creation."""
        httpretty.register_uri(
            httpretty.POST,
            self.endpoint_url("/product"),
            content_type='text/json',
            body='{"status": true,  "message": "Product successfully created"}',
            status=201,
        )

        response = Product.create(
            name="Product pypaystack test", description="my test description",
            price=500000, currency="NGN"
        )
        self.assertTrue(response['status'])

    @httpretty.activate
    def test_product_list(self):
        """Method defined to test Product list."""
        httpretty.register_uri(
            httpretty.GET,
            self.endpoint_url("/product"),
            content_type='text/json',
            body='{"status": true, "message": "Products retrieved", "data":[{}], "meta":{}}',
            status=201,
        )


        response = Product.list()