Compare commits

...

2 Commits

Author SHA1 Message Date
c5a3fb2d04
fix unit tests
All checks were successful
continuous-integration/drone/push Build is passing
2020-04-29 12:31:33 +02:00
22ebf01e20
fix some tests 2020-04-29 12:16:27 +02:00
4 changed files with 11 additions and 5 deletions

View File

@ -15,9 +15,11 @@ steps:
- name: unit_test - name: unit_test
image: python:3.8 image: python:3.8
environment:
PRODUCER_REDIS: cache
commands: commands:
- pip3 install -r requirements.txt - pip3 install -r requirements.txt
- echo -e 'pytest test.py' - pytest test.py
- name: build-app - name: build-app
image: banzaicloud/drone-kaniko image: banzaicloud/drone-kaniko
@ -75,6 +77,8 @@ services:
volumes: volumes:
- name: dockersock - name: dockersock
path: /var/run path: /var/run
- name: cache
image: redis
volumes: volumes:
- name: dockersock - name: dockersock

View File

@ -16,6 +16,7 @@ __version__text__ = "1"
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
class Communicator: class Communicator:
""" """
Class handling low level communication with consumers. Class handling low level communication with consumers.

View File

@ -18,6 +18,7 @@ __version__text__ = "1"
KNOWNCONSUMER = os.getenv("PRODUCER_KNOWNCONSUMER", '10.69.42.1') KNOWNCONSUMER = os.getenv("PRODUCER_KNOWNCONSUMER", '10.69.42.1')
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
class ConsumerLocator: class ConsumerLocator:
""" """

View File

@ -17,8 +17,8 @@ __module_name__ = "test"
__version__text__ = "1" __version__text__ = "1"
generateduuid = 'c959ad81-58f9-4445-aab4-8f3d68aee1ad' generateduuid = 'c959ad81-58f9-4445-aab4-8f3d68aee1ad'
redis_proc = factories.redis_proc(port=6379) redis_proc = factories.redis_proc(host='cache', port=6379)
redis_db = factories.redisdb('redis_db') redis_db = factories.redisdb('redis_nooproc')
def test_generate_string(mocker): def test_generate_string(mocker):
@ -31,7 +31,7 @@ def test_generate_string(mocker):
comm = communicator.Communicator( comm = communicator.Communicator(
currentconsumer="localhost", currentconsumer="localhost",
uuid=generateduuid) uuid=generateduuid)
mess = messagesender.MessageSender(communicator=comm, uuid=generateduuid) mess = messagesender.MessageSender(communicator=comm, uuid=generateduuid)
msg = mess.randomstring(stringlength=32) msg = mess.randomstring(stringlength=32)
assert isinstance(msg, str) assert isinstance(msg, str)
assert len(msg) == 32 assert len(msg) == 32
@ -71,7 +71,7 @@ def test_send_message(mocker):
comm = communicator.Communicator( comm = communicator.Communicator(
currentconsumer="127.0.0.1", currentconsumer="127.0.0.1",
uuid=generateduuid) uuid=generateduuid)
mess = messagesender.MessageSender(communicator=comm, uuid=generateduuid) mess = messagesender.MessageSender(communicator=comm, uuid=generateduuid)
messa = "SENDING" messa = "SENDING"
msg = mess.sendmessage(message=messa) msg = mess.sendmessage(message=messa)
assert msg is None assert msg is None