Skip to content

Commit

Permalink
chore: Parametrize creation_date in test_send_invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
pprzetacznik committed Dec 10, 2023
1 parent 188e637 commit dab3ae3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
3 changes: 0 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ def get_invoices(self, session_token, from_date=None, to_date=None):
)
if not to_date:
to_date = datetime.now()
date_format = "%Y-%m-%dT%H:%M:%S.%fZ"
from_string = from_date.strftime(date_format)
from_string = from_date.isoformat(timespec="milliseconds")
to_string = to_date.strftime(date_format)
to_string = datetime.now(self.config.TIMEZONE).isoformat(
timespec="milliseconds"
)
Expand Down
31 changes: 20 additions & 11 deletions test_ksef.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import datetime
from time import sleep
from json import dumps
from pytest import mark
from pytest import mark, fixture
from utils import format_xml


Expand Down Expand Up @@ -39,28 +40,36 @@ def test_init_session(config, service):
print(dumps(response, indent=4))


@mark.functional
@mark.e2e
def test_send_invoice(config, service):
response = service.init_session()
print(dumps(response, indent=4))
response_send_invoice = service.send_invoice(
vendor1={
@fixture
def invoice_data(config):
creation_date = datetime.now(config.TIMEZONE).isoformat(
timespec="milliseconds"
)
return {
"vendor1": {
"nip": config.KSEF_NIP,
"name": "Markosoft-owner Krakow Sp.z o.o.",
"address1": "ul. Bracka 11/12",
"address2": "40-100 Krakow",
"country_code": "PL",
},
vendor2={
"vendor2": {
"nip": 2222222222,
"name": "Markosoft3 Krakow Sp.z o.o.",
"address1": "ul. Bracka 11/12",
"address2": "40-100 Krakow",
"country_code": "PL",
},
invoice={"creation_date": "2023-11-24T15:19:25Z"},
)
"invoice": {"creation_date": creation_date},
}


@mark.functional
@mark.e2e
def test_send_invoice(config, service, invoice_data):
response = service.init_session()
print(dumps(response, indent=4))
response_send_invoice = service.send_invoice(**invoice_data)
print(response_send_invoice.status_code)
print(dumps(response_send_invoice.json(), indent=4))

Expand Down

0 comments on commit dab3ae3

Please sign in to comment.