Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
eefd9fee
Commit
eefd9fee
authored
8 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Fix up tests
parent
014fee93
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/storage/test__base.py
+1
-1
1 addition, 1 deletion
tests/storage/test__base.py
tests/util/caches/test_descriptors.py
+38
-0
38 additions, 0 deletions
tests/util/caches/test_descriptors.py
tests/util/test_snapshot_cache.py
+3
-1
3 additions, 1 deletion
tests/util/test_snapshot_cache.py
with
42 additions
and
2 deletions
tests/storage/test__base.py
+
1
−
1
View file @
eefd9fee
...
...
@@ -199,7 +199,7 @@ class CacheDecoratorTestCase(unittest.TestCase):
a
.
func
.
prefill
((
"
foo
"
,),
ObservableDeferred
(
d
))
self
.
assertEquals
(
a
.
func
(
"
foo
"
)
.
result
,
d
.
result
)
self
.
assertEquals
(
a
.
func
(
"
foo
"
),
d
.
result
)
self
.
assertEquals
(
callcount
[
0
],
0
)
@defer.inlineCallbacks
...
...
This diff is collapsed.
Click to expand it.
tests/util/caches/test_descriptors.py
+
38
−
0
View file @
eefd9fee
...
...
@@ -175,3 +175,41 @@ class DescriptorTestCase(unittest.TestCase):
logcontext
.
LoggingContext
.
sentinel
)
return
d1
@defer.inlineCallbacks
def
test_cache_default_args
(
self
):
class
Cls
(
object
):
def
__init__
(
self
):
self
.
mock
=
mock
.
Mock
()
@descriptors.cached
()
def
fn
(
self
,
arg1
,
arg2
=
2
,
arg3
=
3
):
return
self
.
mock
(
arg1
,
arg2
,
arg3
)
obj
=
Cls
()
obj
.
mock
.
return_value
=
'
fish
'
r
=
yield
obj
.
fn
(
1
,
2
,
3
)
self
.
assertEqual
(
r
,
'
fish
'
)
obj
.
mock
.
assert_called_once_with
(
1
,
2
,
3
)
obj
.
mock
.
reset_mock
()
# a call with same params shouldn't call the mock again
r
=
yield
obj
.
fn
(
1
,
2
)
self
.
assertEqual
(
r
,
'
fish
'
)
obj
.
mock
.
assert_not_called
()
obj
.
mock
.
reset_mock
()
# a call with different params should call the mock again
obj
.
mock
.
return_value
=
'
chips
'
r
=
yield
obj
.
fn
(
2
,
3
)
self
.
assertEqual
(
r
,
'
chips
'
)
obj
.
mock
.
assert_called_once_with
(
2
,
3
,
3
)
obj
.
mock
.
reset_mock
()
# the two values should now be cached
r
=
yield
obj
.
fn
(
1
,
2
)
self
.
assertEqual
(
r
,
'
fish
'
)
r
=
yield
obj
.
fn
(
2
,
3
)
self
.
assertEqual
(
r
,
'
chips
'
)
obj
.
mock
.
assert_not_called
()
This diff is collapsed.
Click to expand it.
tests/util/test_snapshot_cache.py
+
3
−
1
View file @
eefd9fee
...
...
@@ -53,7 +53,9 @@ class SnapshotCacheTestCase(unittest.TestCase):
# before the cache expires returns a resolved deferred.
get_result_at_11
=
self
.
cache
.
get
(
11
,
"
key
"
)
self
.
assertIsNotNone
(
get_result_at_11
)
self
.
assertTrue
(
get_result_at_11
.
called
)
if
isinstance
(
get_result_at_11
,
Deferred
):
# The cache may return the actual result rather than a deferred
self
.
assertTrue
(
get_result_at_11
.
called
)
# Check that getting the key after the deferred has resolved
# after the cache expires returns None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment