コード例 #1
0
 def test_contained_subgait(self):
     subgait = "test"
     graph = SubgaitGraph({
         "start": {
             "to": subgait
         },
         subgait: {
             "to": "end"
         }
     })
     self.assertIn(subgait, graph)
コード例 #2
0
 def test_get_correct_stop_transition(self):
     subgait = 'test'
     graph = SubgaitGraph({
         'start': {
             'to': subgait
         },
         subgait: {
             'stop': 'end'
         }
     })
     self.assertEqual(graph[(subgait, 'stop')], 'end')
コード例 #3
0
 def test_get_correct_to_transition(self):
     subgait = "test"
     graph = SubgaitGraph({
         "start": {
             "to": subgait
         },
         subgait: {
             "to": "end"
         }
     })
     self.assertEqual(graph[(subgait, "to")], "end")
コード例 #4
0
 def test_contained_subgait(self):
     subgait = 'test'
     graph = SubgaitGraph({
         'start': {
             'to': subgait
         },
         subgait: {
             'to': 'end'
         }
     })
     self.assertTrue(subgait in graph)
コード例 #5
0
 def test_subgait_transitions_to_end(self):
     graph = SubgaitGraph({
         "start": {
             "to": "1"
         },
         "1": {
             "to": "end",
             "stop": "2"
         },
         "2": {
             "to": "end"
         }
     })
     self.assertListEqual(graph.end_subgaits(), ["1", "2"])
コード例 #6
0
 def test_iter_transitions(self):
     graph = SubgaitGraph({
         'start': {
             'to': '1'
         },
         '1': {
             'to': '2'
         },
         '2': {
             'to': '1',
             'stop': 'end'
         }
     })
     self.assertListEqual(list(iter(graph)), [('1', '2'), ('2', '1')])
コード例 #7
0
 def test_stoppable_graph(self):
     graph = SubgaitGraph({
         "start": {
             "to": "1"
         },
         "1": {
             "to": "2"
         },
         "2": {
             "to": "1",
             "stop": "end"
         }
     })
     self.assertTrue(graph.is_stoppable())
コード例 #8
0
 def test_iter_transitions(self):
     graph = SubgaitGraph({
         "start": {
             "to": "1"
         },
         "1": {
             "to": "2"
         },
         "2": {
             "to": "1",
             "stop": "end"
         }
     })
     self.assertCountEqual(list(iter(graph)), [("1", "2"), ("start", "1"),
                                               ("2", "1"), ("2", "end")])
コード例 #9
0
 def test_get_correct_stop_transition(self):
     subgait = "test"
     stop_subgait = "stopping"
     graph = SubgaitGraph({
         "start": {
             "to": subgait
         },
         subgait: {
             "to": "end",
             "stop": stop_subgait
         },
         stop_subgait: {
             "to": "end"
         },
     })
     self.assertEqual(graph[(subgait, "stop")], stop_subgait)
コード例 #10
0
 def test_iter_transitions_with_increase_decrease(self):
     graph = SubgaitGraph({
         "start": {
             "to": "1"
         },
         "1": {
             "to": "end",
             "increase_size": "2",
             "decrease_size": "3"
         },
         "2": {
             "to": "end"
         },
         "3": {
             "to": "end"
         },
     })
     self.assertCountEqual(
         list(iter(graph)),
         [("1", "end"), ("start", "1"), ("3", "end"), ("2", "end")],
     )
コード例 #11
0
 def test_iter_transitions_without_subgaits(self):
     graph = SubgaitGraph({"start": {"to": "end"}})
     self.assertListEqual(list(iter(graph)), [("start", "end")])
コード例 #12
0
 def test_not_stoppable_graph(self):
     graph = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     self.assertFalse(graph.is_stoppable())
コード例 #13
0
 def test_get_invalid_transition(self):
     graph = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     self.assertIsNone(graph[("1", "stop")])
コード例 #14
0
 def test_get_no_subgait(self):
     graph = SubgaitGraph({'start': {'to': '1'}, '1': {'to': 'end'}})
     with self.assertRaises(KeyError):
         graph.__getitem__(('2', 'to'))
コード例 #15
0
 def test_get_invalid_transition(self):
     graph = SubgaitGraph({'start': {'to': '1'}, '1': {'to': 'end'}})
     self.assertIsNone(graph[('1', 'stop')])
コード例 #16
0
 def test_get_no_subgait(self):
     graph = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     with self.assertRaises(KeyError):
         graph.__getitem__(("2", "to"))
コード例 #17
0
 def test_not_contained_subgait(self):
     graph = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     self.assertNotIn("test", graph)
コード例 #18
0
 def test_iter_transitions_without_subgaits(self):
     graph = SubgaitGraph({'start': {'to': 'end'}})
     self.assertListEqual(list(iter(graph)), [])
コード例 #19
0
 def test_equal_graphs(self):
     graph1 = SubgaitGraph({'start': {'to': 'end'}})
     graph2 = SubgaitGraph({'start': {'to': 'end'}})
     self.assertTrue(graph1 == graph2)
コード例 #20
0
 def test_not_equal_graphs(self):
     graph1 = SubgaitGraph({'start': {'to': '1'}, '1': {'to': 'end'}})
     graph2 = SubgaitGraph({'start': {'to': 'end'}})
     self.assertFalse(graph1 == graph2)
コード例 #21
0
 def test_not_contained_subgait(self):
     graph = SubgaitGraph({'start': {'to': '1'}, '1': {'to': 'end'}})
     self.assertFalse('test' in graph)
コード例 #22
0
 def test_not_equal_graphs(self):
     graph1 = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     graph2 = SubgaitGraph({"start": {"to": "end"}})
     self.assertNotEqual(graph1, graph2)
コード例 #23
0
 def test_invalid_graph(self, name, graph):
     with self.assertRaises(SubgaitGraphError):
         SubgaitGraph(graph)
コード例 #24
0
 def test_valid_graph(self, name, graph):
     self.assertIsInstance(SubgaitGraph(graph), SubgaitGraph)
コード例 #25
0
 def test_subgaits_from_start(self):
     graph = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     self.assertListEqual(graph.start_subgaits(), ["1"])