import json

import pytest

from anonapi.responses import (
    format_job_info_list,
    parse_job_infos_response,
    APIParseResponseError,
)
from tests.mock_responses import RequestsMockResponseExamples


def test_jobs_response():
    response_raw = json.loads(RequestsMockResponseExamples.JOBS_LIST_GET_JOBS)
    info_list = parse_job_infos_response(response_raw)

    list_str = format_job_info_list(info_list)
    assert (
        list_str  # Just check that something was returned and nothing crashed
    )
    assert len(info_list) == 2

    response_raw = json.loads(
        RequestsMockResponseExamples.JOBS_LIST_GET_JOBS_LIST
    )
    info_list = parse_job_infos_response(response_raw)
    assert [x.status for x in info_list] == ["DONE", "UPLOADED", "UPLOADED"]

    list_str = format_job_info_list(info_list)
    assert list_str


def test_jobs_response_exception():
    with pytest.raises(APIParseResponseError):
        parse_job_infos_response("definitly a wrong response")

    with pytest.raises(APIParseResponseError):
        parse_job_infos_response({"1": {"message": "also not great"}})

39ec963c35ab81ace93953d7da3ccdb923541597
<mask token>

<mask token>


def test_jobs_response():
    response_raw = json.loads(RequestsMockResponseExamples.JOBS_LIST_GET_JOBS)
    info_list = parse_job_infos_response(response_raw)
    list_str = format_job_info_list(info_list)
    assert list_str
    assert len(info_list) == 2
    response_raw = json.loads(RequestsMockResponseExamples.
        JOBS_LIST_GET_JOBS_LIST)
    info_list = parse_job_infos_response(response_raw)
    assert [x.status for x in info_list] == ['DONE', 'UPLOADED', 'UPLOADED']
    list_str = format_job_info_list(info_list)
    assert list_str


<mask token>

<mask token>


def test_jobs_response():
    response_raw = json.loads(RequestsMockResponseExamples.JOBS_LIST_GET_JOBS)
    info_list = parse_job_infos_response(response_raw)
    list_str = format_job_info_list(info_list)
    assert list_str
    assert len(info_list) == 2
    response_raw = json.loads(RequestsMockResponseExamples.
        JOBS_LIST_GET_JOBS_LIST)
    info_list = parse_job_infos_response(response_raw)
    assert [x.status for x in info_list] == ['DONE', 'UPLOADED', 'UPLOADED']
    list_str = format_job_info_list(info_list)
    assert list_str


def test_jobs_response_exception():
    with pytest.raises(APIParseResponseError):
        parse_job_infos_response('definitly a wrong response')
    with pytest.raises(APIParseResponseError):
        parse_job_infos_response({'1': {'message': 'also not great'}})

import json
import pytest
from anonapi.responses import format_job_info_list, parse_job_infos_response, APIParseResponseError
from tests.mock_responses import RequestsMockResponseExamples


def test_jobs_response():
    response_raw = json.loads(RequestsMockResponseExamples.JOBS_LIST_GET_JOBS)
    info_list = parse_job_infos_response(response_raw)
    list_str = format_job_info_list(info_list)
    assert list_str
    assert len(info_list) == 2
    response_raw = json.loads(RequestsMockResponseExamples.
        JOBS_LIST_GET_JOBS_LIST)
    info_list = parse_job_infos_response(response_raw)
    assert [x.status for x in info_list] == ['DONE', 'UPLOADED', 'UPLOADED']
    list_str = format_job_info_list(info_list)
    assert list_str


def test_jobs_response_exception():
    with pytest.raises(APIParseResponseError):
        parse_job_infos_response('definitly a wrong response')
    with pytest.raises(APIParseResponseError):
        parse_job_infos_response({'1': {'message': 'also not great'}})

import json

import pytest

from anonapi.responses import (
    format_job_info_list,
    parse_job_infos_response,
    APIParseResponseError,
)
from tests.mock_responses import RequestsMockResponseExamples


def test_jobs_response():
    response_raw = json.loads(RequestsMockResponseExamples.JOBS_LIST_GET_JOBS)
    info_list = parse_job_infos_response(response_raw)

    list_str = format_job_info_list(info_list)
    assert (
        list_str  # Just check that something was returned and nothing crashed
    )
    assert len(info_list) == 2

    response_raw = json.loads(
        RequestsMockResponseExamples.JOBS_LIST_GET_JOBS_LIST
    )
    info_list = parse_job_infos_response(response_raw)
    assert [x.status for x in info_list] == ["DONE", "UPLOADED", "UPLOADED"]

    list_str = format_job_info_list(info_list)
    assert list_str


def test_jobs_response_exception():
    with pytest.raises(APIParseResponseError):
        parse_job_infos_response("definitly a wrong response")

    with pytest.raises(APIParseResponseError):
        parse_job_infos_response({"1": {"message": "also not great"}})
