def __is_available_assert_equal(self, gate, expected, function_mock, count=0): command = MagicMock() command.gate = gate api = MockApiClient() function_mock.return_value = count backend = QIBackend(quantum_inspire_api=api) actual = backend.is_available(command) self.assertEqual(actual, expected, msg="{} failed!".format(gate))
def test_is_available_verbose_prints_data(self): command = MagicMock() command.gate = CNOT api = MockApiClient() backend = QIBackend(quantum_inspire_api=api, verbose=3) with patch('sys.stdout', new_callable=io.StringIO) as mock_stdout: _ = backend.is_available(command) std_output = mock_stdout.getvalue() self.assertTrue(std_output.startswith('call to is_available with cmd'))