Skip to content

Commit 1a071a7

Browse files
committed
Removed redundant tests
1 parent f04b6c7 commit 1a071a7

File tree

3 files changed

+22
-93
lines changed

3 files changed

+22
-93
lines changed

tests/action_tests/GetActionTests.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from Node import Node
44
from NodePath import NodePath
5-
from TreeRoot import TreeRoot
65
from actions.BasicActions import GetAction
76

87

@@ -15,37 +14,18 @@ def setUp(self):
1514

1615
self.get = GetAction()
1716

18-
def test_get(self):
17+
def test_action_name(self):
18+
self.assertEqual(NodePath('get'), self.get.path)
19+
20+
def test_normal_usage(self):
1921
self.assertEqual(123, self.get(self.root['integer']))
2022
self.assertEqual('foobar', self.get(self.root['string']))
2123
self.assertEqual(None, self.get(self.root['empty']))
2224

23-
def test_get_any_arguments(self):
25+
def test_surplus_arguments(self):
2426
with self.assertRaises(TypeError):
2527
self.get(self.root['empty'], 1 ,2 ,3)
2628

2729

28-
class GetActionNodeTests(unittest.TestCase):
29-
def setUp(self):
30-
self.root = TreeRoot()
31-
self.root.create('.integer', 123)
32-
self.root.create('.string', 'foobar')
33-
self.root.create('.empty')
34-
35-
def test_get(self):
36-
integer = self.root.execute('.integer', NodePath('get'))
37-
self.assertEqual(123, integer)
38-
39-
string = self.root.execute('.string', NodePath('get'))
40-
self.assertEqual('foobar', string)
41-
42-
empty = self.root.execute('.empty', NodePath('get'))
43-
self.assertEqual(None, empty)
44-
45-
def test_get_any_arguments(self):
46-
with self.assertRaises(TypeError):
47-
self.root.execute('.', NodePath('get'), 3, 2, 1)
48-
49-
5030
if __name__ == '__main__':
5131
unittest.main()

tests/action_tests/ListActionTests.py

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from Node import Node
44
from NodePath import NodePath
5-
from TreeRoot import TreeRoot
65
from actions.BasicActions import ListAction
76

87

@@ -14,56 +13,32 @@ def setUp(self):
1413

1514
self.list = ListAction()
1615

17-
def test_list_all_empty(self):
16+
def test_action_names(self):
17+
self.assertEqual(NodePath('list'), self.list.path)
18+
self.assertEqual(NodePath('all'), self.list.list_all.path)
19+
self.assertEqual(NodePath('nodes'), self.list.list_nodes.path)
20+
self.assertEqual(NodePath('attributes'), self.list.list_attributes.path)
21+
22+
def test_all_empty(self):
1823
empty_list = self.list.list_all(Node())
1924
self.assertListEqual([], empty_list)
2025

21-
def test_list_all_nodes_and_attributes(self):
26+
def test_all_nodes_and_attributes(self):
2227
root_list = self.list.list_all(self.root)
2328
self.assertListEqual(['@attribute', 'empty'], root_list)
2429

25-
def test_list_nodes(self):
30+
def test_nodes(self):
2631
root_list = self.list.list_nodes(self.root)
2732
self.assertListEqual(['empty'], root_list)
2833

29-
def test_list_attributes(self):
34+
def test_attributes(self):
3035
root_list = self.list.list_attributes(self.root)
3136
self.assertListEqual(['@attribute'], root_list)
3237

33-
def test_list_default(self):
38+
def test_default(self):
3439
root_list = self.list(self.root)
3540
self.assertListEqual(['empty'], root_list)
3641

3742

38-
class ListActionNodeTests(unittest.TestCase):
39-
def setUp(self):
40-
self.root = TreeRoot()
41-
self.root.create('.test')
42-
self.root.create('.test.@attribute', 'AAA')
43-
self.root.create('.test.empty', '')
44-
45-
# Note: ListAction should be already present in TreeRoot
46-
47-
def test_list_all_empty(self):
48-
empty_list = self.root.execute('.test.empty', NodePath('list.all'))
49-
self.assertListEqual([], empty_list)
50-
51-
def test_list_all_nodes_and_attributes(self):
52-
root_list = self.root.execute('.test', NodePath('list.all'))
53-
self.assertListEqual(['@attribute', 'empty'], root_list)
54-
55-
def test_list_nodes(self):
56-
root_list = self.root.execute('.test', NodePath('list.nodes'))
57-
self.assertListEqual(['empty'], root_list)
58-
59-
def test_list_attributes(self):
60-
root_list = self.root.execute('.test', NodePath('list.attributes'))
61-
self.assertListEqual(['@attribute'], root_list)
62-
63-
def test_list_default(self):
64-
root_list = self.root.execute('.test', NodePath('list'))
65-
self.assertListEqual(['empty'], root_list)
66-
67-
6843
if __name__ == '__main__':
6944
unittest.main()

tests/action_tests/SetActionTests.py

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from Node import Node
44
from NodePath import NodePath
5-
from TreeRoot import TreeRoot
65
from actions.BasicActions import SetAction
76

87

@@ -15,13 +14,16 @@ def setUp(self):
1514

1615
self.set = SetAction()
1716

18-
def test_set(self):
17+
def test_action_name(self):
18+
self.assertEqual(NodePath('set'), self.set.path)
19+
20+
def test_normal_usage(self):
1921
self.set(self.root['integer'], 321)
2022
self.assertEqual(321, self.root['integer'].get())
2123
self.set(self.root['string'], 'barfoo')
2224
self.assertEqual('barfoo', self.root['string'].get())
2325

24-
def test_set_different_type(self):
26+
def test_different_type(self):
2527
with self.assertRaises(TypeError):
2628
self.set(self.root['integer'], 'string')
2729

@@ -30,38 +32,10 @@ def test_set_none(self):
3032
with self.assertRaises(TypeError):
3133
self.set(self.root['empty'], 23)
3234

33-
def test_set_too_many_arguments(self):
35+
def test_too_many_arguments(self):
3436
with self.assertRaises(TypeError):
3537
self.set(self.root['integer'], 1, 2, 3)
3638

3739

38-
class SetActionNodeTests(unittest.TestCase):
39-
def setUp(self):
40-
self.root = TreeRoot()
41-
self.root.create('.integer', 123)
42-
self.root.create('.string', 'foobar')
43-
self.root.create('.empty')
44-
45-
def test_set(self):
46-
self.root.execute('.integer', NodePath('set'), 444)
47-
self.assertEqual(444, self.root.get('.integer'))
48-
49-
self.root.execute('.string', NodePath('set'), 'barfoo')
50-
self.assertEqual('barfoo', self.root.get('.string'))
51-
52-
def test_set_different_type(self):
53-
with self.assertRaises(TypeError):
54-
self.root.execute('.integer', NodePath('set'), 'string')
55-
56-
def test_set_none(self):
57-
# This behaviour is subject to change
58-
with self.assertRaises(TypeError):
59-
self.root.execute('.empty', NodePath('set'), 444)
60-
61-
def test_set_any_arguments(self):
62-
with self.assertRaises(TypeError):
63-
self.root.execute('.integer', NodePath('set'), 3, 2, 1)
64-
65-
6640
if __name__ == '__main__':
6741
unittest.main()

0 commit comments

Comments
 (0)