Beispiel #1
0
def test_find_plugins(mock_get_file_from_each, mock_find_plugin_details):
	mock_get_file_from_each.return_value = ['wp/wp-content/plugins/plugin1/readme.txt', 'wp/wp-content/plugins/plugin2/readme.txt']
	mock_find_plugin_details.side_effect = [['plugin1', '1.2.3'], ['plugin2', '1.0']]
	found = wpa.find_plugins('wp/')
	mock_get_file_from_each.assert_called_with('wp/wp-content/plugins', 'readme.txt')
	calls = [
		mock.call('wp/wp-content/plugins/plugin1/readme.txt'),
		mock.call('wp/wp-content/plugins/plugin2/readme.txt')
	]
	mock_find_plugin_details.assert_has_calls(calls)
	assert_equal(found, [
		{'name': 'plugin1', 'version': '1.2.3'},
		{'name': 'plugin2', 'version': '1.0'}
	])
def test_find_plugins(mock_walk, mock_find_plugin_version):
	mock_walk.return_value = iter([
			('plugins', ('plugin1', 'plugin2'), ('plugin1.php', 'plugin2.php')),
			('plugins/plugin1', (), ('plugin1.php')),
			('plugins/plugin2', (), ('plugin2.php'))
		])
	mock_find_plugin_version.side_effect = ['1.2.3','1.2.4']
	res = wpa.find_plugins('wp')
	mock_walk.assert_called_with('wp/wp-content/plugins')
	calls = [
		mock.call('wp/wp-content/plugins/plugin1/readme.txt'),
		mock.call('wp/wp-content/plugins/plugin2/readme.txt'),
	]
	mock_find_plugin_version.assert_has_calls(calls)
	assert_equal(res, [
		{'name': 'plugin1', 'version': '1.2.3'}, 
		{'name': 'plugin2', 'version': '1.2.4'}
	])
Beispiel #3
0
def test_find_plugins(mock_walk, mock_find_plugin_version):
	mock_walk.return_value = iter([
			('plugins', ('plugin1', 'plugin2'), ('plugin1.php', 'plugin2.php')),
			('plugins/plugin1', (), ('plugin1.php')),
			('plugins/plugin2', (), ('plugin2.php'))
		])
	mock_find_plugin_version.side_effect = ['1.2.3','1.2.4']
	res = wpa.find_plugins('wp')
	mock_walk.assert_called_with('wp/wp-content/plugins')
	calls = [
		mock.call('wp/wp-content/plugins/plugin1/readme.txt'),
		mock.call('wp/wp-content/plugins/plugin2/readme.txt'),
	]
	mock_find_plugin_version.assert_has_calls(calls)
	assert_equal(res, [
		{'name': 'plugin1', 'version': '1.2.3'}, 
		{'name': 'plugin2', 'version': '1.2.4'}
	])