示例#1
0
def test_get_plis():
    """Test get_plis with a mock."""
    with requests_mock.Mocker() as m:
        api_response = open("pydelivengo/tests/assets/get_plis_ok.json",
                            "rb",
                            encoding='utf8').read()
        m.get('https://mydelivengo.laposte.fr/api/v2.4/plis',
              text=api_response)

        api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
        result = api.get_plis()

        assert 'data' in result.keys()

        # Check if there are some keys in the result
        data_keys_set = set(result['data'][0].keys())
        assert {'id', 'id_envoi', 'numero',
                'date_creation'}.issubset(data_keys_set)
示例#2
0
def test_get_plis_type_error():
    """Test get_plis when params is not a dictionary."""
    api = PyDelivengo(api_authorization='Loremipsumdolorsitametconsectetu')
    with pytest.raises(PyDelivengoTypeError):
        # noinspection PyTypeChecker
        api.get_plis(params='lolcatz')