99)
1010
1111from minos .common import (
12- MinosConfig ,
12+ MinosConfig , Config ,
1313)
1414from minos .networks import (
1515 BrokerMessageV1 ,
@@ -37,11 +37,12 @@ def test_is_subclass(self):
3737 self .assertTrue (issubclass (RabbitMQBrokerSubscriber , BrokerSubscriber ))
3838
3939 async def test_from_config (self ):
40- config = MinosConfig (CONFIG_FILE_PATH )
40+ config = Config (CONFIG_FILE_PATH )
41+ broker_config = config .get_interface_by_name ("broker" )["common" ]
4142 async with RabbitMQBrokerSubscriber .from_config (config , topics = {"foo" , "bar" }) as subscriber :
42- self .assertEqual (config . broker . host , subscriber .broker_host )
43- self .assertEqual (config . broker . port , subscriber .broker_port )
44- self .assertEqual (config .service . name , subscriber .group_id )
43+ self .assertEqual (broker_config [ " host" ] , subscriber .broker_host )
44+ self .assertEqual (broker_config [ " port" ] , subscriber .broker_port )
45+ self .assertEqual (config .get_name () , subscriber .group_id )
4546 self .assertEqual (False , subscriber .remove_topics_on_destroy )
4647 self .assertEqual ({"foo" , "bar" }, subscriber .topics )
4748
@@ -61,31 +62,33 @@ async def test_receive(self, connect_mock, mock_avro):
6162
6263class TestRabbitMQBrokerSubscriberBuilder (unittest .TestCase ):
6364 def setUp (self ) -> None :
64- self .config = MinosConfig (CONFIG_FILE_PATH )
65+ self .config = Config (CONFIG_FILE_PATH )
6566
6667 def test_with_config (self ):
6768 builder = RabbitMQBrokerSubscriberBuilder ().with_config (self .config )
69+ common_config = self .config .get_interface_by_name ("broker" )["common" ]
6870
6971 expected = {
70- "group_id" : self .config .service . name ,
71- "broker_host" : self . config . broker . host ,
72- "broker_port" : self . config . broker . port ,
72+ "group_id" : self .config .get_name () ,
73+ "broker_host" : common_config [ " host" ] ,
74+ "broker_port" : common_config [ " port" ] ,
7375 }
7476 self .assertEqual (expected , builder .kwargs )
7577
7678 def test_build (self ):
79+ common_config = self .config .get_interface_by_name ("broker" )["common" ]
7780 builder = RabbitMQBrokerSubscriberBuilder ().with_config (self .config ).with_topics ({"one" , "two" })
7881 subscriber = builder .build ()
7982
8083 self .assertIsInstance (subscriber , RabbitMQBrokerSubscriber )
8184 self .assertEqual ({"one" , "two" }, subscriber .topics )
82- self .assertEqual (self . config . broker . port , subscriber .broker_port )
83- self .assertEqual (self . config . broker . host , subscriber .broker_host )
85+ self .assertEqual (common_config [ "host" ] , subscriber .broker_host )
86+ self .assertEqual (common_config [ "port" ] , subscriber .broker_port )
8487
8588
8689class TestPostgreSqlQueuedRabbitMQBrokerSubscriberBuilder (unittest .TestCase ):
8790 def setUp (self ) -> None :
88- self .config = MinosConfig (CONFIG_FILE_PATH )
91+ self .config = Config (CONFIG_FILE_PATH )
8992
9093 def test_build (self ):
9194 builder = PostgreSqlQueuedRabbitMQBrokerSubscriberBuilder ().with_config (self .config ).with_topics ({"one" , "two" })
@@ -98,7 +101,7 @@ def test_build(self):
98101
99102class TestInMemoryQueuedRabbitMQBrokerSubscriberBuilder (unittest .TestCase ):
100103 def setUp (self ) -> None :
101- self .config = MinosConfig (CONFIG_FILE_PATH )
104+ self .config = Config (CONFIG_FILE_PATH )
102105
103106 def test_build (self ):
104107 builder = InMemoryQueuedRabbitMQBrokerSubscriberBuilder ().with_config (self .config ).with_topics ({"one" , "two" })
0 commit comments