소스 검색

Added tests for a few untested lines

Clara Hobbs 7 년 전
부모
커밋
c9c58a5b4d
1개의 변경된 파일36개의 추가작업 그리고 12개의 파일을 삭제
  1. 36
    12
      test_pdbuddy/__init__.py

+ 36
- 12
test_pdbuddy/__init__.py 파일 보기

@@ -20,12 +20,20 @@ class SinkTestCase(unittest.TestCase):
20 20
                 flags=pdbuddy.SinkFlags.NONE, v=15000, i=3000)
21 21
         self.obj_valid_gb = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
22 22
                 flags=pdbuddy.SinkFlags.GIVEBACK, v=15000, i=3000)
23
-        self.obj_huge_vi = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
24
-                flags=pdbuddy.SinkFlags.NONE, v=65536, i=65536)
25
-        self.obj_big_vi = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
26
-                flags=pdbuddy.SinkFlags.NONE, v=20001, i=5001)
27
-        self.obj_neg_vi = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
28
-                flags=pdbuddy.SinkFlags.NONE, v=-1, i=-1)
23
+
24
+        self.obj_huge_v = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
25
+                flags=pdbuddy.SinkFlags.NONE, v=65536, i=1000)
26
+        self.obj_big_v = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
27
+                flags=pdbuddy.SinkFlags.NONE, v=20001, i=1000)
28
+        self.obj_neg_v = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
29
+                flags=pdbuddy.SinkFlags.NONE, v=-1, i=1000)
30
+
31
+        self.obj_huge_i = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
32
+                flags=pdbuddy.SinkFlags.NONE, v=5000, i=65536)
33
+        self.obj_big_i = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
34
+                flags=pdbuddy.SinkFlags.NONE, v=5000, i=5001)
35
+        self.obj_neg_i = pdbuddy.SinkConfig(status=pdbuddy.SinkStatus.VALID,
36
+                flags=pdbuddy.SinkFlags.NONE, v=5000, i=-1)
29 37
 
30 38
     def tearDown(self):
31 39
         # Close the connection to the PD Buddy Sink
@@ -52,17 +60,29 @@ class SinkTestCase(unittest.TestCase):
52 60
         self.pdbs.set_tmpcfg(self.obj_valid_gb)
53 61
         self.assertEqual(self.pdbs.get_tmpcfg(), self.obj_valid_gb)
54 62
 
55
-    def test_set_tmpcfg_huge_vi(self):
63
+    def test_set_tmpcfg_huge_v(self):
64
+        with self.assertRaises(ValueError):
65
+            self.pdbs.set_tmpcfg(self.obj_huge_v)
66
+
67
+    def test_set_tmpcfg_big_v(self):
68
+        with self.assertRaises(ValueError):
69
+            self.pdbs.set_tmpcfg(self.obj_big_v)
70
+
71
+    def test_set_tmpcfg_neg_v(self):
72
+        with self.assertRaises(ValueError):
73
+            self.pdbs.set_tmpcfg(self.obj_neg_v)
74
+
75
+    def test_set_tmpcfg_huge_i(self):
56 76
         with self.assertRaises(ValueError):
57
-            self.pdbs.set_tmpcfg(self.obj_huge_vi)
77
+            self.pdbs.set_tmpcfg(self.obj_huge_i)
58 78
 
59
-    def test_set_tmpcfg_big_vi(self):
79
+    def test_set_tmpcfg_big_i(self):
60 80
         with self.assertRaises(ValueError):
61
-            self.pdbs.set_tmpcfg(self.obj_big_vi)
81
+            self.pdbs.set_tmpcfg(self.obj_big_i)
62 82
 
63
-    def test_set_tmpcfg_neg_vi(self):
83
+    def test_set_tmpcfg_neg_i(self):
64 84
         with self.assertRaises(ValueError):
65
-            self.pdbs.set_tmpcfg(self.obj_neg_vi)
85
+            self.pdbs.set_tmpcfg(self.obj_neg_i)
66 86
 
67 87
     def test_write(self):
68 88
         self.test_set_tmpcfg_valid()
@@ -113,6 +133,10 @@ class SinkTestCase(unittest.TestCase):
113 133
         except ValueError:
114 134
             self.skipTest("Unknown value returned by PD Buddy Sink")
115 135
 
136
+    def test_send_command_invalid(self):
137
+        with self.assertRaises(KeyError):
138
+            self.pdbs.send_command("foo bar")
139
+
116 140
 
117 141
 class SinkConfigTestCase(unittest.TestCase):
118 142
 

Loading…
취소
저장