Skip to content

Commit

Permalink
fix some tests type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
Gal Ben David committed Apr 4, 2022
1 parent eca9968 commit c99c768
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 32 deletions.
24 changes: 18 additions & 6 deletions tests/broker/test_broker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import tempfile
import time
import typing
import unittest
import unittest.mock

Expand All @@ -9,7 +10,13 @@
import sergeant.objects


class BrokerTestCase:
class BrokerTestCase(
unittest.TestCase,
):
__test__ = False

test_broker: sergeant.broker.Broker
test_brokers: typing.List[sergeant.broker.Broker]
tasks = [
sergeant.objects.Task(
kwargs={
Expand Down Expand Up @@ -567,8 +574,9 @@ def test_lock(

class RedisSingleServerBrokerTestCase(
BrokerTestCase,
unittest.TestCase,
):
__test__ = True

@classmethod
def setUpClass(
cls,
Expand Down Expand Up @@ -613,8 +621,9 @@ def setUpClass(

class RedisMultipleServerBrokerTestCase(
BrokerTestCase,
unittest.TestCase,
):
__test__ = True

@classmethod
def setUpClass(
cls,
Expand Down Expand Up @@ -665,8 +674,9 @@ def setUpClass(

class MongoSingleServerConnectorTestCase(
BrokerTestCase,
unittest.TestCase,
):
__test__ = True

@classmethod
def setUpClass(
cls,
Expand Down Expand Up @@ -710,8 +720,9 @@ def setUpClass(

class MongoMultipleServersConnectorTestCase(
BrokerTestCase,
unittest.TestCase,
):
__test__ = True

@classmethod
def setUpClass(
cls,
Expand Down Expand Up @@ -760,8 +771,9 @@ def setUpClass(

class LocalBrokerTestCase(
BrokerTestCase,
unittest.TestCase,
):
__test__ = True

@classmethod
def setUpClass(
cls,
Expand Down
22 changes: 16 additions & 6 deletions tests/connector/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import sergeant.connector


class ConnectorTestCase:
class ConnectorTestCase(
unittest.TestCase,
):
__test__ = False

connector: sergeant.connector._connector.Connector
test_queue_name = 'test_queue_name'
test_queue_item = b'test_queue_item'
test_queue_items = [
Expand Down Expand Up @@ -668,8 +673,9 @@ def test_queue_consumable(

class RedisSingleServerConnectorTestCase(
ConnectorTestCase,
unittest.TestCase,
):
__test__ = True

def setUp(
self,
):
Expand All @@ -687,8 +693,9 @@ def setUp(

class RedisMultipleServersConnectorTestCase(
ConnectorTestCase,
unittest.TestCase,
):
__test__ = True

def setUp(
self,
):
Expand All @@ -712,8 +719,9 @@ def setUp(

class MongoSingleServerConnectorTestCase(
ConnectorTestCase,
unittest.TestCase,
):
__test__ = True

def setUp(
self,
):
Expand All @@ -730,8 +738,9 @@ def setUp(

class MongoMultipleServersConnectorTestCase(
ConnectorTestCase,
unittest.TestCase,
):
__test__ = True

def setUp(
self,
):
Expand All @@ -753,8 +762,9 @@ def setUp(

class LocalConnectorTestCase(
ConnectorTestCase,
unittest.TestCase,
):
__test__ = True

def setUp(
self,
):
Expand Down
25 changes: 5 additions & 20 deletions tests/worker/test_initializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import unittest
import unittest.mock

import sergeant.broker
import sergeant.config
import sergeant.connector
import sergeant.encoder
import sergeant.logging
import sergeant.worker


Expand All @@ -13,10 +18,6 @@ def test_init_logger(
worker = sergeant.worker.Worker()
worker.config = sergeant.config.WorkerConfig(
name='some_worker',
connector=sergeant.config.Connector(
type='',
params={},
),
)

worker.init_logger()
Expand All @@ -26,10 +27,6 @@ def test_init_logger(

worker.config = sergeant.config.WorkerConfig(
name='some_worker',
connector=sergeant.config.Connector(
type='',
params={},
),
logging=sergeant.config.Logging(
handlers=[
sergeant.logging.logstash.LogstashHandler(
Expand Down Expand Up @@ -214,10 +211,6 @@ def test_init_executor(
worker = sergeant.worker.Worker()
worker.config = sergeant.config.WorkerConfig(
name='some_worker',
connector=sergeant.config.Connector(
type='',
params={},
),
)
worker.init_executor()
self.assertIsInstance(
Expand All @@ -227,10 +220,6 @@ def test_init_executor(

worker.config = sergeant.config.WorkerConfig(
name='some_worker',
connector=sergeant.config.Connector(
type='',
params={},
),
number_of_threads=1,
)
worker.init_executor()
Expand All @@ -241,10 +230,6 @@ def test_init_executor(

worker.config = sergeant.config.WorkerConfig(
name='some_worker',
connector=sergeant.config.Connector(
type='',
params={},
),
number_of_threads=2,
)
worker.init_executor()
Expand Down

0 comments on commit c99c768

Please sign in to comment.