Ejemplo n.º 1
0
def test_locate_files():
	loader = mock_loader()
	locator = Locator('/root', [loader])
	with mock.patch('prove.util.list_files') as mock_list_files:
		mock_list_files.return_value = ['/root/files/test_file']
		files = locator.locate_files()
		mock_list_files.assert_called_once_with('/root/files')
	assert 'test_file' in files
	assert '/root/files/test_file' == files['test_file']
Ejemplo n.º 2
0
def test_locate_components():
	loader = mock_loader()
	locator = Locator('/root', [loader])
	with mock.patch('prove.util.list_subdirs') as mock_list_subdirs:
		mock_list_subdirs.return_value = ['test_component']
		components = locator.locate_components()
		mock_list_subdirs.assert_called_once_with('/root/components')
	assert 'test_component' in components
	assert isinstance(components['test_component'], Component)
	assert 'test_component' == components['test_component'].name
Ejemplo n.º 3
0
def test_locate_variables():
	loader = mock_loader()
	locator = Locator('/root', [loader])
	loader.load.return_value = {'test_var': {}}
	with mock.patch('prove.util.list_files') as mock_list_files:
		mock_list_files.return_value = ['test_var']
		variables = locator.locate_variables()
		mock_list_files.assert_called_once_with('/root/variables')
	assert 'test_var' in variables
	assert isinstance(variables['test_var'], VariableFile)
	assert 'test_var' == variables['test_var'].name
Ejemplo n.º 4
0
def test_locate_states():
	loader = mock_loader()
	locator = Locator('/root', [loader])
	loader.load.return_value = {'test_state': {}}
	with mock.patch('prove.util.list_files') as mock_list_files:
		mock_list_files.return_value = ['test_state']
		states = locator.locate_states()
		mock_list_files.assert_called_once_with('/root/states')
	assert 'test_state' in states
	assert isinstance(states['test_state'], StateFile)
	assert 'test_state' == states['test_state'].name
Ejemplo n.º 5
0
def test_locate_components_with_roles():
	loader = mock_loader()
	locator = Locator('/root', [loader])
	loader.load.return_value = {'states': ['test_state']}
	with mock.patch('prove.util.list_subdirs') as mock_list_subdirs, \
	     mock.patch('prove.util.list_files') as mock_list_files:
		mock_list_subdirs.return_value = ['test_component']
		mock_list_files.side_effect = [['test_role'], [], [], []]
		components = locator.locate_components()
		mock_list_subdirs.assert_called_once_with('/root/components')
	assert 'test_component/test_role' in components['test_component'].roles
	role = components['test_component'].roles['test_component/test_role']
	assert 'test_state' in role.states