cape: models: add tests

This commit is contained in:
Willi Ballenthin
2023-08-16 08:57:54 +00:00
committed by GitHub
parent 046427cf55
commit 26539e68d9
2 changed files with 16 additions and 3 deletions

View File

@@ -6,14 +6,27 @@
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
import gzip
from pathlib import Path
import fixtures
from capa.features.extractors.cape.models import CapeReport
CD = Path(__file__).resolve().parent
CAPE_DIR = CD / "data" / "dynamic" / "cape"
def test_cape_model_can_load():
path = fixtures.get_data_path_by_name("0000a657")
@fixtures.parametrize(
"version,filename",
[
("v2.2", "0000a65749f5902c4d82ffa701198038f0b4870b00a27cfca109f8f933476d82.json.gz"),
("v2.2", "55dcd38773f4104b95589acc87d93bf8b4a264b4a6d823b73fb6a7ab8144c08b.json.gz"),
("v2.2", "77c961050aa252d6d595ec5120981abf02068c968f4a5be5958d10e87aa6f0e8.json.gz"),
("v2.2", "d46900384c78863420fb3e297d0a2f743cd2b6b3f7f82bf64059a168e07aceb7.json.gz"),
],
)
def test_cape_model_can_load(version: str, filename: str):
path = CAPE_DIR / version / filename
buf = gzip.decompress(path.read_bytes())
report = CapeReport.from_buf(buf)
assert report is not None