def test_attributes(request):
    parsed = AnalysisListRequest(**request)

    assert parsed.dict(by_alias=True) == request
    assert parsed.headers == {}
    assert parsed.payload == {}
    assert parsed.method == "GET"
    assert parsed.endpoint == "v1/analyses"
    assert parsed.parameters["createdBy"] == request["createdBy"]
    assert parsed.parameters["groupId"] == request["groupId"]
    assert parsed.parameters["groupName"] == request["groupName"]
    assert parsed.parameters["mainSource"] == request["mainSource"]
    assert parsed.parameters["offset"] == request["offset"]
Beispiel #2
0
def test_analysis_list_request_from_empty_json():
    req = AnalysisListRequest.from_json("{}")
    assert req.to_dict() == {
        "offset": None,
        "createdBy": None,
        "groupName": None,
        "dateFrom": None,
        "dateTo": None,
        "groupId": None,
        "mainSource": None,
    }
Beispiel #3
0
        status=STATUS_1,
        submitted_at=SUBMITTED_AT_1,
        submitted_by=SUBMITTED_BY_1,
        client_tool_name=CLIENT_TOOL_NAME_1,
    )
)

# ANALYSIS LIST
ANALYSIS_LIST_REQUEST_DICT = {
    "offset": OFFSET,
    "dateFrom": DATE_FROM,
    "dateTo": DATE_TO,
}
ANALYSIS_LIST_REQUEST_OBJECT = AnalysisListRequest(
    offset=OFFSET,
    date_from=dateutil.parser.parse(DATE_FROM),
    date_to=dateutil.parser.parse(DATE_TO),
)
ANALYSIS_LIST_RESPONSE_DICT = {
    "analyses": [
        {
            "uuid": UUID_1,
            "apiVersion": API_VERSION_1,
            "maruVersion": MARU_VERSION_1,
            "mythrilVersion": MYTHRIL_VERSION_1,
            "harveyVersion": HARVEY_VERSION_1,
            "queueTime": QUEUE_TIME_1,
            "runTime": RUN_TIME_1,
            "status": STATUS_1,
            "submittedAt": SUBMITTED_AT_1,
            "submittedBy": SUBMITTED_BY_1,
Beispiel #4
0
def test_analysis_list_request_from_valid_dict():
    req = AnalysisListRequest.from_dict(DICT_DATA)
    assert_analysis_list_request(req)
Beispiel #5
0
def test_analysis_list_request_from_valid_json():
    req = AnalysisListRequest.from_json(JSON_DATA)
    assert_analysis_list_request(req)
Beispiel #6
0
import json
from datetime import datetime

from mythx_models.request import AnalysisListRequest

from .common import get_test_case

JSON_DATA, DICT_DATA = get_test_case("testdata/analysis-list-request.json")
OBJ_DATA = AnalysisListRequest.from_json(JSON_DATA)


def assert_analysis_list_request(req):
    assert req.offset == "test"
    assert req.date_from == datetime(2019, 2, 7, 0, 40, 49, 58158)
    assert req.date_to == datetime(2019, 2, 7, 0, 40, 49, 58158)
    assert req.payload == {}
    assert req.method == "GET"
    assert req.parameters == DICT_DATA
    assert req.headers == {}


def test_analysis_list_request_from_valid_json():
    req = AnalysisListRequest.from_json(JSON_DATA)
    assert_analysis_list_request(req)


def test_analysis_list_request_from_empty_json():
    req = AnalysisListRequest.from_json("{}")
    assert req.to_dict() == {
        "offset": None,
        "createdBy": None,
def test_serde(response):
    resp = AnalysisListRequest(**response)
    assert resp.dict(by_alias=True) == response