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
2865c7ca
Commit
2865c7ca
authored
Nov 28, 2012
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved tests from miller to tests
parent
dcd52801
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
142 additions
and
154 deletions
+142
-154
common/lib/capa/capa/chem/miller.py
+0
-149
common/lib/capa/capa/chem/tests.py
+142
-5
No files found.
common/lib/capa/capa/chem/miller.py
View file @
2865c7ca
...
@@ -4,7 +4,6 @@ import numpy as np
...
@@ -4,7 +4,6 @@ import numpy as np
import
math
import
math
import
fractions
as
fr
import
fractions
as
fr
import
decimal
import
decimal
import
unittest
import
json
import
json
...
@@ -266,151 +265,3 @@ def grade(user_input, correct_answer):
...
@@ -266,151 +265,3 @@ def grade(user_input, correct_answer):
return
True
return
True
return
False
return
False
class
Test_Crystallography_Miller
(
unittest
.
TestCase
):
''' Tests for crystallography grade function.'''
def
test_empty_points
(
self
):
user_input
=
'{"lattice": "bcc", "points": []}'
self
.
assertFalse
(
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_only_one_point
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"]]}'
self
.
assertFalse
(
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_only_two_points
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"], ["0.00", "0.50", "0.00"]]}'
self
.
assertFalse
(
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_1
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"], ["0.00", "0.50", "0.00"], ["0.00", "0.00", "0.50"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_2
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "0.00"], ["0.00", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(1,1,1)'
,
'lattice'
:
'bcc'
}))
def
test_3
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.50", "1.00"], ["1.00", "1.00", "0.50"], ["0.50", "1.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_4
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.33", "1.00", "0.00"], ["0.00", "0.664", "0.00"], ["0.00", "1.00", "0.33"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(-3, 3, -3)'
,
'lattice'
:
'bcc'
}))
def
test_5
(
self
):
""" return true only in case points coordinates are exact.
But if they transform to closest 0.05 value it is not true"""
user_input
=
'{"lattice": "bcc", "points": [["0.33", "1.00", "0.00"], ["0.00", "0.33", "0.00"], ["0.00", "1.00", "0.33"]]}'
self
.
assertFalse
(
grade
(
user_input
,
{
'miller'
:
'(-6,3,-6)'
,
'lattice'
:
'bcc'
}))
def
test_6
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.25", "0.00"], ["0.25", "0.00", "0.00"], ["0.00", "0.00", "0.25"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(4,4,4)'
,
'lattice'
:
'bcc'
}))
def
test_7
(
self
):
# goes throug origin
user_input
=
'{"lattice": "bcc", "points": [["0.00", "1.00", "0.00"], ["1.00", "0.00", "0.00"], ["0.50", "1.00", "0.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(0,0,-1)'
,
'lattice'
:
'bcc'
}))
def
test_8
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "1.00", "0.50"], ["1.00", "0.00", "0.50"], ["0.50", "1.00", "0.50"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(0,0,2)'
,
'lattice'
:
'bcc'
}))
def
test_9
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "1.00"], ["0.00", "1.00", "1.00"], ["1.00", "0.00", "0.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(1,1,0)'
,
'lattice'
:
'bcc'
}))
def
test_10
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "1.00"], ["0.00", "0.00", "0.00"], ["0.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(1,1,-1)'
,
'lattice'
:
'bcc'
}))
def
test_11
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "0.50"], ["1.00", "1.00", "0.00"], ["0.00", "1.00", "0.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(0,1,2)'
,
'lattice'
:
'bcc'
}))
def
test_12
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "0.50"], ["0.00", "0.00", "0.50"], ["1.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(0,1,-2)'
,
'lattice'
:
'bcc'
}))
def
test_13
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"], ["0.50", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(2,0,1)'
,
'lattice'
:
'bcc'
}))
def
test_14
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["0.00", "0.00", "1.00"], ["0.50", "1.00", "0.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(2,-1,0)'
,
'lattice'
:
'bcc'
}))
def
test_15
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(1,-1,1)'
,
'lattice'
:
'bcc'
}))
def
test_16
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "0.00"], ["0.00", "1.00", "0.00"], ["1.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(1,1,-1)'
,
'lattice'
:
'bcc'
}))
def
test_17
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "0.00", "1.00"], ["1.00", "1.00", "0.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(-1,1,1)'
,
'lattice'
:
'bcc'
}))
def
test_18
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(1,-1,1)'
,
'lattice'
:
'bcc'
}))
def
test_19
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(-1,1,0)'
,
'lattice'
:
'bcc'
}))
def
test_20
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(1,0,1)'
,
'lattice'
:
'bcc'
}))
def
test_21
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["0.00", "1.00", "0.00"], ["1.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(-1,0,1)'
,
'lattice'
:
'bcc'
}))
def
test_22
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "1.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(0,1,1)'
,
'lattice'
:
'bcc'
}))
def
test_23
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "0.00", "0.00"], ["1.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(0,-1,1)'
,
'lattice'
:
'bcc'
}))
def
test_24
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.66", "0.00", "0.00"], ["0.00", "0.66", "0.00"], ["0.00", "0.00", "0.66"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(3,3,3)'
,
'lattice'
:
'bcc'
}))
def
test_25
(
self
):
user_input
=
u'{"lattice":"","points":[["0.00","0.00","0.01"],["1.00","1.00","0.01"],["0.00","1.00","1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(1,-1,1)'
,
'lattice'
:
''
}))
def
test_26
(
self
):
user_input
=
u'{"lattice":"","points":[["0.00","0.01","0.00"],["1.00","0.00","0.00"],["0.00","0.00","1.00"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(0,-1,0)'
,
'lattice'
:
''
}))
def
test_27
(
self
):
""" rounding to 0.35"""
user_input
=
u'{"lattice":"","points":[["0.33","0.00","0.00"],["0.00","0.33","0.00"],["0.00","0.00","0.33"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(3,3,3)'
,
'lattice'
:
''
}))
def
test_28
(
self
):
""" rounding to 0.30"""
user_input
=
u'{"lattice":"","points":[["0.30","0.00","0.00"],["0.00","0.30","0.00"],["0.00","0.00","0.30"]]}'
self
.
assertTrue
(
grade
(
user_input
,
{
'miller'
:
'(10,10,10)'
,
'lattice'
:
''
}))
def
test_wrong_lattice
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "0.00", "0.00"], ["1.00", "1.00", "1.00"]]}'
self
.
assertFalse
(
grade
(
user_input
,
{
'miller'
:
'(3,3,3)'
,
'lattice'
:
'fcc'
}))
def
suite
():
testcases
=
[
Test_Crystallography_Miller
]
suites
=
[]
for
testcase
in
testcases
:
suites
.
append
(
unittest
.
TestLoader
()
.
loadTestsFromTestCase
(
testcase
))
return
unittest
.
TestSuite
(
suites
)
if
__name__
==
"__main__"
:
unittest
.
TextTestRunner
(
verbosity
=
2
)
.
run
(
suite
())
common/lib/capa/capa/chem/tests.py
View file @
2865c7ca
import
codecs
import
codecs
from
fractions
import
Fraction
from
fractions
import
Fraction
from
pyparsing
import
ParseException
import
unittest
import
unittest
from
chemcalc
import
(
compare_chemical_expression
,
divide_chemical_expression
,
from
chemcalc
import
(
compare_chemical_expression
,
divide_chemical_expression
,
render_to_html
,
chemical_equations_equal
)
render_to_html
,
chemical_equations_equal
)
import
miller
local_debug
=
None
local_debug
=
None
def
log
(
s
,
output_type
=
None
):
def
log
(
s
,
output_type
=
None
):
if
local_debug
:
if
local_debug
:
print
s
print
s
...
@@ -37,7 +39,6 @@ class Test_Compare_Equations(unittest.TestCase):
...
@@ -37,7 +39,6 @@ class Test_Compare_Equations(unittest.TestCase):
self
.
assertFalse
(
chemical_equations_equal
(
'2H2 + O2 -> H2O2'
,
self
.
assertFalse
(
chemical_equations_equal
(
'2H2 + O2 -> H2O2'
,
'2O2 + 2H2 -> 2H2O2'
))
'2O2 + 2H2 -> 2H2O2'
))
def
test_different_arrows
(
self
):
def
test_different_arrows
(
self
):
self
.
assertTrue
(
chemical_equations_equal
(
'H2 + O2 -> H2O2'
,
self
.
assertTrue
(
chemical_equations_equal
(
'H2 + O2 -> H2O2'
,
'2O2 + 2H2 -> 2H2O2'
))
'2O2 + 2H2 -> 2H2O2'
))
...
@@ -56,7 +57,6 @@ class Test_Compare_Equations(unittest.TestCase):
...
@@ -56,7 +57,6 @@ class Test_Compare_Equations(unittest.TestCase):
self
.
assertTrue
(
chemical_equations_equal
(
'H2 + O2 -> H2O2'
,
self
.
assertTrue
(
chemical_equations_equal
(
'H2 + O2 -> H2O2'
,
'O2 + H2 -> H2O2'
,
exact
=
True
))
'O2 + H2 -> H2O2'
,
exact
=
True
))
def
test_syntax_errors
(
self
):
def
test_syntax_errors
(
self
):
self
.
assertFalse
(
chemical_equations_equal
(
'H2 + O2 a-> H2O2'
,
self
.
assertFalse
(
chemical_equations_equal
(
'H2 + O2 a-> H2O2'
,
'2O2 + 2H2 -> 2H2O2'
))
'2O2 + 2H2 -> 2H2O2'
))
...
@@ -311,7 +311,6 @@ class Test_Render_Equations(unittest.TestCase):
...
@@ -311,7 +311,6 @@ class Test_Render_Equations(unittest.TestCase):
log
(
out
+
' ------- '
+
correct
,
'html'
)
log
(
out
+
' ------- '
+
correct
,
'html'
)
self
.
assertEqual
(
out
,
correct
)
self
.
assertEqual
(
out
,
correct
)
def
test_render_eq3
(
self
):
def
test_render_eq3
(
self
):
s
=
"H^+ + OH^- <= H2O"
# unsupported arrow
s
=
"H^+ + OH^- <= H2O"
# unsupported arrow
out
=
render_to_html
(
s
)
out
=
render_to_html
(
s
)
...
@@ -320,10 +319,148 @@ class Test_Render_Equations(unittest.TestCase):
...
@@ -320,10 +319,148 @@ class Test_Render_Equations(unittest.TestCase):
self
.
assertEqual
(
out
,
correct
)
self
.
assertEqual
(
out
,
correct
)
class
Test_Crystallography_Miller
(
unittest
.
TestCase
):
''' Tests for crystallography grade function.'''
def
test_empty_points
(
self
):
user_input
=
'{"lattice": "bcc", "points": []}'
self
.
assertFalse
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_only_one_point
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"]]}'
self
.
assertFalse
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_only_two_points
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"], ["0.00", "0.50", "0.00"]]}'
self
.
assertFalse
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_1
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"], ["0.00", "0.50", "0.00"], ["0.00", "0.00", "0.50"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_2
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "0.00"], ["0.00", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(1,1,1)'
,
'lattice'
:
'bcc'
}))
def
test_3
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.50", "1.00"], ["1.00", "1.00", "0.50"], ["0.50", "1.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(2,2,2)'
,
'lattice'
:
'bcc'
}))
def
test_4
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.33", "1.00", "0.00"], ["0.00", "0.664", "0.00"], ["0.00", "1.00", "0.33"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(-3, 3, -3)'
,
'lattice'
:
'bcc'
}))
def
test_5
(
self
):
""" return true only in case points coordinates are exact.
But if they transform to closest 0.05 value it is not true"""
user_input
=
'{"lattice": "bcc", "points": [["0.33", "1.00", "0.00"], ["0.00", "0.33", "0.00"], ["0.00", "1.00", "0.33"]]}'
self
.
assertFalse
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(-6,3,-6)'
,
'lattice'
:
'bcc'
}))
def
test_6
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.25", "0.00"], ["0.25", "0.00", "0.00"], ["0.00", "0.00", "0.25"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(4,4,4)'
,
'lattice'
:
'bcc'
}))
def
test_7
(
self
):
# goes throug origin
user_input
=
'{"lattice": "bcc", "points": [["0.00", "1.00", "0.00"], ["1.00", "0.00", "0.00"], ["0.50", "1.00", "0.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(0,0,-1)'
,
'lattice'
:
'bcc'
}))
def
test_8
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "1.00", "0.50"], ["1.00", "0.00", "0.50"], ["0.50", "1.00", "0.50"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(0,0,2)'
,
'lattice'
:
'bcc'
}))
def
test_9
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "1.00"], ["0.00", "1.00", "1.00"], ["1.00", "0.00", "0.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(1,1,0)'
,
'lattice'
:
'bcc'
}))
def
test_10
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "1.00"], ["0.00", "0.00", "0.00"], ["0.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(1,1,-1)'
,
'lattice'
:
'bcc'
}))
def
test_11
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "0.50"], ["1.00", "1.00", "0.00"], ["0.00", "1.00", "0.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(0,1,2)'
,
'lattice'
:
'bcc'
}))
def
test_12
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "0.50"], ["0.00", "0.00", "0.50"], ["1.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(0,1,-2)'
,
'lattice'
:
'bcc'
}))
def
test_13
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.50", "0.00", "0.00"], ["0.50", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(2,0,1)'
,
'lattice'
:
'bcc'
}))
def
test_14
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["0.00", "0.00", "1.00"], ["0.50", "1.00", "0.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(2,-1,0)'
,
'lattice'
:
'bcc'
}))
def
test_15
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(1,-1,1)'
,
'lattice'
:
'bcc'
}))
def
test_16
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "0.00"], ["0.00", "1.00", "0.00"], ["1.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(1,1,-1)'
,
'lattice'
:
'bcc'
}))
def
test_17
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "0.00", "1.00"], ["1.00", "1.00", "0.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(-1,1,1)'
,
'lattice'
:
'bcc'
}))
def
test_18
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(1,-1,1)'
,
'lattice'
:
'bcc'
}))
def
test_19
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(-1,1,0)'
,
'lattice'
:
'bcc'
}))
def
test_20
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["1.00", "0.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(1,0,1)'
,
'lattice'
:
'bcc'
}))
def
test_21
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["0.00", "1.00", "0.00"], ["1.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(-1,0,1)'
,
'lattice'
:
'bcc'
}))
def
test_22
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "1.00", "0.00"], ["1.00", "1.00", "0.00"], ["0.00", "0.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(0,1,1)'
,
'lattice'
:
'bcc'
}))
def
test_23
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "0.00", "0.00"], ["1.00", "1.00", "1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(0,-1,1)'
,
'lattice'
:
'bcc'
}))
def
test_24
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.66", "0.00", "0.00"], ["0.00", "0.66", "0.00"], ["0.00", "0.00", "0.66"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(3,3,3)'
,
'lattice'
:
'bcc'
}))
def
test_25
(
self
):
user_input
=
u'{"lattice":"","points":[["0.00","0.00","0.01"],["1.00","1.00","0.01"],["0.00","1.00","1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(1,-1,1)'
,
'lattice'
:
''
}))
def
test_26
(
self
):
user_input
=
u'{"lattice":"","points":[["0.00","0.01","0.00"],["1.00","0.00","0.00"],["0.00","0.00","1.00"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(0,-1,0)'
,
'lattice'
:
''
}))
def
test_27
(
self
):
""" rounding to 0.35"""
user_input
=
u'{"lattice":"","points":[["0.33","0.00","0.00"],["0.00","0.33","0.00"],["0.00","0.00","0.33"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(3,3,3)'
,
'lattice'
:
''
}))
def
test_28
(
self
):
""" rounding to 0.30"""
user_input
=
u'{"lattice":"","points":[["0.30","0.00","0.00"],["0.00","0.30","0.00"],["0.00","0.00","0.30"]]}'
self
.
assertTrue
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(10,10,10)'
,
'lattice'
:
''
}))
def
test_wrong_lattice
(
self
):
user_input
=
'{"lattice": "bcc", "points": [["0.00", "0.00", "0.00"], ["1.00", "0.00", "0.00"], ["1.00", "1.00", "1.00"]]}'
self
.
assertFalse
(
miller
.
grade
(
user_input
,
{
'miller'
:
'(3,3,3)'
,
'lattice'
:
'fcc'
}))
def
suite
():
def
suite
():
testcases
=
[
Test_Compare_Expressions
,
Test_Divide_Expressions
,
Test_Render_Equations
]
testcases
=
[
Test_Compare_Expressions
,
Test_Divide_Expressions
,
Test_Render_Equations
,
Test_Crystallography_Miller
]
suites
=
[]
suites
=
[]
for
testcase
in
testcases
:
for
testcase
in
testcases
:
suites
.
append
(
unittest
.
TestLoader
()
.
loadTestsFromTestCase
(
testcase
))
suites
.
append
(
unittest
.
TestLoader
()
.
loadTestsFromTestCase
(
testcase
))
...
...
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