# Path: APITaxi_models2/unittest/factories.py
# class CustomerFactory(BaseFactory):
#     class Meta:
#         model = Customer
# 
#     id = factory.Sequence(lambda n: 'CUSTOMER_%d' % n)
#     added_at = factory.LazyFunction(datetime.datetime.now)
#     added_by = factory.SubFactory(UserFactory)
#     added_via = 'api'
#     source = 'added_by'
#     phone_number = factory.Sequence(lambda n: '+336%09d' % n)


from APITaxi_models2.unittest.factories import CustomerFactory


class TestEditCustomers:
    def test_invalid(self, anonymous, operateur, moteur):
        # Login required
        resp = anonymous.client.put('/customers/xxx', json={})
        assert resp.status_code == 401

        # Permission denied
        resp = operateur.client.put('/customers/xxx', json={})
        assert resp.status_code == 403

        # No data
        resp = moteur.client.put('/customers/xxx', json={})
        assert resp.status_code == 400
        assert 'data' in resp.json['errors']

        # Empty data

# Path: APITaxi_models2/unittest/factories.py
# class CustomerFactory(BaseFactory):
#     class Meta:
#         model = Customer
# 
#     id = factory.Sequence(lambda n: 'CUSTOMER_%d' % n)
#     added_at = factory.LazyFunction(datetime.datetime.now)
#     added_by = factory.SubFactory(UserFactory)
#     added_via = 'api'
#     source = 'added_by'
#     phone_number = factory.Sequence(lambda n: '+336%09d' % n)


# Path: APITaxi2/tests/test_customers.py
from APITaxi_models2.unittest.factories import CustomerFactory



class TestEditCustomers:
    def test_invalid(self, anonymous, operateur, moteur):
        # Login required
        resp = anonymous.client.put('/customers/xxx', json={})
        assert resp.status_code == 401

        # Permission denied
        resp = operateur.client.put('/customers/xxx', json={})
        assert resp.status_code == 403

        # No data
        resp = moteur.client.put('/customers/xxx', json={})
        assert resp.status_code == 400
        assert 'data' in resp.json['errors']

        # Empty data

        resp = moteur.client.put('/customers/xxx', json={'data': []})