-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccs_unit_tests_clue.py
61 lines (50 loc) · 2.2 KB
/
ccs_unit_tests_clue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
__author__ = 'Jarek Glowacki'
import unittest
from clue import Clue
from exceptions import *
class UnitTestsClue(unittest.TestCase):
"""
These tests check whether the input clues are correctly parsed.
Additional Clue-specific testing is performed in the integration tests
"""
def test_validClueMinimal(self):
c = Clue('This is a clue.')
self.assertEqual(c.clue, 'This is a clue.')
self.assertEqual(c.length, None)
self.assertEqual(c.typ, None)
self.assertEqual(c.known_letters, None)
self.assertEqual(c.tokens, ['this', 'is', 'a', 'clue'])
def test_validClueWithLength(self):
c = Clue('This is a clue. (7)')
self.assertEqual(c.clue, 'This is a clue.')
self.assertEqual(c.length, 7)
self.assertEqual(c.typ, None)
self.assertEqual(c.known_letters, None)
self.assertEqual(c.tokens, ['this', 'is', 'a', 'clue'])
def test_validClueWithLengthAndType(self):
c = Clue('This is a clue. (7)', typ='initial')
self.assertEqual(c.clue, 'This is a clue.')
self.assertEqual(c.length, 7)
self.assertEqual(c.typ, 'initial')
self.assertEqual(c.known_letters, None)
self.assertEqual(c.tokens, ['this', 'is', 'a', 'clue'])
def test_validClueWithLengthAndKnownLetters(self):
c = Clue('This is a clue. (7)', known_letters='????p??')
self.assertEqual(c.clue, 'This is a clue.')
self.assertEqual(c.length, 7)
self.assertEqual(c.typ, None)
self.assertEqual(c.known_letters, '????p??')
self.assertEqual(c.tokens, ['this', 'is', 'a', 'clue'])
def test_validClueWithEverything(self):
c = Clue('This is a clue. (7)', length=7, typ='anagram', known_letters='D???p??')
self.assertEqual(c.clue, 'This is a clue.')
self.assertEqual(c.length, 7)
self.assertEqual(c.typ, 'anagram')
self.assertEqual(c.known_letters, 'd???p??')
self.assertEqual(c.tokens, ['this', 'is', 'a', 'clue'])
def test_invalidClueLengthMismatch(self):
self.assertRaises(SolutionLengthMismatchException, Clue, 'Random clue. (4)', 5)
self.assertRaises(SolutionLengthMismatchException, Clue, 'Random clue. (4)', known_letters='?f?e???')
def test_invalidClueMultiWordLength(self):
self.assertRaises(UnsupportedClueException, Clue, 'Random clue. (4-4)')
self.assertRaises(UnsupportedClueException, Clue, 'Random clue. (3,5)')