Manual update of pip requirements
[osm/N2VC.git] / n2vc / tests / unit / test_utils.py
index bffbc29..3896b2f 100644 (file)
 
 from unittest import TestCase
 
 
 from unittest import TestCase
 
-from n2vc.utils import Dict, EntityType, JujuStatusToOSM, N2VCDeploymentStatus
+from n2vc.utils import (
+    Dict,
+    EntityType,
+    JujuStatusToOSM,
+    N2VCDeploymentStatus,
+    get_ee_id_components,
+)
 from juju.machine import Machine
 from juju.application import Application
 from juju.action import Action
 from juju.machine import Machine
 from juju.application import Application
 from juju.action import Action
@@ -84,3 +90,17 @@ class UtilsTest(TestCase):
                 osm_status = status["osm"]
                 self.assertTrue(juju_status in JujuStatusToOSM[entity_type])
                 self.assertEqual(osm_status, JujuStatusToOSM[entity_type][juju_status])
                 osm_status = status["osm"]
                 self.assertTrue(juju_status in JujuStatusToOSM[entity_type])
                 self.assertEqual(osm_status, JujuStatusToOSM[entity_type][juju_status])
+
+
+class GetEEComponentTest(TestCase):
+    def test_valid(self):
+        model, application, machine = get_ee_id_components("model.application.machine")
+        self.assertEqual(model, "model")
+        self.assertEqual(application, "application")
+        self.assertEqual(machine, "machine")
+
+    def test_invalid(self):
+        with self.assertRaises(Exception):
+            get_ee_id_components("model.application.machine.1")
+        with self.assertRaises(Exception):
+            get_ee_id_components("model.application")