def test_multipleActions(self): """ Multiple actions can be specified for each rule. Each action should happen. """ tmpdir = FilePath(self.mktemp()) rules = [ { 'pattern': { 'foo': '*', }, 'actions': [ {'merge_yaml': '{foo}.yml'}, {'merge_yaml': '{foo}2.yml'}, ] }, ] dumper = RuleBasedFileDumper(tmpdir.path, rules) dumper.dumpObject({ 'foo': 'thefoo', }) self.assertTrue(tmpdir.child('thefoo.yml').exists(), "Should have matched and acted on the first rule first action") self.assertTrue(tmpdir.child('thefoo2.yml').exists(), "Should have matched and acted on the first rule second action")
def test_catchAll(self): """ Everything should match a catchall rule. """ tmpdir = FilePath(self.mktemp()) rules = [ { 'pattern': { 'foo': '*', }, 'actions': [ {'merge_yaml': '{foo}.yml'}, ] }, { 'pattern': 'all', 'actions': [ {'merge_yaml': 'extra.yml'}, ] } ] dumper = RuleBasedFileDumper(tmpdir.path, rules) dumper.dumpObject({ 'foo': 'thefoo', }) self.assertTrue(tmpdir.child('thefoo.yml').exists(), "Should have matched and acted on the first rule") dumper.dumpObject({ 'bar': 'hey', }) self.assertTrue(tmpdir.child('extra.yml').exists(), "Should have matched and acted on the second rule") self.assertEqual(len(tmpdir.children()), 2, "Should only have made " "the 2 expected files")