Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alicflorez committed Feb 2, 2018
1 parent 4d22568 commit 0e2007a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
28 changes: 14 additions & 14 deletions tests/tests_depots.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ def test_get_depot():
}


def test_get_depot_application_pdf():
"""Test get_depot when the pdf is requested."""
with requests_mock.Mocker() as m:
api_response = open("tests/assets/get_depot_ok.json", "rb", encoding='utf8').read()
m.get('https://mydelivengo.laposte.fr/api/v2/depots/1814183', text=api_response)

api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
result = api.get_depot(1814183, print_pdf=True)

assert result == {"data": {"id": 1814183, "id_utilisateur": 22855, "date": "2018-01-15 14:57:51",
"num_coclico": "2205490", "num_siret": "",
"bordereaux": [{"id": 1727987, "numero": "0000000001",
"nb_pages": 2, "type": 35, "plis": []}]}
}
# def test_get_depot_application_pdf(): # TODO: find a depot with some plis
# """Test get_depot when the pdf is requested."""
# with requests_mock.Mocker() as m:
# api_response = open("tests/assets/get_depot_pdf_ok.json", "rb", encoding='utf8').read()
# m.get('https://mydelivengo.laposte.fr/api/v2/depots/1814183', text=api_response)
#
# api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
# result = api.get_depot(1814183, print_pdf=True)
#
# assert result == {"data": {"id": 1814183, "id_utilisateur": 22855, "date": "2018-01-15 14:57:51",
# "num_coclico": "2205490", "num_siret": "",
# "bordereaux": [{"id": 1727987, "numero": "0000000001",
# "nb_pages": 2, "type": 35, "plis": []}]}
# }


def test_get_depot_missing_parameter():
Expand Down
24 changes: 12 additions & 12 deletions tests/tests_plis.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ def test_get_plis_type_error():

# ------------------------------------------------------- get_pli ------------------------------------------------------

# def test_get_pli(): # TODO: anonymize PDF
# """Test get_pli when the pdf is requested."""
# with requests_mock.Mocker() as m:
# api_response = open("tests/assets/get_pli_pdf_ok.json", "rb", encoding='utf8').read()
# m.get('https://mydelivengo.laposte.fr/api/v2/plis/11437479', text=api_response)
#
# api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
# result = api.get_pli(11437479, print_pdf=True)
#
# # Check if 'id', 'plis' and 'documents_supports' are keys of result
# data_keys_set = set(result['data'].keys())
# assert {'id', 'documents_supports'}.issubset(data_keys_set)
def test_get_pli():
"""Test get_pli when the pdf is requested."""
with requests_mock.Mocker() as m:
api_response = open("tests/assets/get_pli_pdf_ok.json", "rb", encoding='utf8').read()
m.get('https://mydelivengo.laposte.fr/api/v2/plis/11437479', text=api_response)

api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
result = api.get_pli(11437479, print_pdf=True)

# Check if 'id', 'plis' and 'documents_supports' are keys of result
data_keys_set = set(result['data'].keys())
assert {'id', 'documents_supports'}.issubset(data_keys_set)


def test_get_pli_missing_parameter():
Expand Down

0 comments on commit 0e2007a

Please sign in to comment.