def test_pause_and_resume_recurring_payment_return_correct_keys( self, RecurringPayment, recurring_payment_data): recurring_payment = recurring_payment_data recurring_payment = RecurringPayment.pause(id=recurring_payment.id, ) self.assert_returned_object_has_same_key_as_sample_response( recurring_payment, recurring_payment_response()) recurring_payment = RecurringPayment.resume(id=recurring_payment.id, ) self.assert_returned_object_has_same_key_as_sample_response( recurring_payment, recurring_payment_response())
def test_edit_recurring_payment_return_correct_keys(self, RecurringPayment): recurring_payment = RecurringPayment.edit_recurring_payment( id="5f059f3bfe20a578a49d8072", interval_count=2 ) self.assert_returned_object_has_same_key_as_sample_response( recurring_payment, recurring_payment_response() )
def test_pause_and_resume_recurring_payment_return_correct_keys( self, RecurringPayment ): recurring_payment = RecurringPayment.pause_recurring_payment( id="5f059f3bfe20a578a49d8072", ) self.assert_returned_object_has_same_key_as_sample_response( recurring_payment, recurring_payment_response() ) recurring_payment = RecurringPayment.resume_recurring_payment( id="5f059f3bfe20a578a49d8072", ) self.assert_returned_object_has_same_key_as_sample_response( recurring_payment, recurring_payment_response() )
def test_edit_recurring_payment_return_correct_keys( self, RecurringPayment, recurring_payment_data): recurring_payment = recurring_payment_data recurring_payment = RecurringPayment.edit(id=recurring_payment.id, interval_count=2) self.assert_returned_object_has_same_key_as_sample_response( recurring_payment, recurring_payment_response())
def test_create_recurring_payment_return_correct_keys(self, RecurringPayment): recurring_payment = RecurringPayment.create_recurring_payment( external_id=f"recurring_{int(time.time())}", payer_email="*****@*****.**", description="Test Curring Payment", amount=100000, interval="MONTH", interval_count=1, ) self.assert_returned_object_has_same_key_as_sample_response( recurring_payment, recurring_payment_response() )
def default_recurring_payment_data(self): tested_class = RecurringPayment class_name = "RecurringPayment" method_name = "pause" http_method_name = "post" args = () kwargs = { "id": "mock_id-123", } params = (args, kwargs) url = f"/recurring_payments/{kwargs['id']}/pause!" expected_correct_result = recurring_payment_response() return (tested_class, class_name, method_name, http_method_name, url, params, expected_correct_result)
def default_recurring_payment_data(self): tested_class = RecurringPayment class_name = "RecurringPayment" method_name = "create" http_method_name = "post" args = () kwargs = { "external_id": "recurring_12345", "payer_email": "*****@*****.**", "description": "Test Curring Payment", "amount": 100000, "interval": "MONTH", "interval_count": 1, "x_idempotency_key": "test-idemp_123", } params = (args, kwargs) url = "/recurring_payments" expected_correct_result = recurring_payment_response() return (tested_class, class_name, method_name, http_method_name, url, params, expected_correct_result)
class TestPauseRecurringPayment(ModelBaseTest): @pytest.fixture def default_recurring_payment_data(self): tested_class = RecurringPayment class_name = "RecurringPayment" method_name = "pause" http_method_name = "post" args = () kwargs = { "id": "mock_id-123", } params = (args, kwargs) url = f"/recurring_payments/{kwargs['id']}/pause!" expected_correct_result = recurring_payment_response() return (tested_class, class_name, method_name, http_method_name, url, params, expected_correct_result) @pytest.fixture def api_requestor_request_data(self, default_recurring_payment_data): tested_class, class_name, method_name, http_method_name, url, params, _ = default_recurring_payment_data headers = {} body = {} return (tested_class, class_name, method_name, http_method_name, url, params, headers, body) @pytest.mark.parametrize("mock_correct_response", [recurring_payment_response()], indirect=True) def test_return_recurring_payment_on_correct_params( self, mocker, mock_correct_response, default_recurring_payment_data): self.run_success_return_test_on_xendit_instance( mocker, mock_correct_response, default_recurring_payment_data) def test_raise_xendit_error_on_response_error( self, mocker, mock_error_request_response, default_recurring_payment_data): self.run_raises_error_test_on_xendit_instance( mocker, mock_error_request_response, default_recurring_payment_data) @pytest.mark.parametrize("mock_correct_response", [recurring_payment_response()], indirect=True) def test_return_recurring_payment_on_correct_params_and_global_xendit( self, mocker, mock_correct_response, default_recurring_payment_data): self.run_success_return_test_on_global_config( mocker, mock_correct_response, default_recurring_payment_data) def test_raise_xendit_error_on_response_error_and_global_xendit( self, mocker, mock_error_request_response, default_recurring_payment_data): self.run_raises_error_test_on_global_config( mocker, mock_error_request_response, default_recurring_payment_data) @pytest.mark.parametrize("mock_correct_response", [recurring_payment_response()], indirect=True) def test_send_correct_request_to_api_requestor(self, mocker, mock_correct_response, api_requestor_request_data): self.run_send_correct_request_to_api_requestor( mocker, mock_correct_response, api_requestor_request_data)
def test_create_recurring_payment_return_correct_keys( self, recurring_payment_data): recurring_payment = recurring_payment_data self.assert_returned_object_has_same_key_as_sample_response( recurring_payment, recurring_payment_response())
class TestCreateRecurringPayment(ModelBaseTest): @pytest.fixture def default_recurring_payment_data(self): tested_class = RecurringPayment class_name = "RecurringPayment" method_name = "create" http_method_name = "post" args = () kwargs = { "external_id": "recurring_12345", "payer_email": "*****@*****.**", "description": "Test Curring Payment", "amount": 100000, "interval": "MONTH", "interval_count": 1, "x_idempotency_key": "test-idemp_123", } params = (args, kwargs) url = "/recurring_payments" expected_correct_result = recurring_payment_response() return (tested_class, class_name, method_name, http_method_name, url, params, expected_correct_result) @pytest.fixture def api_requestor_request_data(self, default_recurring_payment_data): tested_class, class_name, method_name, http_method_name, url, params, _ = default_recurring_payment_data headers = {"X-IDEMPOTENCY-KEY": "test-idemp_123"} body = { "external_id": "recurring_12345", "payer_email": "*****@*****.**", "description": "Test Curring Payment", "amount": 100000, "interval": "MONTH", "interval_count": 1, } return (tested_class, class_name, method_name, http_method_name, url, params, headers, body) @pytest.mark.parametrize("mock_correct_response", [recurring_payment_response()], indirect=True) def test_return_recurring_payment_on_correct_params( self, mocker, mock_correct_response, default_recurring_payment_data): self.run_success_return_test_on_xendit_instance( mocker, mock_correct_response, default_recurring_payment_data) def test_raise_xendit_error_on_response_error( self, mocker, mock_error_request_response, default_recurring_payment_data): self.run_raises_error_test_on_xendit_instance( mocker, mock_error_request_response, default_recurring_payment_data) @pytest.mark.parametrize("mock_correct_response", [recurring_payment_response()], indirect=True) def test_return_recurring_payment_on_correct_params_and_global_xendit( self, mocker, mock_correct_response, default_recurring_payment_data): self.run_success_return_test_on_global_config( mocker, mock_correct_response, default_recurring_payment_data) def test_raise_xendit_error_on_response_error_and_global_xendit( self, mocker, mock_error_request_response, default_recurring_payment_data): self.run_raises_error_test_on_global_config( mocker, mock_error_request_response, default_recurring_payment_data) @pytest.mark.parametrize("mock_correct_response", [recurring_payment_response()], indirect=True) def test_send_correct_request_to_api_requestor(self, mocker, mock_correct_response, api_requestor_request_data): self.run_send_correct_request_to_api_requestor( mocker, mock_correct_response, api_requestor_request_data)