<commit_before>from mollie.api.objects.list import List
from mollie.api.objects.mandate import Mandate
from mollie.api.objects.subscription import Subscription
CUSTOMER_ID = 'cst_8wmqcHMN4U'


def test_create_customer(client, response):
    """Create a new customer."""
    response.post('https://api.mollie.com/v2/customers', 'customer_new')

    customer = client.customers.create({
        'name': '<NAME>',
        'email': '<EMAIL>',
        'locale': 'nl_NL',
    })
    assert customer.name == '<NAME>'
    assert customer.email == '<EMAIL>'
    assert customer.id is not None
    assert customer.resource == 'customer'
    assert customer.created_at is not None
    assert customer.metadata is None
    assert customer.locale == 'nl_NL'
    assert customer.mode == 'test'


def test_update_customer(client, response):
    """Update an existing customer"""
    response.patch('https://api.mollie.com/v2/customers/%s' % CUSTOMER_ID, 'customer_updated')

    updated_customer = client.customers.update(CUSTOMER_ID, {
        'name': 'Updated <NAME>',
        'email': '<EMAIL>',
    })
    assert updated_customer.name == 'Updated <NAME>'
    assert updated_customer.email == '<EMAIL>'


def test_delete_customers(client, response):
    """Delete a customer"""
    response.delete('https://api.mollie.com/v2/customers/%s' % CUSTOMER_ID, 'empty')

    deleted_customer = client.customers.delete('cst_8wmqcHMN4U')
    assert deleted_customer == {}


def test_customers_all(client, response):
    """Retrieve a list of all existing customers"""
    response.get('https://api.mollie.com/v2/customers', 'customer_multiple')

    customers = client.customers.all()
    assert customers.count == 3
    iterated = 0
    for customer in customers:
        iterated += 1
        assert customer.id is not None
        assert customer.mode is not None
        assert customer.resource is not None
        assert customer.name is not None
        assert customer.email is not None
        assert customer.locale is not None
        assert customer.created_at is not None
    assert iterated == 3


def test_customer_get_related_mandates(client, response):
    """Retrieve related mandates for a customer."""
    response.get('https://api.mollie.com/v2/customers/%s' % CUSTOMER_ID, 'customer_updated')
    response.get('https://api.mollie.com/v2/customers/%s/mandates' % CUSTOMER_ID, 'customer_mandates_multiple')

    customer = client.customers.get(CUSTOMER_ID)
    mandates = customer.mandates
    assert isinstance(mandates, List)
    iterated = 0
    for mandate in mandates:
        assert isinstance(mandate, Mandate)
        iterated += 1
    assert iterated == mandates.count


def test_customer_get_related_subscriptions(client, response):
    """Retrieve related subscriptions for a customer"""
    response.get('https://api.mollie.com/v2/customers/%s/subscriptions' % CUSTOMER_ID,
                 'subscription_all')
    response.get('https://api.mollie.com/v2/customers/%s' % CUSTOMER_ID, 'customer_single')

    customer = client.customers.get(CUSTOMER_ID)
    subscriptions = customer.subscriptions<commit_msg>Make test_customers_all() the same as all similar tests<commit_after>from mollie.api.objects.list import List
from mollie.api.objects.mandate import Mandate
from mollie.api.objects.subscription import Subscription
CUSTOMER_ID = 'cst_8wmqcHMN4U'


def test_create_customer(client, response):
    """Create a new customer."""
    response.post('https://api.mollie.com/v2/customers', 'customer_new')

    customer = client.customers.create({
        'name': '<NAME>',
        'email': '<EMAIL>',
        'locale': 'nl_NL',
    })
    assert customer.name == '<NAME>'
    assert customer.email == '<EMAIL>'
    assert customer.id is not None
    assert customer.resource == 'customer'
    assert customer.created_at is not None
    assert customer.metadata is None
    assert customer.locale == 'nl_NL'
    assert customer.mode == 'test'


def test_update_customer(client, response):
    """Update an existing customer"""
    response.patch('https://api.mollie.com/v2/customers/%s' % CUSTOMER_ID, 'customer_updated')

    updated_customer = client.customers.update(CUSTOMER_ID, {
        'name': '<NAME>',
        'email': '<EMAIL>',
    })
    assert updated_customer.name == '<NAME>'
    assert updated_customer.email == '<EMAIL>'


def test_delete_customers(client, response):
    """Delete a customer"""
    response.delete('https://api.mollie.com/v2/customers/%s' % CUSTOMER_ID, 'empty')

    deleted_customer = client.customers.delete('cst_8wmqcHMN4U')
    assert deleted_customer == {}


def test_customers_all(client, response):
    """Retrieve a list of all existing customers"""
    response.get('https://api.mollie.com/v2/customers', 'customer_multiple')

    customers = client.customers.all()
    assert isinstance(customers, List)
    assert customers.count == 3
    iterated = 0
    iterated_customer_ids = []
    for customer in customers:
        assert isinstance(customer, Customer)
        iterated += 1
        assert customer.id is not None
        iterated_customer_ids.append(customer.id)
     assert iterated == customer.count, 'Unexpected amount of customer retrieved'
     assert len(set(iterated_customer_ids)) == customers.count, 'Unexpected amount of unique customer ids retrieved'


def test_customer_get(client, response):
    """Retrieve a single customer."""
    pass    
    
def test_customer_get_related_mandates(client, response):
    """Retrieve related mandates for a customer."""
    response.get('https://api.mollie.com/v2/customers/%s' % CUSTOMER_ID, 'customer_updated')
    response.get('https://api.mollie.com/v2/customers/%s/mandates' % CUSTOMER_ID, 'customer_mandates_multiple')

    customer = client.customers.get(CUSTOMER_ID)
    mandates = customer.mandates
    assert isinstance(mandates, List)
    iterated = 0
    for mandate in mandates:
        assert isinstance(mandate, Mandate)
        iterated += 1
    assert iterated == mandates.count


def test_customer_get_related_subscriptions(client, response):
    """Retrieve related subscriptions for a customer"""
    response.get('https://api.mollie.com/v2/customers/%s/subscriptions' % CUSTOMER_ID,
                 'subscription_all')
    response.get('https://api.mollie.com/v2/customers/%s' % CUSTOMER_ID, 'customer_single')

    customer = client.customers.get(CUSTOMER_ID)
    subscriptions = customer.subscriptions
{'fraction_non_alphanumeric': 0.12173913043478261, 'fraction_numerical': 0.005434782608695652, 'mean_word_length': 3.6877729257641922, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1170422', 'n_tokens_mistral': 1994, 'n_tokens_neox': 1950, 'n_words': 435}