2018-01-27 19:52:27 +01:00
|
|
|
from __future__ import unicode_literals
|
2014-04-24 14:01:53 +02:00
|
|
|
import pytest
|
2018-01-27 19:52:27 +01:00
|
|
|
import sys
|
2014-04-24 14:01:53 +02:00
|
|
|
|
|
|
|
|
from pyhamtools.lookuplib import LookupLib
|
|
|
|
|
from pyhamtools.exceptions import APIKeyMissingError
|
|
|
|
|
|
2018-01-27 19:52:27 +01:00
|
|
|
if sys.version_info.major == 3:
|
|
|
|
|
unicode = str
|
2014-04-24 14:01:53 +02:00
|
|
|
|
|
|
|
|
@pytest.fixture(scope="function", params=[5, -5, "", "foo bar", 11.5, {}, [], None, ("foo", "bar")])
|
|
|
|
|
def fixAnyValue(request):
|
|
|
|
|
return request.param
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestlookupLib:
|
2014-04-25 23:46:44 +02:00
|
|
|
|
|
|
|
|
|
2014-04-24 14:01:53 +02:00
|
|
|
def test_construction_with_invalid_kwargs(self, fixAnyValue):
|
|
|
|
|
"""Load with non without any args & kwargs"""
|
|
|
|
|
with pytest.raises(AttributeError):
|
|
|
|
|
LookupLib(fixAnyValue)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestlookupLibHelper:
|
2018-01-27 19:52:27 +01:00
|
|
|
|
2014-04-24 14:01:53 +02:00
|
|
|
# def test_checkApiKeyValidity(self, fixClublogApi, fixApiKey):
|
|
|
|
|
#
|
|
|
|
|
# with pytest.raises(AttributeError):
|
|
|
|
|
# fixClublogApi._checkApiKeyValidity()
|
|
|
|
|
#
|
|
|
|
|
# with pytest.raises(ValueError):
|
|
|
|
|
# fixClublogApi._checkApiKeyValidity(apikey="")
|
|
|
|
|
#
|
|
|
|
|
# assert fixClublogApi._checkApiKeyValidity(apikey=fixApiKey) is True
|
2018-01-27 19:52:27 +01:00
|
|
|
|
|
|
|
|
|
2014-04-24 14:01:53 +02:00
|
|
|
def test_generateRandomWord(self, fixClublogApi, fixNonUnsignedInteger):
|
2018-01-27 19:52:27 +01:00
|
|
|
|
2014-04-24 14:01:53 +02:00
|
|
|
with pytest.raises(TypeError):
|
|
|
|
|
fixClublogApi._generate_random_word()
|
|
|
|
|
|
2018-01-27 19:52:27 +01:00
|
|
|
assert type(fixClublogApi._generate_random_word(5)) is unicode
|
2014-04-24 14:01:53 +02:00
|
|
|
assert len(fixClublogApi._generate_random_word(5)) is 5
|