import json,pathlib,unittest
from review import review
class ReviewTests(unittest.TestCase):
    def test_filled_decisions(self):
        for x in json.loads(pathlib.Path(__file__).with_name('filled-review.json').read_text())['cases']:
            with self.subTest(case=x['case']):self.assertEqual(review(x['packet'])['status'],x['expected'])
    def test_unbound_input(self):
        for p in [None,{},[],True]:self.assertEqual(review(p)['status'],'POLICY_UNVERIFIED')
    def test_wrong_base_is_not_same_fragment(self):
        from review import absolute
        self.assertNotEqual(absolute('https://shop.example.invalid/policy','#gold'),absolute('https://shop.example.invalid/product','#gold'))
    def test_flags_never_claim_live_result(self):
        for x in json.loads(pathlib.Path(__file__).with_name('filled-review.json').read_text())['cases']:
            y=review(x['packet']);self.assertFalse(y['liveChecked']);self.assertFalse(y['fullSchemaValidated']);self.assertFalse(y['searchDisplayVerified'])

if __name__=='__main__':unittest.main()
