Exemplo n.º 1
0
def test_job_fields_cannot_get_status():
    job_dict = {
        'id': 'my_id',
        'target': 'qpu',
        'name': 'bacon',
        'qubits': '5',
        'status': 'running',
        'metadata': {
            'shots': 1000
        },
    }
    mock_client = mock.MagicMock()
    mock_client.get_job.side_effect = ionq.IonQException('bad')
    job = ionq.Job(mock_client, job_dict)
    with pytest.raises(ionq.IonQException, match='bad'):
        _ = job.target()
    with pytest.raises(ionq.IonQException, match='bad'):
        _ = job.name()
    with pytest.raises(ionq.IonQException, match='bad'):
        _ = job.num_qubits()
    with pytest.raises(ionq.IonQException, match='bad'):
        _ = job.repetitions()
Exemplo n.º 2
0
def test_ionq_exception_str():
    ex = ionq.IonQException('err', status_code=501)
    assert str(ex) == 'Status code: 501, Message: \'err\''
Exemplo n.º 3
0
def test_ionq_exception():
    ex = ionq.IonQException(message='Hello', status_code=500)
    assert str(ex) == 'Status code: 500, Message: \'Hello\''
    assert ex.status_code == 500