def test_workbench_get_all_malware():
    mal = Malware(id=constants.MALWARE_ID, **constants.MALWARE_KWARGS)
    save(mal)

    resp = malware()
    assert len(resp) == 1
    assert resp[0].id == constants.MALWARE_ID
Beispiel #2
0
def test_workbench_related_with_filters():
    malware = Malware(labels=["ransomware"],
                      name="CryptorBit",
                      created_by_ref=IDENTITY_ID)
    rel = Relationship(malware.id, 'variant-of', MALWARE_ID)
    save([malware, rel])

    filters = [Filter('created_by_ref', '=', IDENTITY_ID)]
    resp = get(MALWARE_ID).related(filters=filters)

    assert len(resp) == 1
    assert resp[0].name == malware.name
    assert resp[0].created_by_ref == IDENTITY_ID

    # filters arg can also be single filter
    resp = get(MALWARE_ID).related(filters=filters[0])
    assert len(resp) == 1