def create_paystack_customer(sender, instance, *args, **kwargs): customer = Customer.create( first_name=instance.first_name, last_name=instance.last_name, email=instance.email, phone=instance.phone, )
def test_update(self): """Function defined to test paystackapi customer update.""" httpretty.register_uri( httpretty.PUT, "https://api.paystack.co/customer/4013", content_type='text/json', body='{"status": true, "contributors": true}', status=201, ) response = Customer.update(customer_id=4013, first_name='andela') self.assertEqual(response['status'], True)
def test_list(self): """Function defined to test paystackapi customer list method.""" httpretty.register_uri( httpretty.GET, "https://api.paystack.co/customer", content_type='text/json', body='{"status": true, "contributors": true}', status=201, ) response = Customer.list() self.assertEqual(response['status'], True)
def test_update(self): """Function defined to test paystackapi customer update.""" httpretty.register_uri( httpretty.PUT, self.endpoint_url("/customer/4013"), content_type='text/json', body='{"status": true, "contributors": true}', status=201, ) response = Customer.update(customer_id=4013, first_name='andela') self.assertEqual(response['status'], True)
def test_list(self): """Function defined to test paystackapi customer list method.""" httpretty.register_uri( httpretty.GET, self.endpoint_url("/customer"), content_type='text/json', body='{"status": true, "contributors": true}', status=201, ) response = Customer.list() self.assertEqual(response['status'], True)
def test_get(self): """Function defined to test Customer get method.""" httpretty.register_uri( httpretty.GET, self.endpoint_url("/customer/4013"), content_type='text/json', body='{"status": true, "contributors": true}', status=201, ) response = Customer.get(customer_id=4013) self.assertEqual(response['status'], True)
def test_create(self): """Method defined to test customer creation.""" httpretty.register_uri( httpretty.POST, "https://api.paystack.co/customer", content_type='text/json', body='{"status": true, "contributors": true}', status=201, ) response = Customer.create( first_name='samuel', last_name='james', email='*****@*****.**', phone='00000000000') self.assertTrue(response['status'])
def test_create(self): """Method defined to test customer creation.""" httpretty.register_uri( httpretty.POST, self.endpoint_url("/customer"), content_type='text/json', body='{"status": true, "contributors": true}', status=201, ) response = Customer.create(first_name='samuel', last_name='james', email='*****@*****.**', phone='00000000000') self.assertTrue(response['status'])
def test_update(self): """Function defined to test paystackapi customer update.""" with mock.patch('paystackapi.customer.Customer.update') as mock_update: mock_update.return_value = { 'status': True, 'message': 'Customer updated', 'data': {'customer_code': 'CUS_jemg85nfijhrp1s', 'first_name': 'andela', 'last_name': 'james', 'domain': 'test', 'id': 4013, 'phone': '08030495860', 'updatedAt': '2016-02-12T14:28:25.000Z', 'integration': 100384, 'email': '*****@*****.**', 'createdAt': '2016-02-12T12:25:19.000Z', 'metadata': None} } response = Customer.update(4013, 'andela') self.assertEqual(response['status'], True)
def test_create(self): """Method defined to test customer creation.""" with mock.patch('paystackapi.customer.Customer.create') as mock_create: mock_create.return_value = { 'status': True, 'message': 'Customer created', 'data': {'customer_code': 'CUS_jemg85nfijhrp1s', 'first_name': 'samuel', 'last_name': 'james', 'domain': 'test', 'integration': 100384, 'phone': '00000000000', 'updatedAt': '2016-02-12T12:25:19.960Z', 'id': 4013, 'email': '*****@*****.**', 'createdAt': '2016-02-12T12:25:19.960Z'} } response = Customer.create( 'samuel', 'james', '*****@*****.**', '00000000000') self.assertTrue(response['status'])
def test_list(self): """Function defined to test paystackapi customer list method.""" with mock.patch('paystackapi.customer.Customer.list') as mock_list: mock_list.return_value = { 'status': True, 'message': 'Customers retrieved', 'meta': {'skipped': 0, 'total': 1, 'page': 1, 'perPage': 50, 'pageCount': 1}, 'data': [{'customer_code': 'CUS_jemg85nfijhrp1s', 'first_name': 'samuel', 'last_name': 'james', 'integration': 100384, 'id': 4013, 'phone': '08030495860', 'domain': 'test', 'updatedAt': '2016-02-12T12:25:19.000Z', 'email': '*****@*****.**', 'createdAt': '2016-02-12T12:25:19.000Z', 'metadata': None}] } response = Customer.list() self.assertEqual(response['status'], True)
def test_get(self): """Function defined to test Customer get method.""" with mock.patch('paystackapi.customer.Customer.get') as mock_get: mock_get.return_value = { 'status': True, 'message': 'Customer retrieved', 'data': {'total_transactions': 0, 'customer_code': 'CUS_jemg85nfijhrp1s', 'first_name': 'samuel', 'last_name': 'james', 'authorizations': [], 'total_transaction_value': 0, 'subscriptions': [], 'transactions': [], 'domain': 'test', 'id': 4013, 'phone': '00000000000', 'updatedAt': '2016-02-12T12:25:19.000Z', 'integration': 100384, 'email': '*****@*****.**', 'createdAt': '2016-02-12T12:25:19.000Z', 'metadata': None} } response = Customer.get(4013) self.assertEqual(response['status'], True)