Example #1
0
 def test_invalid_jq_expression(self):
     with self.assertRaisesRegexp(ValueError, "jq: 1 compile error"):
         JQTransform({'options': {'jq_filter': 'blah'}})
Example #2
0
 def test_transform_with_filter(self):
     for country in ['es', 'uk']:
         jq_filter = 'select(.country_code == "%s") | {country_code}' % country
         transform = JQTransform({'options': {'jq_filter': jq_filter}})
         expected = [{'country_code': country}]
         self.assertEqual(expected, list(transform.transform_batch(self.batch)))
Example #3
0
 def test_no_transform_batch(self):
     transform = JQTransform({'options': {'jq_filter': '.'}})
     self.assertEqual(self.batch, list(transform.transform_batch(self.batch)))
Example #4
0
 def test_transform_batch(self):
     transform = JQTransform({'options': {'jq_filter': '{country: .country_code}'}})
     expected = [{'country': 'es'}, {'country': 'uk'}]
     self.assertEqual(expected, list(transform.transform_batch(self.batch)))
Example #5
0
 def test_transform_empty_batch(self):
     transform = JQTransform({'options': {'jq_filter': '.'}})
     self.assertEquals([], list(transform.transform_batch([])))