File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change 11import unittest
2- from qunetsim .components .host import Host
2+
3+ from qunetsim .objects import Qubit
4+ from qunetsim .components import Host
35from 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"
You can’t perform that action at this time.
0 commit comments