Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-activetable
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
xblock-activetable
Commits
781f858f
Commit
781f858f
authored
Oct 21, 2015
by
Sven Marnach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for cells.py.
parent
a3c5bffd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
tests/unit/test_cells.py
+35
-0
No files found.
tests/unit/test_cells.py
0 → 100644
View file @
781f858f
# -*- coding: utf-8 -*-
from
__future__
import
absolute_import
,
division
,
unicode_literals
import
unittest
from
activetable.cells
import
NumericCell
,
StringCell
class
CellTest
(
unittest
.
TestCase
):
def
test_numeric_cell
(
self
):
cell
=
NumericCell
(
answer
=
42
,
tolerance
=
1.0
)
self
.
assertTrue
(
cell
.
check_response
(
'42'
))
self
.
assertTrue
(
cell
.
check_response
(
'42.4'
))
self
.
assertTrue
(
cell
.
check_response
(
'41.6'
))
self
.
assertFalse
(
cell
.
check_response
(
'41.5'
))
self
.
assertFalse
(
cell
.
check_response
(
'43'
))
self
.
assertFalse
(
cell
.
check_response
(
'Hurz!'
))
cell
.
set_tolerance
(
10.0
)
self
.
assertTrue
(
cell
.
check_response
(
'42'
))
self
.
assertTrue
(
cell
.
check_response
(
'46'
))
self
.
assertFalse
(
cell
.
check_response
(
'37'
))
def
test_significant_digits
(
self
):
cell
=
NumericCell
(
answer
=
6.238
,
tolerance
=
10.0
,
min_significant_digits
=
3
,
max_significant_digits
=
4
)
self
.
assertTrue
(
cell
.
check_response
(
'6.24'
))
self
.
assertTrue
(
cell
.
check_response
(
'6.238'
))
self
.
assertFalse
(
cell
.
check_response
(
'6.2'
))
self
.
assertFalse
(
cell
.
check_response
(
'6.2382'
))
def
test_string_cell
(
self
):
cell
=
StringCell
(
'OpenCraft'
)
self
.
assertTrue
(
cell
.
check_response
(
'OpenCraft'
))
self
.
assertFalse
(
cell
.
check_response
(
'giraffe'
))
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