# Path: mollie/api/objects/capture.py
# class Capture(ObjectBase):
#     @classmethod
#     def get_resource_class(cls, client):
#         from ..resources.captures import Captures
# 
#         return Captures(client)
# 
#     @property
#     def id(self):
#         return self._get_property("id")
# 
#     @property
#     def mode(self):
#         return self._get_property("mode")
# 
#     @property
#     def amount(self):
#         return self._get_property("amount")
# 
#     @property
#     def settlement_amount(self):
#         return self._get_property("settlementAmount")
# 
#     @property
#     def payment_id(self):
#         return self._get_property("paymentId")
# 
#     @property
#     def shipment_id(self):
#         return self._get_property("shipmentId")
# 
#     @property
#     def settlement_id(self):
#         return self._get_property("settlementId")
# 
#     @property
#     def created_at(self):
#         return self._get_property("createdAt")
# 
#     @property
#     def payment(self):
#         """Return the payment for this capture."""
#         # TODO Use the embedded payment data, if avalable.
#         return self.client.payments.get(self.payment_id)
# 
#     @property
#     def shipment(self):
#         """Return the shipment for this capture."""
#         url = self._get_link("shipment")
#         if url:
#             return self.client.shipments.from_url(url)
# 
#     @property
#     def settlement(self):
#         """Return the settlement for this capture."""
#         return self.client.settlements.get(self.settlement_id)
# 
# 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.capture import Capture
from .utils import assert_list_object


PAYMENT_ID = "tr_7UhSN1zuXS"
SETTLEMENT_ID = "stl_jDk30akdN"
CHARGEBACK_ID = "chb_n9z0tp"


def test_get_settlement_captures_by_capture_id(oauth_client, response):
    """Get captures relevant to settlement by settlement id."""
    response.get(f"https://api.mollie.com/v2/settlements/{SETTLEMENT_ID}/captures", "captures_list")

    captures = oauth_client.settlement_captures.with_parent_id(SETTLEMENT_ID).list()
    assert_list_object(captures, Capture)


def test_list_settlement_captures_by_capture_object(oauth_client, response):
    """Get a list of captures relevant to settlement object."""
    response.get(f"https://api.mollie.com/v2/settlements/{SETTLEMENT_ID}/captures", "captures_list")
    response.get(f"https://api.mollie.com/v2/settlements/{SETTLEMENT_ID}", "settlement_single")

    settlement = oauth_client.settlements.get(SETTLEMENT_ID)
    captures = oauth_client.settlement_captures.on(settlement).list()

# Path: mollie/api/objects/capture.py
# class Capture(ObjectBase):
#     @classmethod
#     def get_resource_class(cls, client):
#         from ..resources.captures import Captures
# 
#         return Captures(client)
# 
#     @property
#     def id(self):
#         return self._get_property("id")
# 
#     @property
#     def mode(self):
#         return self._get_property("mode")
# 
#     @property
#     def amount(self):
#         return self._get_property("amount")
# 
#     @property
#     def settlement_amount(self):
#         return self._get_property("settlementAmount")
# 
#     @property
#     def payment_id(self):
#         return self._get_property("paymentId")
# 
#     @property
#     def shipment_id(self):
#         return self._get_property("shipmentId")
# 
#     @property
#     def settlement_id(self):
#         return self._get_property("settlementId")
# 
#     @property
#     def created_at(self):
#         return self._get_property("createdAt")
# 
#     @property
#     def payment(self):
#         """Return the payment for this capture."""
#         # TODO Use the embedded payment data, if avalable.
#         return self.client.payments.get(self.payment_id)
# 
#     @property
#     def shipment(self):
#         """Return the shipment for this capture."""
#         url = self._get_link("shipment")
#         if url:
#             return self.client.shipments.from_url(url)
# 
#     @property
#     def settlement(self):
#         """Return the settlement for this capture."""
#         return self.client.settlements.get(self.settlement_id)
# 
# 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_settlement_captures.py
from mollie.api.objects.capture import Capture
from .utils import assert_list_object



PAYMENT_ID = "tr_7UhSN1zuXS"
SETTLEMENT_ID = "stl_jDk30akdN"
CHARGEBACK_ID = "chb_n9z0tp"


def test_get_settlement_captures_by_capture_id(oauth_client, response):
    """Get captures relevant to settlement by settlement id."""
    response.get(f"https://api.mollie.com/v2/settlements/{SETTLEMENT_ID}/captures", "captures_list")

    captures = oauth_client.settlement_captures.with_parent_id(SETTLEMENT_ID).list()
    assert_list_object(captures, Capture)


def test_list_settlement_captures_by_capture_object(oauth_client, response):
    """Get a list of captures relevant to settlement object."""
    response.get(f"https://api.mollie.com/v2/settlements/{SETTLEMENT_ID}/captures", "captures_list")
    response.get(f"https://api.mollie.com/v2/settlements/{SETTLEMENT_ID}", "settlement_single")

    settlement = oauth_client.settlements.get(SETTLEMENT_ID)
    captures = oauth_client.settlement_captures.on(settlement).list()

    assert_list_object(captures, Capture)