Repository: canonical/operator

Issue:
Container.start() silently accepts no arguments and does nothing
`Container.start()` takes a variable number of strings as arguments, each specifying a service to be started. The issue is that it also accepts zero arguments without complain, even though it clearly indicates a mistake on the user.

I believe it should raise some sort of exception in the case of no arguments.

Applying this patch to current master (`18477647`) demonstrates the issue:

```diff
diff --git a/test/test_model.py b/test/test_model.py
index ed64add..564681a 100755
--- a/test/test_model.py
+++ b/test/test_model.py
@@ -824,6 +824,10 @@ containers:
             ('start', ('foo', 'bar')),
         ])
 
+    def test_start_no_argument(self):
+        with self.assertRaises(Exception):
+            self.container.start()
+
     def test_stop(self):
         self.container.stop('foo')
         self.container.stop('foo', 'bar')
```

Discussion:

Patch:
diff --git a/ops/model.py b/ops/model.py
index b58d729..d10c3f0 100644
--- a/ops/model.py
+++ b/ops/model.py
@@ -1043,10 +1043,14 @@ class Container:
 
     def start(self, *service_names: str):
         """Start given service(s) by name."""
+        if not service_names:
+            raise TypeError('start expected at least 1 argument, got 0')
         self._pebble.start_services(service_names)
 
     def stop(self, *service_names: str):
         """Stop given service(s) by name."""
+        if not service_names:
+            raise TypeError('stop expected at least 1 argument, got 0')
         self._pebble.stop_services(service_names)
 
     # TODO(benhoyt) - should be: layer: typing.Union[str, typing.Dict, 'pebble.Layer'],


Test patch:
diff --git a/test/test_model.py b/test/test_model.py
index ed64add..030393a 100755
--- a/test/test_model.py
+++ b/test/test_model.py
@@ -824,6 +824,10 @@ containers:
             ('start', ('foo', 'bar')),
         ])
 
+    def test_start_no_arguments(self):
+        with self.assertRaises(TypeError):
+            self.container.start()
+
     def test_stop(self):
         self.container.stop('foo')
         self.container.stop('foo', 'bar')
@@ -832,6 +836,10 @@ containers:
             ('stop', ('foo', 'bar')),
         ])
 
+    def test_stop_no_arguments(self):
+        with self.assertRaises(TypeError):
+            self.container.stop()
+
     def test_type_errors(self):
         meta = ops.charm.CharmMeta.from_yaml("""
 name: k8s-charm