From c6d6d8b5adb48fffd5ffcefa60febd83a306c7cd Mon Sep 17 00:00:00 2001
From: angloth <angus.lothian@hotmail.com>
Date: Mon, 2 Mar 2020 10:53:06 +0100
Subject: [PATCH] Fix some errors with graph id tests

---
 test/fixtures/graph_id.py                |  4 ++++
 test/graph_id/test_graph_id.py           |  8 ++++++--
 test/graph_id/test_graph_id_generator.py | 26 ++++++++++++++++++++++++
 test/port/test_port.py                   |  4 ++--
 4 files changed, 38 insertions(+), 4 deletions(-)
 create mode 100644 test/graph_id/test_graph_id_generator.py

diff --git a/test/fixtures/graph_id.py b/test/fixtures/graph_id.py
index af6a37f8..8cc438a0 100644
--- a/test/fixtures/graph_id.py
+++ b/test/fixtures/graph_id.py
@@ -16,4 +16,8 @@ def graph_ids():
         GraphID("ÅÄÖ", 2), GraphID("", 3), \
         GraphID("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4)]
     
+
+@pytest.fixture
+def graph_id_generator():
+    return GraphIDGenerator()
     
diff --git a/test/graph_id/test_graph_id.py b/test/graph_id/test_graph_id.py
index 3de26ca9..9554c04c 100644
--- a/test/graph_id/test_graph_id.py
+++ b/test/graph_id/test_graph_id.py
@@ -11,24 +11,26 @@ from b_asic.graph_id import GraphID
 import pytest
 
 def test_create_graph_id():
-    """
-    Tests creation 
+    """Tests creation of graph ID objects."""
     graph_id = GraphID("add", 1)
 
     assert graph_id.graph_id_type == "add"
     assert graph_id.graph_id_number == 1
 
+def test_create_graph_id_empty_string():
     graph_id2 = GraphID("", 2)
 
     assert graph_id2.graph_id_type == ""
     assert graph_id2.graph_id_number == 2
 
+def test_create_graph_id_long_string():
     graph_id3 = GraphID("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 3)
 
     assert graph_id3.graph_id_type == "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     assert graph_id3.graph_id_number == 3
 
 def test_graph_id_str(graph_ids):
+    """Test the str() function of graph ids."""
     assert str(graph_ids[0]) == "add1"
     assert str(graph_ids[1]) == "add2"
     assert str(graph_ids[2]) == "sig1"
@@ -39,6 +41,7 @@ def test_graph_id_str(graph_ids):
     assert str(graph_ids[7]) == "ABCDEFGHIJKLMNOPQRSTUVWXYZ4"
 
 def test_graph_id_repr(graph_ids):
+    """Test the repr() function of graph ids."""
     assert repr(graph_ids[0]) == "add1"
     assert repr(graph_ids[1]) == "add2"
     assert repr(graph_ids[2]) == "sig1"
@@ -49,6 +52,7 @@ def test_graph_id_repr(graph_ids):
     assert repr(graph_ids[7]) == "ABCDEFGHIJKLMNOPQRSTUVWXYZ4"
 
 def test_graph_id_eq(graph_ids):
+    """Test the equality of graph ids.""" 
     assert graph_ids[0] == graph_ids[0]
     assert graph_ids[0] != graph_ids[1]
     assert graph_ids[2] == graph_ids[3]
diff --git a/test/graph_id/test_graph_id_generator.py b/test/graph_id/test_graph_id_generator.py
new file mode 100644
index 00000000..71eb02b0
--- /dev/null
+++ b/test/graph_id/test_graph_id_generator.py
@@ -0,0 +1,26 @@
+"""
+B-ASIC test suite for graph id generator.
+"""
+
+from b_asic.graph_id import GraphIDGenerator, GraphID
+
+import pytest
+
+def test_empty_string_generator(graph_id_generator):
+    """Test the graph id generator for an empty string type."""
+    assert graph_id_generator.get_next_id("") == GraphID("", 1)
+    assert graph_id_generator.get_next_id("") == GraphID("", 2)
+
+
+def test_normal_string_generator(graph_id_generator):
+    """"Test the graph id generator for a normal string type."""
+    assert graph_id_generator.get_next_id("add") == GraphID("add", 1)
+    assert graph_id_generator.get_next_id("add") == GraphID("add", 2)
+
+def test_different_strings_generator(graph_id_generator):
+    """Test the graph id generator for different strings."""
+    assert graph_id_generator.get_next_id("sub") == GraphID("sub", 1)
+    assert graph_id_generator.get_next_id("mul") == GraphID("mul", 1)
+    assert graph_id_generator.get_next_id("sub") == GraphID("sub", 2)
+    assert graph_id_generator.get_next_id("mul") == GraphID("mul", 2)
+    
\ No newline at end of file
diff --git a/test/port/test_port.py b/test/port/test_port.py
index 56cb9be2..5fcf563d 100644
--- a/test/port/test_port.py
+++ b/test/port/test_port.py
@@ -13,8 +13,8 @@ def test_connect_one_signal_to_port(signal):
     assert port.signal() == signal
 
 def test_change_port_signal():
-    source = SignalSource(Addition(0), 1)
-    dest = SignalDestination(Addition(1),2)
+    source = SignalSource(Addition, 1)
+    dest = SignalDestination(Addition,2)
     signal1 = Signal(1, source, dest)
     signal2 = Signal(2, source, dest)
 
-- 
GitLab