-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSimpleEncryption02_test.py
66 lines (51 loc) · 1.98 KB
/
SimpleEncryption02_test.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
62
63
64
65
66
from unittest import TestCase
from SimpleEncryption02IndexDifference_5kyu import decrypt, encrypt, step_1, step_2, step_3, step_2_dec
import string
class TestDecrypt(TestCase):
def setUp(self):
self.vocabulary = string.ascii_uppercase + string.ascii_lowercase + string.digits + ".,:;-?! '()$%&" + '"'
def test_EmptyIsEmpty(self):
self.assertEquals(
decrypt(""),
"")
def test_NullIsNull(self):
self.assertEquals(
decrypt(None),
None)
def test_Step2Dec(self):
self.assertEquals(
step_2_dec("B61kujla"),
list("BUsInEsS"))
def test_TrueCaseIsOk(self):
self.assertEquals(
decrypt("$-Wy,dM79H'i'o$n0C&I.ZTcMJw5vPlZc Hn!krhlaa:khV mkL;gvtP-S7Rt1Vp2RV:wV9VuhO Iz3dqb.U0w"),
"Do the kata \"Kobayashi-Maru-Test!\" Endless fun and excitement when finding a solution!")
class TestEncrypt(TestCase):
def setUp(self):
self.vocabulary = string.ascii_uppercase + string.ascii_lowercase + string.digits + ".,:;-?! '()$%&" + '"'
def test_EmptyIsEmpty(self):
self.assertEquals(
encrypt(""),
"")
def test_NullIsNull(self):
self.assertEquals(
encrypt(None),
None)
def test_CharUnknownIsException(self):
self.assertRaises(Exception, encrypt, "b@e")
def test_Step1(self):
self.assertEquals(
step_1(list("Business")),
list("BUsInEsS"))
def test_Step2(self):
self.assertEquals(
step_2("BUsInEsS"),
list("B61kujla"))
def test_Step3(self):
self.assertEquals(
step_3(list("B61kujla")),
list("&61kujla"))
def test_TrueCaseIsOk(self):
self.assertEquals(
encrypt("Do the kata \"Kobayashi-Maru-Test!\" Endless fun and excitement when finding a solution!"),
"$-Wy,dM79H'i'o$n0C&I.ZTcMJw5vPlZc Hn!krhlaa:khV mkL;gvtP-S7Rt1Vp2RV:wV9VuhO Iz3dqb.U0w")