This commit is contained in:
parent
2a95eb392a
commit
e65d48b334
19
test.py
19
test.py
@ -9,7 +9,7 @@ import consumerlocator
|
|||||||
import communicator
|
import communicator
|
||||||
import messagesender
|
import messagesender
|
||||||
import redisconnector
|
import redisconnector
|
||||||
|
from pytest_redis import factories
|
||||||
|
|
||||||
__author__ = "@tormakris"
|
__author__ = "@tormakris"
|
||||||
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
|
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
|
||||||
@ -17,7 +17,7 @@ __module_name__ = "test"
|
|||||||
__version__text__ = "1"
|
__version__text__ = "1"
|
||||||
|
|
||||||
generateduuid = 'c959ad81-58f9-4445-aab4-8f3d68aee1ad'
|
generateduuid = 'c959ad81-58f9-4445-aab4-8f3d68aee1ad'
|
||||||
|
redis_db = factories.redisdb(port=6379)
|
||||||
|
|
||||||
def test_generate_string(mocker):
|
def test_generate_string(mocker):
|
||||||
"""
|
"""
|
||||||
@ -178,11 +178,12 @@ def test_setcurrentconsumer():
|
|||||||
assert comm.currenctconsumer == "10.69.42.1"
|
assert comm.currenctconsumer == "10.69.42.1"
|
||||||
|
|
||||||
|
|
||||||
def test_learnconsumerlist(httpserver):
|
def test_learnconsumerlist(httpserver, redis_db):
|
||||||
"""
|
"""
|
||||||
Tests :func:`consumerlocator.ConsumerLocator.learnconsumerlist`
|
Tests :func:`consumerlocator.ConsumerLocator.learnconsumerlist`
|
||||||
|
|
||||||
:param httpserver: simple HTTP server
|
:param httpserver: simple HTTP server
|
||||||
|
:param redis_db: mock redis
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
httpserver.expect_request(
|
httpserver.expect_request(
|
||||||
@ -203,11 +204,12 @@ def test_learnconsumerlist(httpserver):
|
|||||||
assert ret is None
|
assert ret is None
|
||||||
|
|
||||||
|
|
||||||
def test_getcurrentconsumer(mocker):
|
def test_getcurrentconsumer(mocker, redis_db):
|
||||||
"""
|
"""
|
||||||
Tests :func:`consumerlocator.ConsumerLocator.getcurrentconsumer`
|
Tests :func:`consumerlocator.ConsumerLocator.getcurrentconsumer`
|
||||||
|
|
||||||
:param mocker: patches the :class:`communicator.Communicator`.
|
:param mocker: patches the :class:`communicator.Communicator`.
|
||||||
|
:param redis_db: mock redis
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
mocker.patch('communicator.Communicator')
|
mocker.patch('communicator.Communicator')
|
||||||
@ -220,11 +222,12 @@ def test_getcurrentconsumer(mocker):
|
|||||||
assert locator.getcurrentconsumer() == consumerlocator.KNOWNCONSUMER
|
assert locator.getcurrentconsumer() == consumerlocator.KNOWNCONSUMER
|
||||||
|
|
||||||
|
|
||||||
def test_checkcurrentconsumer(httpserver):
|
def test_checkcurrentconsumer(httpserver, redis_db):
|
||||||
"""
|
"""
|
||||||
Tests :func:`consumerlocator.ConsumerLocator.checkcurrentconsumer`
|
Tests :func:`consumerlocator.ConsumerLocator.checkcurrentconsumer`
|
||||||
|
|
||||||
:param httpserver: simple HTTP server
|
:param httpserver: simple HTTP server
|
||||||
|
:param redis_db: mock redis
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
httpserver.expect_oneshot_request(
|
httpserver.expect_oneshot_request(
|
||||||
@ -245,11 +248,12 @@ def test_checkcurrentconsumer(httpserver):
|
|||||||
assert ret == True
|
assert ret == True
|
||||||
|
|
||||||
|
|
||||||
def test_updateconsumer(httpserver):
|
def test_updateconsumer(httpserver, redis_db):
|
||||||
"""
|
"""
|
||||||
Tests :func:`consumerlocator.ConsumerLocator.updateconsumer`
|
Tests :func:`consumerlocator.ConsumerLocator.updateconsumer`
|
||||||
|
|
||||||
:param httpserver: simple HTTP server
|
:param httpserver: simple HTTP server
|
||||||
|
:param redis_db: mock redis
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
httpserver.expect_oneshot_request(
|
httpserver.expect_oneshot_request(
|
||||||
@ -271,11 +275,12 @@ def test_updateconsumer(httpserver):
|
|||||||
assert ret == f"127.0.0.1:{port}"
|
assert ret == f"127.0.0.1:{port}"
|
||||||
|
|
||||||
|
|
||||||
def test_updateconsumerlist(httpserver):
|
def test_updateconsumerlist(httpserver, redis_db):
|
||||||
"""
|
"""
|
||||||
Tests :func:`consumerlocator.ConsumerLocator.updateconsumerlist`
|
Tests :func:`consumerlocator.ConsumerLocator.updateconsumerlist`
|
||||||
|
|
||||||
:param httpserver: simple HTTP server
|
:param httpserver: simple HTTP server
|
||||||
|
:param redis_db: mock redis
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
httpserver.expect_oneshot_request(
|
httpserver.expect_oneshot_request(
|
||||||
|
Reference in New Issue
Block a user