def test_get_top_data(self): topfile = 'tests/unittests/resources/top.pulsar' def cp_cache_file(topfile): return topfile def match_compound(value): return value __salt__ = {} __salt__['cp.cache_file'] = cp_cache_file __salt__['match.compound'] = match_compound pulsar.__salt__ = __salt__ result = pulsar.get_top_data(topfile) pulsar.__salt__ = {} assert isinstance(result, list) assert result[0] == 'hubblestack_pulsar_config'
def test_get_top_data_for_CommandExecutionError(self): topfile = '/testfile' def cp_cache_file(topfile): return '/testfile' def match_compound(value): return value __salt__ = {} __salt__['cp.cache_file'] = cp_cache_file __salt__['match.compound'] = match_compound pulsar.__salt__ = __salt__ try: result = pulsar.get_top_data(topfile) pulsar.__salt__ = {} except CommandExecutionError: pass
def test_top_result_for_list(self): topfile = 'tests/unittests/resources/top.pulsar' def cp_cache_file(value): return 'tests/unittests/resources/top.pulsar' def match_compound(value): return value __salt__ = {} __salt__['cp.cache_file'] = cp_cache_file __salt__['match.compound'] = match_compound pulsar.__salt__ = __salt__ get_top_data_config = pulsar.get_top_data(topfile) configs = [ 'salt://hubblestack_pulsar/' + config.replace('.', '/') + '.yaml' for config in get_top_data_config ] assert configs[ 0] == 'salt://hubblestack_pulsar/hubblestack_pulsar_config.yaml'