Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
b8cf1313
Commit
b8cf1313
authored
Feb 26, 2015
by
Alejandro Guirao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fix: Search only for files as candidates
parent
affb6641
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
+31
-1
lib/ansible/utils/plugins.py
+2
-1
test/units/TestUtils.py
+29
-0
No files found.
lib/ansible/utils/plugins.py
View file @
b8cf1313
...
...
@@ -176,7 +176,8 @@ class PluginLoader(object):
found
=
None
for
path
in
[
p
for
p
in
self
.
_get_paths
()
if
p
not
in
self
.
_searched_paths
]:
if
os
.
path
.
isdir
(
path
):
for
potential_file
in
os
.
listdir
(
path
):
for
potential_file
in
(
f
for
f
in
os
.
listdir
(
path
)
if
os
.
path
.
isfile
(
os
.
path
.
join
(
path
,
f
))):
for
suffix
in
suffixes
:
if
potential_file
.
endswith
(
suffix
):
full_path
=
os
.
path
.
join
(
path
,
potential_file
)
...
...
test/units/TestUtils.py
View file @
b8cf1313
...
...
@@ -11,8 +11,11 @@ import passlib.hash
import
string
import
StringIO
import
copy
import
tempfile
import
shutil
from
nose.plugins.skip
import
SkipTest
from
mock
import
patch
import
ansible.utils
import
ansible.errors
...
...
@@ -914,3 +917,29 @@ class TestUtils(unittest.TestCase):
for
(
role
,
result
)
in
tests
:
self
.
assertEqual
(
ansible
.
utils
.
role_yaml_parse
(
role
),
result
)
@patch
(
'ansible.utils.plugins.module_finder._get_paths'
)
def
test_find_plugin
(
self
,
mock_get_paths
):
tmp_path
=
tempfile
.
mkdtemp
()
mock_get_paths
.
return_value
=
[
tmp_path
,]
right_module_1
=
'module.py'
right_module_2
=
'module_without_extension'
wrong_module_1
=
'folder'
wrong_module_2
=
'inexistent'
path_right_module_1
=
os
.
path
.
join
(
tmp_path
,
right_module_1
)
path_right_module_2
=
os
.
path
.
join
(
tmp_path
,
right_module_2
)
path_wrong_module_1
=
os
.
path
.
join
(
tmp_path
,
wrong_module_1
)
open
(
path_right_module_1
,
'w'
)
.
close
()
open
(
path_right_module_2
,
'w'
)
.
close
()
os
.
mkdir
(
path_wrong_module_1
)
self
.
assertEqual
(
ansible
.
utils
.
plugins
.
module_finder
.
find_plugin
(
right_module_1
),
path_right_module_1
)
self
.
assertEqual
(
ansible
.
utils
.
plugins
.
module_finder
.
find_plugin
(
right_module_2
),
path_right_module_2
)
self
.
assertEqual
(
ansible
.
utils
.
plugins
.
module_finder
.
find_plugin
(
wrong_module_1
),
None
)
self
.
assertEqual
(
ansible
.
utils
.
plugins
.
module_finder
.
find_plugin
(
wrong_module_2
),
None
)
shutil
.
rmtree
(
tmp_path
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment