Jaseci-Labs / jaseci

The Official Jaseci Code Repository
https://jaseci.org
155 stars 210 forks source link

Jac Test Case Parameter Passisng #1121

Closed ChrisIsKing closed 1 month ago

ChrisIsKing commented 1 year ago

Is your feature request related to a problem? Please describe. When writing core test cases for jaseci actions convention assumes that walkers test static input cases. e.g

@pytest.mark.order(2)
    @jac_testcase("bi_enc.jac", "test_bi_enc_infer")
    def test_biencoder_infer(self, ret):
        self.assertEqual(ret["success"], True)
walker test_bi_enc_infer{
    can bi_enc.infer;
    report bi_enc.infer(["Share my location with Hillary's sister"],["searchplace","getplacedetails","bookrestaurant","gettrafficinformation","compareplaces","sharecurrentlocation","requestride","getdirections","shareeta","getweather"],"text","text");
}

However, test cases can run on dynamic input sources that need to be managed within Python and need a seamless way of passing this in the @jac_testcase decorator

Describe the solution you'd like

data = ["text"]

@pytest.mark.order(2)
    @jac_testcase("bi_enc.jac", "test_bi_enc_infer", ctx=data)
    def test_biencoder_infer(self, ret):
        self.assertEqual(ret["success"], True)
walker test_bi_enc_infer{
    has data;
    can bi_enc.infer;
    report bi_enc.infer(data);
}

Describe alternatives you've considered An alternative is loading & handling the data in JAC or writing several test walkers.

If this feature request is accepted, would you be willing to work on a PR? Yes. I suspect a simple mod to test_core.py would solve this but its unclear how parameters are passed to JsOrc.master()

Additional context Add any other context or screenshots about the feature request here.

ChrisIsKing commented 1 year ago

Seems like this is catered for in part by self.call but I don't think the parameters end anywhere. See here