コード例 #1
0
 def test_type_change(self):
     """Exception is raised if replacement type differs."""
     with self.assertRaises(TypeError):
         update = jmes.Update("metadata", "root().TM")
         update.run(deepcopy(SAMPLE_STATE))
     with self.assertRaises(TypeError):
         update = jmes.Update("templates", "root().TM")
         update.run(deepcopy(SAMPLE_STATE))
コード例 #2
0
 def test_update_dict(self):
     """When value_expr gives a dict, it is updated."""
     update = jmes.Update("metadata", "{qux: `123`}")
     results = update.run(deepcopy(SAMPLE_STATE))
     self.assertEqual(results, {
         "TM": 0.5,
         "templates": [
             {"TM": 0.3, "name": "foo"},
             {"TM": 0.6, "name": "bar"},
         ],
         "metadata": {"date": "1970-01-01", "qux": 123}
     })
コード例 #3
0
 def test_invalid_selection(self):
     """Can only update dicts and lists."""
     with self.assertRaises(TypeError):
         update = jmes.Update("TM", "`[1,2,3]`")
         update.run(deepcopy(SAMPLE_STATE))
コード例 #4
0
 def test_update_identity(self):
     """Updating identical elements does nothing."""
     update = jmes.Update("@", "@")
     results = update.run(deepcopy(SAMPLE_STATE))
     self.assertEqual(results, SAMPLE_STATE)