Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
ebca3af7
Commit
ebca3af7
authored
Jan 16, 2013
by
chrisndodge
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1286 from MITx/feature/christina/misc
Feature/christina/misc
parents
e884f17d
65d45d6d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
4 deletions
+42
-4
cms/djangoapps/contentstore/tests/test_core_caching.py
+38
-0
common/djangoapps/cache_toolbox/core.py
+3
-3
rakefile
+1
-1
No files found.
cms/djangoapps/contentstore/tests/test_core_caching.py
0 → 100644
View file @
ebca3af7
from
django.test.testcases
import
TestCase
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
):
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
(
self
.
nonUnicodeLocation
)
.
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
.
unicodeLocation
),
'should not be stored in cache with unicodeLocation'
)
self
.
assertEqual
(
None
,
get_cached_content
(
self
.
nonUnicodeLocation
),
'should not be stored in cache with nonUnicodeLocation'
)
common/djangoapps/cache_toolbox/core.py
View file @
ebca3af7
...
...
@@ -109,10 +109,10 @@ def instance_key(model, instance_or_pk):
)
def
set_cached_content
(
content
):
cache
.
set
(
content
.
get_id
(
),
content
)
cache
.
set
(
str
(
content
.
location
),
content
)
def
get_cached_content
(
location
):
return
cache
.
get
(
StaticContent
.
get_id_from_location
(
location
))
return
cache
.
get
(
str
(
location
))
def
del_cached_content
(
location
):
cache
.
delete
(
StaticContent
.
get_id_from_location
(
location
))
cache
.
delete
(
str
(
location
))
rakefile
View file @
ebca3af7
...
...
@@ -120,7 +120,7 @@ default_options = {
}
task
:predjango
do
sh
(
"find . -type f -name
*.pyc
-delete"
)
sh
(
"find . -type f -name
'*.pyc'
-delete"
)
sh
(
'pip install -q --upgrade --no-deps -r local-requirements.txt'
)
end
...
...
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