Commit b021d9cc by Calen Pennington

Merge pull request #209 from edx/cale/pep8-fixes

Cleanup pep8 violations in test_correctmap.py
parents dda21b3b 4cc30aab
"""
Tests to verify that CorrectMap behaves correctly
"""
import unittest import unittest
from capa.correctmap import CorrectMap from capa.correctmap import CorrectMap
import datetime import datetime
class CorrectMapTest(unittest.TestCase): class CorrectMapTest(unittest.TestCase):
"""
Tests to verify that CorrectMap behaves correctly
"""
def setUp(self): def setUp(self):
self.cmap = CorrectMap() self.cmap = CorrectMap()
def test_set_input_properties(self): def test_set_input_properties(self):
# Set the correctmap properties for two inputs # Set the correctmap properties for two inputs
self.cmap.set(answer_id='1_2_1', self.cmap.set(
correctness='correct', answer_id='1_2_1',
npoints=5, correctness='correct',
msg='Test message', npoints=5,
hint='Test hint', msg='Test message',
hintmode='always', hint='Test hint',
queuestate={'key':'secretstring', hintmode='always',
'time':'20130228100026'}) queuestate={
'key': 'secretstring',
self.cmap.set(answer_id='2_2_1', 'time': '20130228100026'
correctness='incorrect', }
npoints=None, )
msg=None,
hint=None, self.cmap.set(
hintmode=None, answer_id='2_2_1',
queuestate=None) correctness='incorrect',
npoints=None,
msg=None,
hint=None,
hintmode=None,
queuestate=None
)
# Assert that each input has the expected properties # Assert that each input has the expected properties
self.assertTrue(self.cmap.is_correct('1_2_1')) self.assertTrue(self.cmap.is_correct('1_2_1'))
...@@ -62,7 +75,6 @@ class CorrectMapTest(unittest.TestCase): ...@@ -62,7 +75,6 @@ class CorrectMapTest(unittest.TestCase):
self.assertFalse(self.cmap.is_right_queuekey('2_2_1', '')) self.assertFalse(self.cmap.is_right_queuekey('2_2_1', ''))
self.assertFalse(self.cmap.is_right_queuekey('2_2_1', None)) self.assertFalse(self.cmap.is_right_queuekey('2_2_1', None))
def test_get_npoints(self): def test_get_npoints(self):
# Set the correctmap properties for 4 inputs # Set the correctmap properties for 4 inputs
# 1) correct, 5 points # 1) correct, 5 points
...@@ -70,25 +82,35 @@ class CorrectMapTest(unittest.TestCase): ...@@ -70,25 +82,35 @@ class CorrectMapTest(unittest.TestCase):
# 3) incorrect, 5 points # 3) incorrect, 5 points
# 4) incorrect, None points # 4) incorrect, None points
# 5) correct, 0 points # 5) correct, 0 points
self.cmap.set(answer_id='1_2_1', self.cmap.set(
correctness='correct', answer_id='1_2_1',
npoints=5) correctness='correct',
npoints=5
self.cmap.set(answer_id='2_2_1', )
correctness='correct',
npoints=None) self.cmap.set(
answer_id='2_2_1',
self.cmap.set(answer_id='3_2_1', correctness='correct',
correctness='incorrect', npoints=None
npoints=5) )
self.cmap.set(answer_id='4_2_1', self.cmap.set(
correctness='incorrect', answer_id='3_2_1',
npoints=None) correctness='incorrect',
npoints=5
self.cmap.set(answer_id='5_2_1', )
correctness='correct',
npoints=0) self.cmap.set(
answer_id='4_2_1',
correctness='incorrect',
npoints=None
)
self.cmap.set(
answer_id='5_2_1',
correctness='correct',
npoints=0
)
# Assert that we get the expected points # Assert that we get the expected points
# If points assigned --> npoints # If points assigned --> npoints
...@@ -100,7 +122,6 @@ class CorrectMapTest(unittest.TestCase): ...@@ -100,7 +122,6 @@ class CorrectMapTest(unittest.TestCase):
self.assertEqual(self.cmap.get_npoints('4_2_1'), 0) self.assertEqual(self.cmap.get_npoints('4_2_1'), 0)
self.assertEqual(self.cmap.get_npoints('5_2_1'), 0) self.assertEqual(self.cmap.get_npoints('5_2_1'), 0)
def test_set_overall_message(self): def test_set_overall_message(self):
# Default is an empty string string # Default is an empty string string
...@@ -118,14 +139,18 @@ class CorrectMapTest(unittest.TestCase): ...@@ -118,14 +139,18 @@ class CorrectMapTest(unittest.TestCase):
def test_update_from_correctmap(self): def test_update_from_correctmap(self):
# Initialize a CorrectMap with some properties # Initialize a CorrectMap with some properties
self.cmap.set(answer_id='1_2_1', self.cmap.set(
correctness='correct', answer_id='1_2_1',
npoints=5, correctness='correct',
msg='Test message', npoints=5,
hint='Test hint', msg='Test message',
hintmode='always', hint='Test hint',
queuestate={'key':'secretstring', hintmode='always',
'time':'20130228100026'}) queuestate={
'key': 'secretstring',
'time': '20130228100026'
}
)
self.cmap.set_overall_message("Test message") self.cmap.set_overall_message("Test message")
...@@ -133,14 +158,17 @@ class CorrectMapTest(unittest.TestCase): ...@@ -133,14 +158,17 @@ class CorrectMapTest(unittest.TestCase):
# as the first cmap # as the first cmap
other_cmap = CorrectMap() other_cmap = CorrectMap()
other_cmap.update(self.cmap) other_cmap.update(self.cmap)
# Assert that it has all the same properties
self.assertEqual(other_cmap.get_overall_message(),
self.cmap.get_overall_message())
self.assertEqual(other_cmap.get_dict(),
self.cmap.get_dict())
# Assert that it has all the same properties
self.assertEqual(
other_cmap.get_overall_message(),
self.cmap.get_overall_message()
)
self.assertEqual(
other_cmap.get_dict(),
self.cmap.get_dict()
)
def test_update_from_invalid(self): def test_update_from_invalid(self):
# Should get an exception if we try to update() a CorrectMap # Should get an exception if we try to update() a CorrectMap
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment