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
aaeb3a86
Commit
aaeb3a86
authored
May 17, 2013
by
Valera Rozuvan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Python tests for start_time and end_time parameters.
parent
56f60e06
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
4 deletions
+38
-4
common/lib/xmodule/xmodule/tests/test_logic.py
+33
-1
common/lib/xmodule/xmodule/videoalpha_module.py
+5
-3
No files found.
common/lib/xmodule/xmodule/tests/test_logic.py
View file @
aaeb3a86
...
...
@@ -4,10 +4,12 @@
import
json
import
unittest
from
lxml
import
etree
from
xmodule.poll_module
import
PollDescriptor
from
xmodule.conditional_module
import
ConditionalDescriptor
from
xmodule.word_cloud_module
import
WordCloudDescriptor
from
xmodule.videoalpha_module
import
VideoAlphaDescriptor
class
PostData
:
"""Class which emulate postdata."""
...
...
@@ -117,3 +119,33 @@ class WordCloudModuleTest(LogicTest):
)
self
.
assertEqual
(
100.0
,
sum
(
i
[
'percent'
]
for
i
in
response
[
'top_words'
])
)
class
VideoAlphaModuleTest
(
LogicTest
):
descriptor_class
=
VideoAlphaDescriptor
raw_model_data
=
{
'data'
:
'<videoalpha />'
}
def
test_get_timeframe_no_parameters
(
self
):
xmltree
=
etree
.
fromstring
(
'<videoalpha>test</videoalpha>'
)
output
=
self
.
xmodule
.
_get_timeframe
(
xmltree
)
self
.
assertEqual
(
output
,
(
''
,
''
))
def
test_get_timeframe_with_one_parameter
(
self
):
xmltree
=
etree
.
fromstring
(
'<videoalpha start_time="00:04:07">test</videoalpha>'
)
output
=
self
.
xmodule
.
_get_timeframe
(
xmltree
)
self
.
assertEqual
(
output
,
(
247
,
''
))
def
test_get_timeframe_with_two_parameters
(
self
):
xmltree
=
etree
.
fromstring
(
'''<videoalpha
start_time="00:04:07"
end_time="13:04:39"
>test</videoalpha>'''
)
output
=
self
.
xmodule
.
_get_timeframe
(
xmltree
)
self
.
assertEqual
(
output
,
(
247
,
47079
))
common/lib/xmodule/xmodule/videoalpha_module.py
View file @
aaeb3a86
...
...
@@ -103,9 +103,11 @@ class VideoAlphaModule(VideoAlphaFields, XModule):
return
''
else
:
x
=
time
.
strptime
(
s
,
'
%
H:
%
M:
%
S'
)
return
datetime
.
timedelta
(
hours
=
x
.
tm_hour
,
minutes
=
x
.
tm_min
,
seconds
=
x
.
tm_sec
)
.
total_seconds
()
return
datetime
.
timedelta
(
hours
=
x
.
tm_hour
,
minutes
=
x
.
tm_min
,
seconds
=
x
.
tm_sec
)
.
total_seconds
()
return
parse_time
(
xmltree
.
get
(
'start_time'
)),
parse_time
(
xmltree
.
get
(
'end_time'
))
...
...
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