class PersonWrapperTestCase(LocalImopayTestCase): def setUp(self): self.client = ImopayWrapper().person def test_model(self): self.assertEqual(self.client.model, Person) def test_action(self): self.assertEqual(self.client.action, "persons") def test_search(self): cpf = "foo" expected_data = {"cpf": cpf} expected_url = self.client._construct_url(action=self.client.action, subaction="search") with patch("imopay_wrapper.wrapper.base.BaseImopayWrapper._post" ) as mocked_post: self.client.search(cpf) mocked_post.assert_called_once_with(expected_url, expected_data)
class CompanyWrapperTestCase(LocalImopayTestCase): def setUp(self): self.client = ImopayWrapper().company def test_model(self): self.assertEqual(self.client.model, Company) def test_action(self): self.assertEqual(self.client.action, "companies") def test_search(self): cnpj = "foo" expected_data = {"cnpj": cnpj} expected_url = self.client._construct_url(action=self.client.action, subaction="search") with patch("imopay_wrapper.wrapper.base.BaseImopayWrapper._post" ) as mocked_post: self.client.search(cnpj) mocked_post.assert_called_once_with(expected_url, expected_data)
def setUp(self): self.client = ImopayWrapper().address
class AddressWrapperTestCase(LocalImopayTestCase): def setUp(self): self.client = ImopayWrapper().address def test_mixins(self): """ Dado: - um client ImopayWrapper().address Quando: - N/A Então: - client deve ser uma instância de CreateMixin, RetrieveMixin, DestroyMixin, GetByDocumentMixin """ mixins = (CreateMixin, RetrieveMixin, GetByDocumentMixin) for mixin in mixins: self.assertIsInstance(self.client, mixin) def test_model(self): self.assertEqual(self.client.model, Address) def test_action(self): self.assertEqual(self.client.action, "addresses") def test_create(self): with patch( "imopay_wrapper.wrapper.address.AddressWrapper.model", new_callable=PropertyMock, ) as mocked_model, patch( "imopay_wrapper.wrapper.address.AddressWrapper.action", new_callable=PropertyMock, ) as mocked_action, patch( "imopay_wrapper.wrapper.address.AddressWrapper._post" ) as mocked_post: self.client.create({}) mocked_model.assert_called_once() mocked_action.assert_called_once() mocked_post.assert_called_once_with( self.client._construct_url(action=mocked_action.return_value, subaction="create_by_name_and_uf"), mocked_model.return_value.return_value.to_dict.return_value, ) def test_update(self): with patch( "imopay_wrapper.wrapper.address.AddressWrapper.model", new_callable=PropertyMock, ) as mocked_model, patch( "imopay_wrapper.wrapper.address.AddressWrapper.action", new_callable=PropertyMock, ) as mocked_action, patch( "imopay_wrapper.wrapper.address.AddressWrapper._patch" ) as mocked_post: self.client.update("foo", {}) mocked_model.assert_called_once() mocked_action.assert_called_once() mocked_post.assert_called_once_with( self.client._construct_url( action=mocked_action.return_value, subaction="update_by_name_and_uf", identifier="foo", ), mocked_model.return_value.return_value.to_dict.return_value, ) def test_get_by_document(self): with patch( "imopay_wrapper.wrapper.address.AddressWrapper.action", new_callable=PropertyMock, ) as mocked_action, patch( "imopay_wrapper.wrapper.address.AddressWrapper._post" ) as mocked_post: self.client.get_by_document("foo") mocked_action.assert_called_once() expected_data = {"cpf_cnpj": "foo"} mocked_post.assert_called_once_with( self.client._construct_url(action=mocked_action.return_value, subaction="get_by_document"), expected_data, )
def setUp(self): self.client = ImopayWrapper().person
from imopay_wrapper import ImopayWrapper client = ImopayWrapper() data = { "email": "*****@*****.**", "phone": "+55 74 99572 8196", "cnpj": "13415795551619", "opening_date": "1909-02-05", "social_name": "Hardy, Mann and Whitehead", "commercial_name": "maximize distributed deliverables", "website": "https://horton-black.info/", } response = client.company.create(data) print(response.data)
def setUp(self): self.client = ImopayWrapper().transaction
class TransactionWrapperTestCase(LocalImopayTestCase): def setUp(self): self.client = ImopayWrapper().transaction def test_action(self): self.assertEqual(self.client.action, "transactions") def test_create_invoice(self): expected_data = { "payer": "1", "receiver": "2", "reference_id": "3", "amount": 4, "description": "5", "payment_method": { "expiration_date": today(), "limit_date": tomorrow(), "configurations": { "fine": { "value": 1, "charge_type": BaseConfiguration.FIXED, }, "interest": { "value": 1, "charge_type": BaseConfiguration.DAILY_FIXED, }, "discounts": [{ "value": 1, "charge_type": BaseConfiguration.FIXED, "date": today(), }], }, }, } expected_url = self.client._construct_url( action=self.client.action, subaction="create_invoice_transaction") with patch("imopay_wrapper.wrapper.base.BaseImopayWrapper._post" ) as mocked_post: self.client.create_invoice({ "payer": "1", "receiver": "2", "reference_id": "3", "amount": "4", "description": "5", "payment_method": { "expiration_date": today(), "limit_date": tomorrow(), "configurations": { "fine": { "value": 1, "charge_type": BaseConfiguration.FIXED, }, "interest": { "value": 1, "charge_type": BaseConfiguration.DAILY_FIXED, }, "discounts": [{ "value": 1, "charge_type": BaseConfiguration.FIXED, "date": today(), }], }, }, }) mocked_post.assert_called_once_with(expected_url, expected_data)
def setUp(self): self.client = ImopayWrapper().bank_account
def setUp(self): self.client = ImopayWrapper().webhook
def setUp(self): self.client = ImopayWrapper().company