def test_required_fields_invalid_email_not_set(self): data = { 'total': 13.37, } globee_payment = GlobeePayment(payment_data=data) with self.assertRaises(ValidationError): globee_payment.check_required_fields()
def test_required_fields_invalid_total_not_set(self): data = { 'customer': { 'email': '*****@*****.**' }, } globee_payment = GlobeePayment(payment_data=data) with self.assertRaises(ValidationError): globee_payment.check_required_fields()
def test_required_fields_invalid_email(self): data = { 'total': 13.37, 'customer': { 'email': 'invalid_mail.com' }, } globee_payment = GlobeePayment(payment_data=data) with self.assertRaises(ValidationError): globee_payment.check_required_fields()
def test_update_payment_valid(self): data = { 'total': 13.37, 'currency': 'EUR', 'customer': { 'name': 'foobar', 'email': '*****@*****.**' }, } globee_payment = GlobeePayment(payment_data=data) self.assertTrue(globee_payment.check_required_fields()) self.assertIn("https://test.globee.com/", globee_payment.create_request()) custom_payment_id = "NEWID" custom_store_reference = "NEWSTOREREF" updated_data = { "custom_payment_id": custom_payment_id, "custom_store_reference": custom_store_reference, 'customer': { 'email': '*****@*****.**' }, } globee_payment.payment_data = updated_data response = globee_payment.update_payment_request() self.assertEqual(response['id'], globee_payment.payment_id) self.assertEqual(response['custom_payment_id'], custom_payment_id) self.assertEqual(response['custom_store_reference'], custom_store_reference)
def test_required_fields_valid(self): data = { 'total': 13.37, 'customer': { 'name': 'foobar', 'email': '*****@*****.**' }, } globee_payment = GlobeePayment(payment_data=data) self.assertTrue(globee_payment.check_required_fields())
def test_create_payment_invalid_key(self): data = { 'total': 13.37, 'customer': { 'name': 'foobar', 'email': '*****@*****.**' }, } globee_payment = GlobeePayment(payment_data=data) self.assertTrue(globee_payment.check_required_fields()) with self.assertRaises(ValidationError): globee_payment.create_request()
def test_create_payment_invalid_urls(self): data = { 'total': 13.37, 'customer': { 'email': '*****@*****.**' }, 'success_url': 'invalid-url', 'cancel_url': 'invalid-url', 'ipn_url': 'invalid-url', } globee_payment = GlobeePayment(payment_data=data) self.assertTrue(globee_payment.check_required_fields()) with self.assertRaises(ValidationError): globee_payment.create_request()
def test_create_payment_valid(self): data = { 'total': 13.37, 'currency': 'EUR', 'customer': { 'name': 'foobar', 'email': '*****@*****.**' }, } globee_payment = GlobeePayment(payment_data=data) self.assertTrue(globee_payment.check_required_fields()) self.assertIn("https://test.globee.com/", globee_payment.create_request()) self.assertIn("https://test.globee.com/", globee_payment.get_payment_url())
def test_get_payment_details_for_currency_valid(self): data = { 'total': 13.37, 'currency': 'EUR', 'customer': { 'name': 'foobar', 'email': '*****@*****.**' }, } globee_payment = GlobeePayment(payment_data=data) self.assertTrue(globee_payment.check_required_fields()) self.assertIn("https://test.globee.com/", globee_payment.create_request()) response = globee_payment.get_payment_currency_details("BTC") self.assertIsInstance(response, dict)
def test_update_payment_invalid_email_not_set(self): data = { 'total': 13.37, 'currency': 'EUR', 'customer': { 'name': 'foobar', 'email': '*****@*****.**' }, } globee_payment = GlobeePayment(payment_data=data) self.assertTrue(globee_payment.check_required_fields()) self.assertIn("https://test.globee.com/", globee_payment.create_request()) custom_payment_id = "NEWID" custom_store_reference = "NEWSTOREREF" updated_data = { "custom_payment_id": custom_payment_id, "custom_store_reference": custom_store_reference, } globee_payment.payment_data = updated_data with self.assertRaises(ValidationError): globee_payment.update_payment_request()
def test_create_payment_invalid_empty_data(self): globee_payment = GlobeePayment() with self.assertRaises(ValidationError): globee_payment.check_required_fields() with self.assertRaises(ValidationError): globee_payment.create_request()