# Path: mollie/api/objects/customer.py
# class Customer(ObjectBase):
#     @classmethod
#     def get_resource_class(cls, client):
#         from ..resources.customers import Customers
# 
#         return Customers(client)
# 
#     @property
#     def id(self):
#         return self._get_property("id")
# 
#     @property
#     def name(self):
#         return self._get_property("name")
# 
#     @property
#     def email(self):
#         return self._get_property("email")
# 
#     @property
#     def locale(self):
#         return self._get_property("locale")
# 
#     @property
#     def metadata(self):
#         return self._get_property("metadata")
# 
#     @property
#     def mode(self):
#         return self._get_property("mode")
# 
#     @property
#     def resource(self):
#         return self._get_property("resource")
# 
#     @property
#     def created_at(self):
#         return self._get_property("createdAt")
# 
#     @property
#     def subscriptions(self):
#         """Return the subscription list for the customer."""
#         if not self._get_link("subscriptions"):
#             return ObjectList({}, None)
#         return self.client.customer_subscriptions.on(self).list()
# 
#     @property
#     def mandates(self):
#         """Return the mandate list for the customer."""
#         if not self._get_link("mandates"):
#             return ObjectList({}, None)
#         return self.client.customer_mandates.on(self).list()
# 
#     @property
#     def payments(self):
#         """Return the payment list for the customer."""
#         if not self._get_link("payments"):
#             return ObjectList({}, None)
#         return self.client.customer_payments.on(self).list()
# 
# Path: mollie/api/objects/mandate.py
# class Mandate(ObjectBase):
#     @classmethod
#     def get_resource_class(cls, client):
#         from ..resources.customer_mandates import CustomerMandates
# 
#         return CustomerMandates(client)
# 
#     STATUS_PENDING = "pending"
#     STATUS_VALID = "valid"
#     STATUS_INVALID = "invalid"
# 
#     @property
#     def id(self):
#         return self._get_property("id")
# 
#     @property
#     def resource(self):
#         return self._get_property("resource")
# 
#     @property
#     def status(self):
#         return self._get_property("status")
# 
#     @property
#     def method(self):
#         return self._get_property("method")
# 
#     @property
#     def details(self):
#         return self._get_property("details")
# 
#     @property
#     def mandate_reference(self):
#         return self._get_property("mandateReference")
# 
#     @property
#     def signature_date(self):
#         return self._get_property("signatureDate")
# 
#     @property
#     def created_at(self):
#         return self._get_property("createdAt")
# 
#     def is_pending(self):
#         """Check if the mandate is pending."""
#         return self.status == self.STATUS_PENDING
# 
#     def is_valid(self):
#         """Check if the mandate is valid."""
#         return self.status == self.STATUS_VALID
# 
#     def is_invalid(self):
#         """Check if the mandate is invalid."""
#         return self.status == self.STATUS_INVALID
# 
#     @property
#     def customer(self):
#         """Return the customer for this mandate."""
#         url = self._get_link("customer")
#         if url:
#             return self.client.customers.from_url(url)
# 
# Path: tests/utils.py
# def assert_list_object(obj, object_type, count=None):
#     """Assert that a List object is correctly working, and has sane contents."""
#     assert isinstance(obj, ObjectList), f"Object {obj} is not a ObjectList instance."
#     assert isinstance(obj.count, int), "ObjectList count is not an integer."
#     if count is not None:
#         assert obj.count == count, "ObjectList does not contain the expected number of items."
#     else:
#         assert obj.count > 0, "ObjectList has no items."
# 
#     # verify items in list
#     items = []
#     for item in obj:
#         assert isinstance(item, object_type)
#         assert item.id is not None
#         items.append(item.id)
# 
#     assert len(items) == obj.count, "Items in ObjectList don't match list count."
#     assert len(set(items)) == obj.count, "Not all object ids in the ObjectList are unique."


from mollie.api.objects.customer import Customer
from mollie.api.objects.mandate import Mandate
from .utils import assert_list_object
    assert isinstance(mandate, Mandate)
    assert mandate.id == MANDATE_ID
    assert mandate.resource == "mandate"
    assert mandate.status == "valid"
    assert mandate.method == "directdebit"
    assert mandate.details == {
        "consumerName": "John Doe",
        "consumerAccount": "NL55INGB0000000000",
        "consumerBic": "INGBNL2A",
    }
    assert mandate.mandate_reference == "YOUR-COMPANY-MD1380"
    assert mandate.signature_date == "2018-05-07"
    assert mandate.created_at == "2018-05-07T10:49:08+00:00"
    assert mandate.is_pending() is False
    assert mandate.is_valid() is True
    assert mandate.is_invalid() is False
    assert mandate.customer is not None


def test_get_customer_mandate_by_customer(client, response):
    """Retrieve a customer by customer object."""
    response.get(f"https://api.mollie.com/v2/customers/{CUSTOMER_ID}", "customer_new")
    response.get(f"https://api.mollie.com/v2/customers/{CUSTOMER_ID}/mandates", "customer_mandates_list")
    response.get(
        f"https://api.mollie.com/v2/customers/{CUSTOMER_ID}/mandates/{MANDATE_ID}",
        "customer_mandate_single",
    )
    customer = client.customers.get(CUSTOMER_ID)

    mandates = client.customer_mandates.on(customer).list()

# Path: mollie/api/objects/customer.py
# class Customer(ObjectBase):
#     @classmethod
#     def get_resource_class(cls, client):
#         from ..resources.customers import Customers
# 
#         return Customers(client)
# 
#     @property
#     def id(self):
#         return self._get_property("id")
# 
#     @property
#     def name(self):
#         return self._get_property("name")
# 
#     @property
#     def email(self):
#         return self._get_property("email")
# 
#     @property
#     def locale(self):
#         return self._get_property("locale")
# 
#     @property
#     def metadata(self):
#         return self._get_property("metadata")
# 
#     @property
#     def mode(self):
#         return self._get_property("mode")
# 
#     @property
#     def resource(self):
#         return self._get_property("resource")
# 
#     @property
#     def created_at(self):
#         return self._get_property("createdAt")
# 
#     @property
#     def subscriptions(self):
#         """Return the subscription list for the customer."""
#         if not self._get_link("subscriptions"):
#             return ObjectList({}, None)
#         return self.client.customer_subscriptions.on(self).list()
# 
#     @property
#     def mandates(self):
#         """Return the mandate list for the customer."""
#         if not self._get_link("mandates"):
#             return ObjectList({}, None)
#         return self.client.customer_mandates.on(self).list()
# 
#     @property
#     def payments(self):
#         """Return the payment list for the customer."""
#         if not self._get_link("payments"):
#             return ObjectList({}, None)
#         return self.client.customer_payments.on(self).list()
# 
# Path: mollie/api/objects/mandate.py
# class Mandate(ObjectBase):
#     @classmethod
#     def get_resource_class(cls, client):
#         from ..resources.customer_mandates import CustomerMandates
# 
#         return CustomerMandates(client)
# 
#     STATUS_PENDING = "pending"
#     STATUS_VALID = "valid"
#     STATUS_INVALID = "invalid"
# 
#     @property
#     def id(self):
#         return self._get_property("id")
# 
#     @property
#     def resource(self):
#         return self._get_property("resource")
# 
#     @property
#     def status(self):
#         return self._get_property("status")
# 
#     @property
#     def method(self):
#         return self._get_property("method")
# 
#     @property
#     def details(self):
#         return self._get_property("details")
# 
#     @property
#     def mandate_reference(self):
#         return self._get_property("mandateReference")
# 
#     @property
#     def signature_date(self):
#         return self._get_property("signatureDate")
# 
#     @property
#     def created_at(self):
#         return self._get_property("createdAt")
# 
#     def is_pending(self):
#         """Check if the mandate is pending."""
#         return self.status == self.STATUS_PENDING
# 
#     def is_valid(self):
#         """Check if the mandate is valid."""
#         return self.status == self.STATUS_VALID
# 
#     def is_invalid(self):
#         """Check if the mandate is invalid."""
#         return self.status == self.STATUS_INVALID
# 
#     @property
#     def customer(self):
#         """Return the customer for this mandate."""
#         url = self._get_link("customer")
#         if url:
#             return self.client.customers.from_url(url)
# 
# Path: tests/utils.py
# def assert_list_object(obj, object_type, count=None):
#     """Assert that a List object is correctly working, and has sane contents."""
#     assert isinstance(obj, ObjectList), f"Object {obj} is not a ObjectList instance."
#     assert isinstance(obj.count, int), "ObjectList count is not an integer."
#     if count is not None:
#         assert obj.count == count, "ObjectList does not contain the expected number of items."
#     else:
#         assert obj.count > 0, "ObjectList has no items."
# 
#     # verify items in list
#     items = []
#     for item in obj:
#         assert isinstance(item, object_type)
#         assert item.id is not None
#         items.append(item.id)
# 
#     assert len(items) == obj.count, "Items in ObjectList don't match list count."
#     assert len(set(items)) == obj.count, "Not all object ids in the ObjectList are unique."


# Path: tests/test_customer_mandates.py
from mollie.api.objects.customer import Customer
from mollie.api.objects.mandate import Mandate
from .utils import assert_list_object

    assert isinstance(mandate, Mandate)
    assert mandate.id == MANDATE_ID
    assert mandate.resource == "mandate"
    assert mandate.status == "valid"
    assert mandate.method == "directdebit"
    assert mandate.details == {
        "consumerName": "John Doe",
        "consumerAccount": "NL55INGB0000000000",
        "consumerBic": "INGBNL2A",
    }
    assert mandate.mandate_reference == "YOUR-COMPANY-MD1380"
    assert mandate.signature_date == "2018-05-07"
    assert mandate.created_at == "2018-05-07T10:49:08+00:00"
    assert mandate.is_pending() is False
    assert mandate.is_valid() is True
    assert mandate.is_invalid() is False
    assert mandate.customer is not None


def test_get_customer_mandate_by_customer(client, response):
    """Retrieve a customer by customer object."""
    response.get(f"https://api.mollie.com/v2/customers/{CUSTOMER_ID}", "customer_new")
    response.get(f"https://api.mollie.com/v2/customers/{CUSTOMER_ID}/mandates", "customer_mandates_list")
    response.get(
        f"https://api.mollie.com/v2/customers/{CUSTOMER_ID}/mandates/{MANDATE_ID}",
        "customer_mandate_single",
    )
    customer = client.customers.get(CUSTOMER_ID)

    mandates = client.customer_mandates.on(customer).list()

    assert_list_object(mandates, Mandate)