Skip to content

Commit

Permalink
Fix MARI rules tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pasarus committed Dec 4, 2024
1 parent a398922 commit 40baacc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion rundetection/rules/mari_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class MariStitchRule(Rule[bool]):
"""
The MariStitchRule is the rule that applies
The MariStitchRule is the rule that applies, dependent on the other rules running first. This runs last.
"""

def __init__(self, value: bool) -> None:
Expand Down
24 changes: 6 additions & 18 deletions test/rules/test_mari_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
Test for mari rules
"""

import json
import os
from pathlib import Path
from typing import Any
from unittest.mock import patch

import pytest
Expand All @@ -14,18 +12,6 @@
from rundetection.rules.mari_rules import MariMaskFileRule, MariStitchRule, MariWBVANRule


def get_specification_value(key: str) -> Any:
"""
Given a key, return the specification value
:param key: The key for the rule
:return: The rule value
"""
path = Path("rundetection/specifications/mari_specification.json")
with path.open(encoding="utf-8") as fle:
spec = json.load(fle)
return spec[key]


@pytest.fixture(autouse=True)
def _working_directory_fix():
# Set dir to repo root for purposes of the test.
Expand Down Expand Up @@ -110,14 +96,16 @@ def test_verify_multiple_runs(mari_stitch_rule_true, job_request):
:param job_request: job request fixture
:return: None
"""
rule = MariMaskFileRule("some link")
rule.verify(job_request)
rule = MariWBVANRule(1234567)
rule.verify(job_request)
with patch("rundetection.rules.mari_rules.MariStitchRule._get_runs_to_stitch", return_value=[1, 2, 3]):
mari_stitch_rule_true.verify(job_request)

assert len(job_request.additional_requests) == 1
assert job_request.additional_requests[0].additional_values["mask_file_link"] == get_specification_value(
"marimaskfile"
)
assert job_request.additional_requests[0].additional_values["wbvan"] == get_specification_value("mariwbvan")
assert job_request.additional_requests[0].additional_values["mask_file_link"] == "some link"
assert job_request.additional_requests[0].additional_values["wbvan"] == 1234567


def test_mari_mask_rule(job_request):
Expand Down

0 comments on commit 40baacc

Please sign in to comment.