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
a32bf1ec
Commit
a32bf1ec
authored
Sep 03, 2015
by
Marius Gedminas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify FactCache.copy()
Also fix the bug (missing from six import iteritems) I introduced in
823677b4
.
parent
ce978745
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
lib/ansible/plugins/cache/__init__.py
+1
-1
test/units/plugins/cache/test_cache.py
+16
-1
No files found.
lib/ansible/plugins/cache/__init__.py
View file @
a32bf1ec
...
...
@@ -60,7 +60,7 @@ class FactCache(MutableMapping):
def
copy
(
self
):
""" Return a primitive copy of the keys and values from the cache. """
return
dict
(
[(
k
,
v
)
for
(
k
,
v
)
in
iteritems
(
self
)]
)
return
dict
(
self
)
def
keys
(
self
):
return
self
.
_plugin
.
keys
()
...
...
test/units/plugins/cache/test_cache.py
View file @
a32bf1ec
...
...
@@ -19,7 +19,8 @@
from
__future__
import
(
absolute_import
,
division
,
print_function
)
__metaclass__
=
type
from
ansible.compat.tests
import
unittest
from
ansible.compat.tests
import
unittest
,
mock
from
ansible.plugins.cache
import
FactCache
from
ansible.plugins.cache.base
import
BaseCacheModule
from
ansible.plugins.cache.memory
import
CacheModule
as
MemoryCache
...
...
@@ -42,6 +43,20 @@ else:
from
ansible.plugins.cache.redis
import
CacheModule
as
RedisCache
class
TestFactCache
(
unittest
.
TestCase
):
def
setUp
(
self
):
with
mock
.
patch
(
'ansible.constants.CACHE_PLUGIN'
,
'memory'
):
self
.
cache
=
FactCache
()
def
test_copy
(
self
):
self
.
cache
[
'avocado'
]
=
'fruit'
self
.
cache
[
'daisy'
]
=
'flower'
a_copy
=
self
.
cache
.
copy
()
self
.
assertEqual
(
type
(
a_copy
),
dict
)
self
.
assertEqual
(
a_copy
,
dict
(
avocado
=
'fruit'
,
daisy
=
'flower'
))
class
TestAbstractClass
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
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