class ClientTests(object): @pytest.mark.parametrize("data", [ CLIENT_CREATE, factories.ClientFactory().get_raw_data(), ]) def test_create_refresh_client_sandbox(self, api_client, data): item = api_client.clients.create(**data) assert item item.get() log.debug("id: %s", item.id) assert item.id def test_client_create_invoice(self, mocker): invoices_create = mocker.patch('fakturownia.endpoints.Invoices.create') client = factories.ClientFactory(id=777) client.create_invoice() assert invoices_create.called def test_client_create_invoice_no_id(self, ): client = factories.ClientFactory() with pytest.raises(AssertionError): client.create_invoice() # noinspection PyShadowingNames @pytest.mark.parametrize("data", [ CLIENT_CREATE, factories.ClientFactory().get_raw_data(), ]) def test_client_create_invoice_sandbox(self, api_client, data, existing_product_id): client = api_client.clients.create(**data) invoice = client.create_invoice(positions=[{ 'product_id': existing_product_id, 'quantity': 100 }]) invoice.get() log.debug("id: %s", client.id) assert invoice.id assert invoice.payment_url def test_get_client(self, api_client): with pytest.raises(HttpException, match='404 Client Error: Not Found for url') as ex: # noinspection PyStatementEffect api_client.clients[123] assert ex.value.status_code == 404 # noinspection PyShadowingNames def test_invalid_data(self, client_raw_data): api = MagicMock() api.return_value = {} client = endpoints.Client(api, **client_raw_data) client.put() data = api.put.call_args[1]['data'] assert 'balance' not in data
def test_client_create_invoice_no_id(self, ): client = factories.ClientFactory() with pytest.raises(AssertionError): client.create_invoice()
def test_client_create_invoice(self, mocker): invoices_create = mocker.patch('fakturownia.endpoints.Invoices.create') client = factories.ClientFactory(id=777) client.create_invoice() assert invoices_create.called
# noinspection PyUnresolvedReferences CLIENT_CREATE = test_data.CLIENT_CREATE # noinspection PyUnresolvedReferences INVOICE_CREATE = test_data.INVOICE_CREATE @pytest.fixture(params=["invoices", "clients"]) def endpoint(request, offline_client): return getattr(offline_client, request.param) # noinspection PyUnresolvedReferences @pytest.fixture(params=[ test_data.CLIENT_GET, factories.ClientFactory().get_raw_data(), ]) def client_raw_data(request): return request.param @pytest.fixture def existing_product_id(secrets): if 'FAKTUROWNIA_EXISTING_PRODUCT_ID' not in secrets: pytest.skip( 'Requires an environment FAKTUROWNIA_EXISTING_PRODUCT_ID setting') return secrets['FAKTUROWNIA_EXISTING_PRODUCT_ID'] # noinspection PyShadowingNames def test_create_invoice(endpoint, mocker):