def test_hardware_backend2(self): with mock.patch( 'quantuminspire.qiskit.quantum_inspire_provider.QuantumInspireAPI' ) as api: quantum_inpire_provider = QuantumInspireProvider() with self.assertRaises(QiskitBackendError): quantum_inpire_provider.backends(name='quantum-inspire') email = '*****@*****.**' secret = 'secret' quantum_inpire_provider.set_basic_authentication(email, secret) authentication = BasicAuthentication(email, secret) api.assert_called_with(QI_URL, authentication, None) quantum_inpire_provider._api.get_backend_types.return_value = [ self.hardware_backend_type2 ] backend = quantum_inpire_provider.get_backend(name='qi_hardware') self.assertEqual('qi_hardware', backend.name()) self.assertEqual(backend.configuration().coupling_map, [[0, 1], [1, 0]]) self.assertFalse(backend.configuration().simulator) self.assertEqual(2, backend.configuration().n_qubits) self.assertTrue(backend.configuration().memory) self.assertEqual(4096, backend.configuration().max_shots) self.assertEqual(1, backend.configuration().max_experiments) self.assertFalse(backend.configuration().conditional) self.assertEqual(backend.configuration().basis_gates, [ 'rx', 'ry', 'rz', 'x', 'y', 'z', 'h', 'id', 't', 'tdg', 's', 'sdg', 'cz', 'cx', 'swap', 'ccx', 'u1', 'u2', 'u3' ])
def test_hardware_backend(self): with mock.patch( 'quantuminspire.qiskit.quantum_inspire_provider.QuantumInspireAPI' ) as api: quantum_inpire_provider = QuantumInspireProvider() with self.assertRaises(ApiError): quantum_inpire_provider.backends(name='quantum-inspire') email = '*****@*****.**' secret = 'secret' quantum_inpire_provider.set_basic_authentication(email, secret) authentication = BasicAuthentication(email, secret) api.assert_called_with(QI_URL, authentication) quantum_inpire_provider._api.get_backend_types.return_value = [ self.hardware_backend_type ] backend = quantum_inpire_provider.get_backend(name='qi_hardware') self.assertEqual('qi_hardware', backend.name()) self.assertEqual(backend.configuration().coupling_map, [(0, 2), (1, 2), (2, 0), (2, 1), (2, 3), (2, 4), (3, 2), (4, 2)]) self.assertFalse(backend.configuration().simulator) self.assertEqual(5, backend.configuration().n_qubits) self.assertTrue(backend.configuration().memory) self.assertEqual(2048, backend.configuration().max_shots) self.assertEqual(1, backend.configuration().max_experiments) self.assertFalse(backend.configuration().conditional) self.assertEqual(backend.configuration().basis_gates, ['rx', 'rz', 'x', 's', 'z', 'h', 'tdg', 'cz'])
def test_backends(self): with mock.patch( 'quantuminspire.qiskit.quantum_inspire_provider.QuantumInspireAPI' ) as api: quantum_inpire_provider = QuantumInspireProvider() with self.assertRaises(QiskitBackendError): quantum_inpire_provider.backends(name='quantum-inspire') email = '*****@*****.**' secret = 'secret' quantum_inpire_provider.set_basic_authentication(email, secret) authentication = BasicAuthentication(email, secret) api.assert_called_with(QI_URL, authentication, None) quantum_inpire_provider._api.get_backend_types.return_value = [ self.simulator_backend_type ] backend = quantum_inpire_provider.get_backend(name='qi_simulator') self.assertEqual('qi_simulator', backend.name()) with self.assertRaises(QiskitBackendNotFoundError) as error: quantum_inpire_provider.get_backend(name='not-quantum-inspire') self.assertEqual(('No backend matches the criteria', ), error.exception.args)
def test_set_basic_authentication(self): with mock.patch( 'quantuminspire.qiskit.quantum_inspire_provider.QuantumInspireAPI' ) as api: quantum_inpire_provider = QuantumInspireProvider() with self.assertRaises(ApiError): quantum_inpire_provider.backends(name='quantum-inspire') email = '*****@*****.**' secret = 'secret' quantum_inpire_provider.set_basic_authentication(email, secret) authentication = BasicAuthentication(email, secret) api.assert_called_with(QI_URL, authentication) quantum_inpire_provider._api.get_backend_types.return_value = [ self.simulator_backend_type ] backend = quantum_inpire_provider.get_backend(name='qi_simulator') self.assertEqual('qi_simulator', backend.name())