# 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/page.py
# class Page(PayStackBase):
#     """docstring for Page."""
# 
#     @classmethod
#     def create(cls, **kwargs):
#         """
#         method defined to create a new page.
# 
#         Args:
#             name: name of page
#             **kwargs
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.post('page', data=kwargs,)
# 
#     @classmethod
#     def list(cls, **kwargs):
#         """
#         List pages
#         
#         Args:
#             perPage: records you want to retrieve per page (Integer)
#             page: what page you want to retrieve (Integer)
#         
#         Returns:
#         JSON data from paystack's API.
#         """
#         return cls().requests.get("page", qs=kwargs)
# 
#     @classmethod
#     def fetch(cls, id_or_slug):
#         """
#         Get a single page by id or slug.
# 
#         Args:
#             id_or_slug: id or slug
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.get(f"page/{id_or_slug}")
# 
#     @classmethod
#     def update(cls, id_or_slug, **kwargs):
#         """
#         Update a single page by id or slug.
# 
#         Args:
#             id_or_slug: id or slug
#             **kwargs
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.put(f"page/{id_or_slug}", data=kwargs,)
# 
#     @classmethod
#     def is_slug_available(cls, slug):
#         """
#         Check if a slug is available.
# 
#         Args:
#             slug: URL slug to be confirmed
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.put(f"page/check_slug_availability/{slug}")
# 
#     @classmethod
#     def add_products(cls, payment_page_id, **kwargs):
#         """
#         Add products to page
# 
#         Args:
#             payment_page_id: Id of the payment page (Integer)
#             product: Ids of all the products i.e. [473, 292]
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.put(f"page/{payment_page_id}/product", data=kwargs,)


import httpretty
from paystackapi.tests.base_test_case import BaseTestCase
from paystackapi.page import Page
        )

        response = Page.update(id_or_slug="5nApBwZkvY", name="new page name")
        self.assertEqual(response['status'], True)

    @httpretty.activate
    def test_is_slug_available(self):
        """Method defined to test_is_slug_available method."""
        httpretty.register_uri(
            httpretty.PUT,
            self.endpoint_url("/page/check_slug_availability/5nApBwZkvY"),
            content_type='text/json',
            body='{"status": true, "message": "Slug is available"}',
            status=201,
        )

        response = Page.is_slug_available(slug="5nApBwZkvY")
        self.assertEqual(response['status'], True)

    @httpretty.activate
    def test_add_products(self):
        """Method defined to test add_products method."""
        httpretty.register_uri(
            httpretty.PUT,
            self.endpoint_url("/page/23/product"),
            content_type='text/json',
            body='{"status": true, "message": "Products added to page"}',
            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/page.py
# class Page(PayStackBase):
#     """docstring for Page."""
# 
#     @classmethod
#     def create(cls, **kwargs):
#         """
#         method defined to create a new page.
# 
#         Args:
#             name: name of page
#             **kwargs
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.post('page', data=kwargs,)
# 
#     @classmethod
#     def list(cls, **kwargs):
#         """
#         List pages
#         
#         Args:
#             perPage: records you want to retrieve per page (Integer)
#             page: what page you want to retrieve (Integer)
#         
#         Returns:
#         JSON data from paystack's API.
#         """
#         return cls().requests.get("page", qs=kwargs)
# 
#     @classmethod
#     def fetch(cls, id_or_slug):
#         """
#         Get a single page by id or slug.
# 
#         Args:
#             id_or_slug: id or slug
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.get(f"page/{id_or_slug}")
# 
#     @classmethod
#     def update(cls, id_or_slug, **kwargs):
#         """
#         Update a single page by id or slug.
# 
#         Args:
#             id_or_slug: id or slug
#             **kwargs
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.put(f"page/{id_or_slug}", data=kwargs,)
# 
#     @classmethod
#     def is_slug_available(cls, slug):
#         """
#         Check if a slug is available.
# 
#         Args:
#             slug: URL slug to be confirmed
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.put(f"page/check_slug_availability/{slug}")
# 
#     @classmethod
#     def add_products(cls, payment_page_id, **kwargs):
#         """
#         Add products to page
# 
#         Args:
#             payment_page_id: Id of the payment page (Integer)
#             product: Ids of all the products i.e. [473, 292]
# 
#         Returns:
#             Json data from paystack API.
#         """
#         return cls().requests.put(f"page/{payment_page_id}/product", data=kwargs,)


# Path: paystackapi/tests/test_page.py
import httpretty
from paystackapi.tests.base_test_case import BaseTestCase
from paystackapi.page import Page

        )

        response = Page.update(id_or_slug="5nApBwZkvY", name="new page name")
        self.assertEqual(response['status'], True)

    @httpretty.activate
    def test_is_slug_available(self):
        """Method defined to test_is_slug_available method."""
        httpretty.register_uri(
            httpretty.PUT,
            self.endpoint_url("/page/check_slug_availability/5nApBwZkvY"),
            content_type='text/json',
            body='{"status": true, "message": "Slug is available"}',
            status=201,
        )

        response = Page.is_slug_available(slug="5nApBwZkvY")
        self.assertEqual(response['status'], True)

    @httpretty.activate
    def test_add_products(self):
        """Method defined to test add_products method."""
        httpretty.register_uri(
            httpretty.PUT,
            self.endpoint_url("/page/23/product"),
            content_type='text/json',
            body='{"status": true, "message": "Products added to page"}',
            status=201,
        )


        response = Page.add_products(payment_page_id=23, product=[[473, 292]])