Skip to content

Commit c9a82d3

Browse files
author
Stephen DiAdamo
committed
Add test case for the Host version of get_qubit_by_id
1 parent 2783e9a commit c9a82d3

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

integration_tests/test_host.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import unittest
2-
from qunetsim.components.host import Host
2+
3+
from qunetsim.objects import Qubit
4+
from qunetsim.components import Host
35
from random import randint
46

57

@@ -15,6 +17,32 @@ def setUpClass(cls):
1517
def tearDownClass(cls):
1618
pass
1719

20+
def test_get_qubits_by_id(self):
21+
host = Host('A')
22+
q1 = Qubit(host)
23+
q2 = Qubit(host)
24+
q3 = Qubit(host)
25+
26+
host2 = Host('B')
27+
q4 = Qubit(host2)
28+
29+
host.add_epr('B', q1)
30+
host.add_data_qubit('C', q2)
31+
host.add_ghz_qubit('D', q3)
32+
33+
host2.add_data_qubit('A', q4)
34+
35+
# Test all types of qubits
36+
self.assertEqual(q1, host.get_qubit_by_id(q1.id))
37+
self.assertEqual(q2, host.get_qubit_by_id(q2.id))
38+
self.assertEqual(q3, host.get_qubit_by_id(q3.id))
39+
40+
# Test getting qubits from other hosts
41+
self.assertIsNone(host.get_qubit_by_id(q4.id))
42+
43+
# Test getting qubits that don't exist
44+
self.assertIsNone(host.get_qubit_by_id('fake'))
45+
1846
# @unittest.skip('')
1947
def test_connections(self):
2048
name = "A"

0 commit comments

Comments
 (0)