What's the best way to mock digests for unit testi...
# plugins
r
What's the best way to mock digests for unit testing?
Alternatively, is there a way I can mock just one rule and use the real thing for the others?
h
You can create digests in tests with
Copy code
digest = rule_runner.request(
        Digest, [CreateDigest([ FileContent("a/foo.txt", b"foo\n")])]
    )
or similar
r
Is it possible to use
run_rule_with_mocks
and run an actual rule or do all rules need to be mocked? Or to mock a rule with rule runner?
I'm trying to mock a rule that reaches out to the internet and downloads stuff but test the actual logic otherwise.
Copy code
class MyRuleRunner(RuleRunner):
    def call_actual_rule(self, output_type, input_types: tuple) -> MockGet:
        return MockGet(output_type=output_type, input_types=input_types, mock=lambda *args: self.request(output_type, args))
This works 👀