def test_yaml(self): plan = pebble.Plan('') self.assertEqual(plan.to_yaml(), '') self.assertEqual(str(plan), '') yaml = 'services:\n foo:\n override: replace\n command: echo foo' plan = pebble.Plan(yaml) self.assertEqual(plan.to_yaml(), yaml) self.assertEqual(str(plan), yaml)
def test_services(self): plan = pebble.Plan('') self.assertEqual(plan.services, {}) plan = pebble.Plan('services:\n foo:\n override: replace\n command: echo foo') self.assertEqual(len(plan.services), 1) self.assertEqual(plan.services['foo'].name, 'foo') self.assertEqual(plan.services['foo'].override, 'replace') self.assertEqual(plan.services['foo'].command, 'echo foo') # Should be read-only ("can't set attribute") with self.assertRaises(AttributeError): plan.services = {}
def get_plan(self) -> pebble.Plan: plan = pebble.Plan('{}') services = self._render_services() if not services: return plan for name in sorted(services.keys()): plan.services[name] = services[name] return plan
def test_no_args(self): with self.assertRaises(TypeError): pebble.Plan()