def mock_hub() -> testing.MockHub: ''' mock the needed subs for the heist tests ''' # A fixture is required for asynchronous tests to access a mock_hub return helpers.mock_hub( subs=['heist.heist', 'roster', 'tunnel', 'artifact'])
def test__get_asyncssh_opt_autodetect(self, mocked_autodetect): ''' Test getting option from autodetect of target and config aren't available ''' mock_hub = helpers.mock_hub() mock_hub.OPT = {'heis': {}} target = {} result = asyncssh_tunnel._get_asyncssh_opt(mock_hub, target=target, option='username', default='default') assert result == 'autodetect'
def test__get_asyncssh_opt_target(self): ''' Test getting option from the target ''' mock_hub = helpers.mock_hub() mock_hub.OPT = {'heis': {'username', 'opt'}} target = {'username': '******'} result = asyncssh_tunnel._get_asyncssh_opt(mock_hub, target=target, option='username', default='default') assert result == 'target'
def test__get_asyncssh_opt_config(self): ''' Test getting option from the config if target isn't available ''' mock_hub = helpers.mock_hub() mock_hub.OPT = {'heis': {'username': '******'}} target = {} result = asyncssh_tunnel._get_asyncssh_opt(mock_hub, target=target, option='username', default='default') assert result == 'opt'
def test_start(self): mock_hub = helpers.mock_hub(['heis.heis']) heis.heis.init.start(mock_hub) mock_hub.pop.loop.start.assert_called_once() mock_hub.heis.init.run.assert_called_once()
def test_load_subs(self): mock_hub = helpers.mock_hub() heis.heis.init.load_subs(mock_hub) mock_hub.pop.sub.add.assert_any_call(dyne_name='rend') mock_hub.pop.sub.add.assert_any_call(dyne_name='roster') mock_hub.pop.sub.add.assert_any_call(dyne_name='tunnel')
def mock_hub() -> testing.MockHub: # A fixture is required for asynchronous tests to access a mock_hub return helpers.mock_hub(subs=['heis.heis', 'heis.roster'])
def mock_hub(): # A fixture is required for asynchronous tests to access a mock_hub return helpers.mock_hub( subs=['heis.heis', 'heis.roster', 'rend', 'output'])
def mock_hub(): ''' mock the needed subs for the flat roster tests ''' # A fixture is required for asynchronous tests to access a mock_hub return helpers.mock_hub(subs=['heist.heist', 'heist.roster', 'rend', 'output'])