def test_service_list_replace_from_decription(): expected = [ BaseService(name='ReplacedService', hosts_list=['replaced_host.local']), WhitelistService(name='WhitelistService', hosts_list=['whitelist_me.local']), ] service_list = ServiceList([ BaseService(name='OriginalService', hosts_list=['original_host.local']), ]) service_list.replace_from_descrition([{ 'type': 'BaseService', 'name': 'ReplacedService', 'hosts_list': ['replaced_host.local'], }, { 'type': 'WhitelistService', 'name': 'WhitelistService', 'hosts_list': ['whitelist_me.local'], }]) assert list(service_list) == expected
def dispatcher(scenarios_dir) -> Dispatcher: return Dispatcher(service_list=[ BaseService( name='TestServiceA', hosts_list=['host_a.local'], ), BaseService( name='TestServiceB', hosts_list=['host_b.local'], ), ], )
def test_service_list_prepend(): expected = [ BaseService(name='Service', hosts_list=['host.local']), WhitelistService(name='WhitelistService', hosts_list=['whitelist_me.local']), ] service_list = ServiceList([ WhitelistService(name='WhitelistService', hosts_list=['whitelist_me.local']), ]) service_list.prepend(BaseService(name='Service', hosts_list=['host.local'])) assert list(service_list) == expected
def service(): test_service = BaseService( name='TestService', hosts_list=['host_a.local', 'host_b.local'], ) test_service.set_active_scenario('test_scenario') return test_service
def dispatcher() -> Dispatcher: return Dispatcher(service_list=[ BaseService( name='TestService', hosts_list=['test-service.local'], ), ], )
def management_service() -> ManagementService: mgmt_service = ManagementService( ServiceList([ BaseService(name='TestService', hosts_list=['test-service.local']), ])) mgmt_service.config = { 'active_scenario': None, 'a_setting': 'value', } return mgmt_service
def test_service_list_to_dict(): service_list = ServiceList([ BaseService(name='TestName', hosts_list=['test_host.local', 'test_host2.local']), WhitelistService(name='TestWhitelist', hosts_list=['test_host.local']), ]) expected_description = [ { 'type': 'BaseService', 'name': 'TestName', 'hosts_list': ['test_host.local', 'test_host2.local'], }, { 'type': 'WhitelistService', 'name': 'TestWhitelist', 'hosts_list': ['test_host.local'], }, ] result_service = service_list.to_list() assert expected_description == result_service
]) service_list.prepend(BaseService(name='Service', hosts_list=['host.local'])) assert list(service_list) == expected @mark.parametrize('service_description, expected_service', [ ( { 'type': 'BaseService', 'name': 'TestName', 'hosts_list': ['test_host.local', 'test_host2.local'], }, BaseService(name='TestName', hosts_list=['test_host.local', 'test_host2.local']), ), ( { 'name': 'TestName', 'hosts_list': ['test_host.local'], }, BaseService(name='TestName', hosts_list=['test_host.local']), ), ( { 'type': 'WhitelistService', 'name': 'TestWhitelist', 'hosts_list': ['test_host.local'], }, WhitelistService(name='TestWhitelist', hosts_list=['test_host.local']),