def test_wrong_type(self): """Test a wrongly-typed filter""" if sys.hexversion >= 0x2070000: with self.assertRaises(ValueError): f = JQFilter(1234)
def test_bad_syntax(self): """Test a filter with the wrong syntax""" if sys.hexversion >= 0x2070000: with self.assertRaises(ValueError): f = JQFilter("this is bad")
def test_hash(self): """Test a hash filter""" f = JQFilter({"script": "."}) self.assertEqual(f({"abc": 123})[0], {"abc": 123})
def test_hash_array(self): """Test a hash filter with an array script""" f = JQFilter({"script": ["", ".", "", ""]}) self.assertEqual(f({"abc": 123})[0], {"abc": 123})
def test_array(self): """Test an array filter""" f = JQFilter(["", ".", "", ""]) self.assertEqual(f({"abc": 123})[0], {"abc": 123})
def test_array_empty(self): """Test an empty array filter""" f = JQFilter([]) self.assertEqual(f({"abc": 123})[0], {"abc": 123})
def test_string(self): """Test a string filter""" f = JQFilter(".") self.assertEqual(f({"abc": 123})[0], {"abc": 123})
def test_bad_syntax(self): """Test a filter with the wrong syntax""" with self.assertRaises(ValueError): f = JQFilter("this is bad")
def test_wrong_type(self): """Test a wrongly-typed filter""" with self.assertRaises(ValueError): f = JQFilter(1234)
def test_args(self): f = JQFilter({"script": "$value"}, args={"value": 123}) self.assertEqual(f(None)[0], 123)
def test_args_empty(self): f = JQFilter({"script": "."}, args={}) self.assertEqual(f(123)[0], 123)