Beispiel #1
0
 def test_stoppable_graph(self):
     graph = SubgaitGraph({
         "start": {
             "to": "1"
         },
         "1": {
             "to": "2"
         },
         "2": {
             "to": "1",
             "stop": "end"
         }
     })
     self.assertTrue(graph.is_stoppable())
Beispiel #2
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"])
Beispiel #3
0
 def test_contained_subgait(self):
     subgait = "test"
     graph = SubgaitGraph({
         "start": {
             "to": subgait
         },
         subgait: {
             "to": "end"
         }
     })
     self.assertIn(subgait, graph)
Beispiel #4
0
 def test_get_correct_to_transition(self):
     subgait = "test"
     graph = SubgaitGraph({
         "start": {
             "to": subgait
         },
         subgait: {
             "to": "end"
         }
     })
     self.assertEqual(graph[(subgait, "to")], "end")
Beispiel #5
0
 def test_get_correct_stop_transition(self):
     subgait = 'test'
     graph = SubgaitGraph({
         'start': {
             'to': subgait
         },
         subgait: {
             'stop': 'end'
         }
     })
     self.assertEqual(graph[(subgait, 'stop')], 'end')
Beispiel #6
0
 def test_contained_subgait(self):
     subgait = 'test'
     graph = SubgaitGraph({
         'start': {
             'to': subgait
         },
         subgait: {
             'to': 'end'
         }
     })
     self.assertTrue(subgait in graph)
Beispiel #7
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')])
Beispiel #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")])
Beispiel #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)
Beispiel #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")],
     )
Beispiel #11
0
 def test_iter_transitions_without_subgaits(self):
     graph = SubgaitGraph({"start": {"to": "end"}})
     self.assertListEqual(list(iter(graph)), [("start", "end")])
Beispiel #12
0
 def test_not_stoppable_graph(self):
     graph = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     self.assertFalse(graph.is_stoppable())
Beispiel #13
0
 def test_get_invalid_transition(self):
     graph = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     self.assertIsNone(graph[("1", "stop")])
Beispiel #14
0
 def test_get_no_subgait(self):
     graph = SubgaitGraph({'start': {'to': '1'}, '1': {'to': 'end'}})
     with self.assertRaises(KeyError):
         graph.__getitem__(('2', 'to'))
Beispiel #15
0
 def test_get_invalid_transition(self):
     graph = SubgaitGraph({'start': {'to': '1'}, '1': {'to': 'end'}})
     self.assertIsNone(graph[('1', 'stop')])
Beispiel #16
0
 def test_get_no_subgait(self):
     graph = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     with self.assertRaises(KeyError):
         graph.__getitem__(("2", "to"))
Beispiel #17
0
 def test_not_contained_subgait(self):
     graph = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     self.assertNotIn("test", graph)
Beispiel #18
0
 def test_iter_transitions_without_subgaits(self):
     graph = SubgaitGraph({'start': {'to': 'end'}})
     self.assertListEqual(list(iter(graph)), [])
Beispiel #19
0
 def test_equal_graphs(self):
     graph1 = SubgaitGraph({'start': {'to': 'end'}})
     graph2 = SubgaitGraph({'start': {'to': 'end'}})
     self.assertTrue(graph1 == graph2)
Beispiel #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)
Beispiel #21
0
 def test_not_contained_subgait(self):
     graph = SubgaitGraph({'start': {'to': '1'}, '1': {'to': 'end'}})
     self.assertFalse('test' in graph)
Beispiel #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)
Beispiel #23
0
 def test_invalid_graph(self, name, graph):
     with self.assertRaises(SubgaitGraphError):
         SubgaitGraph(graph)
Beispiel #24
0
 def test_valid_graph(self, name, graph):
     self.assertIsInstance(SubgaitGraph(graph), SubgaitGraph)
Beispiel #25
0
 def test_subgaits_from_start(self):
     graph = SubgaitGraph({"start": {"to": "1"}, "1": {"to": "end"}})
     self.assertListEqual(graph.start_subgaits(), ["1"])