-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_board_input_test.py
43 lines (34 loc) · 1.4 KB
/
parse_board_input_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
import unittest
from parse_board_input import parse as parse_bi
from ship import Submarine, PatrolBoat, Aircraft
class TestParseBoardInput(unittest.TestCase):
def test_input_1(self):
expected = (Submarine, ('B', 2), True)
input = "Place subMarine at B2 horizontally"
self.assertEquals(parse_bi(input), expected)
def test_input_2(self):
expected = (Aircraft, ('E', 4), False)
input = "place aircraft at E4 vertically"
self.assertEquals(parse_bi(input), expected)
def test_input_3(self):
expected = (PatrolBoat, ('C', 6), False)
input = "place patrol boat at C6 vertically"
self.assertEquals(parse_bi(input), expected)
def test_input_4(self):
expected = (PatrolBoat, ('E', 3), True)
input = "place patrol boats at E3 horizontally"
self.assertEquals(parse_bi(input), expected)
def test_invalid_ship(self):
with self.assertRaises(ValueError):
input = "Place sandwich on C3 horizontally"
parse_bi(input)
def test_invalid_position(self):
with self.assertRaises(ValueError):
input = "Place patrol boat on Z3 vertically"
parse_bi(input)
def test_invalid_orientation(self):
with self.assertRaises(ValueError):
input = "Place submarine on d1 diagonally"
parse_bi(input)
if __name__ == '__main__':
unittest.main()