Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
07d6bee5
Commit
07d6bee5
authored
12 years ago
by
cahrens
Browse files
Options
Downloads
Patches
Plain Diff
storing work
parent
9818664b
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cms/djangoapps/contentstore/tests/test_core_caching.py
+30
-13
30 additions, 13 deletions
cms/djangoapps/contentstore/tests/test_core_caching.py
common/djangoapps/cache_toolbox/core.py
+0
-12
0 additions, 12 deletions
common/djangoapps/cache_toolbox/core.py
with
30 additions
and
25 deletions
cms/djangoapps/contentstore/tests/test_core_caching.py
+
30
−
13
View file @
07d6bee5
from
django.test.testcases
import
TestCase
from
cache_toolbox.core
import
get_cached_content
,
set_cached_content
import
mock
from
cache_toolbox.core
import
get_cached_content
,
set_cached_content
,
del_cached_content
from
xmodule.modulestore
import
Location
from
xmodule.contentstore.content
import
StaticContent
class
Content
:
def
__init__
(
self
,
location
,
content
):
self
.
location
=
location
self
.
content
=
content
def
get_id
(
self
):
return
StaticContent
.
get_id_from_location
(
self
.
location
)
class
CachingTestCase
(
TestCase
):
# Tests for https://edx.lighthouseapp.com/projects/102637/tickets/112-updating-asset-does-not-refresh-the-cached-copy
unicodeLocation
=
Location
(
u
'
c4x
'
,
u
'
mitX
'
,
u
'
800
'
,
u
'
thumbnail
'
,
u
'
monsters.jpg
'
)
# Note that some of the parts are strings instead of unicode strings
nonUnicodeLocation
=
Location
(
'
c4x
'
,
u
'
mitX
'
,
u
'
800
'
,
'
thumbnail
'
,
'
monsters.jpg
'
)
mockAsset
=
Content
(
unicodeLocation
,
'
my content
'
)
def
test_put_and_get
(
self
):
mockAsset
=
mock
.
Mock
()
mockLocation
=
mock
.
Mock
()
mockLocation
.
category
=
u
'
thumbnail
'
mockLocation
.
name
=
u
'
monsters.jpg
'
mockLocation
.
course
=
u
'
800
'
mockLocation
.
tag
=
u
'
c4x
'
mockLocation
.
org
=
u
'
mitX
'
mockLocation
.
revision
=
None
mockAsset
.
location
=
mockLocation
set_cached_content
(
mockAsset
)
cachedAsset
=
get_cached_content
(
mockLocation
)
set_cached_content
(
self
.
mockAsset
)
self
.
assertEqual
(
self
.
mockAsset
.
content
,
get_cached_content
(
self
.
unicodeLocation
).
content
,
'
should be stored in cache with unicodeLocation
'
)
self
.
assertEqual
(
self
.
mockAsset
.
content
,
get_cached_content
(
Location
(
'
c4x
'
,
u
'
mitX
'
,
u
'
800
'
,
'
thumbnail
'
,
'
monsters.jpg
'
)).
content
,
'
should be stored in cache with nonUnicodeLocation
'
)
def
test_delete
(
self
):
set_cached_content
(
self
.
mockAsset
)
del_cached_content
(
self
.
nonUnicodeLocation
)
self
.
assertEqual
(
None
,
get_cached_content
(
self
.
nonUnicodeLocation
),
'
should not be stored in cache with nonUnicodeLocation
'
)
self
.
assertEqual
(
None
,
get_cached_content
(
self
.
unicodeLocation
),
'
should not be stored in cache with unicodeLocation
'
)
This diff is collapsed.
Click to expand it.
common/djangoapps/cache_toolbox/core.py
+
0
−
12
View file @
07d6bee5
...
...
@@ -108,23 +108,11 @@ def instance_key(model, instance_or_pk):
getattr
(
instance_or_pk
,
'
pk
'
,
instance_or_pk
),
)
import
logging
def
set_cached_content
(
content
):
logging
.
warn
(
"
set cached---------------------------------------
"
)
logging
.
warn
(
str
(
content
.
location
))
cache
.
set
(
str
(
content
.
location
),
content
)
def
get_cached_content
(
location
):
logging
.
warn
(
"
get cached------------------------
"
)
logging
.
warn
(
str
(
location
))
logging
.
warn
(
StaticContent
.
get_id_from_location
(
location
))
return
cache
.
get
(
str
(
location
))
def
del_cached_content
(
location
):
if
cache
.
get
(
str
(
location
))
is
None
:
logging
.
err
(
'
nothing in cache for:
'
+
str
(
location
))
logging
.
warn
(
"
deleted cache----------
"
)
logging
.
warn
(
str
(
location
))
logging
.
warn
(
StaticContent
.
get_id_from_location
(
location
))
cache
.
delete
(
str
(
location
))
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