Feature-9904: Enhancing NG-UI to enable Juju operational view dashboard
[osm/N2VC.git] / n2vc / tests / unit / utils.py
index fe7362e..92ab7a8 100644 (file)
@@ -14,7 +14,7 @@
 
 import asyncio
 
-from n2vc.utils import Dict, EntityType, N2VCDeploymentStatus
+from n2vc.utils import Dict, N2VCDeploymentStatus
 from n2vc.n2vc_conn import N2VCConnector
 from unittest.mock import MagicMock
 
@@ -55,7 +55,19 @@ class FakeMachine(MagicMock):
     entity_id = "2"
     dns_name = "FAKE ENDPOINT"
     model_name = "FAKE MODEL"
-    entity_type = EntityType.MACHINE
+    entity_type = "machine"
+    safe_data = {"instance-id": "myid"}
+
+    async def destroy(self, force):
+        pass
+
+
+class FakeManualMachine(MagicMock):
+    entity_id = "2"
+    dns_name = "FAKE ENDPOINT"
+    model_name = "FAKE MODEL"
+    entity_type = "machine"
+    safe_data = {"instance-id": "manual:myid"}
 
     async def destroy(self, force):
         pass
@@ -98,6 +110,9 @@ class FakeApplication(AsyncMock):
     async def get_actions(self):
         return ["existing_action"]
 
+    async def get_config(self):
+        return ["app_config"]
+
     units = [FakeUnit(), FakeUnit()]
 
 
@@ -201,8 +216,8 @@ FAKE_DELTA_ACTION_COMPLETED = Dict(
 Deltas = [
     Dict(
         {
-            "entity": Dict({"id": "2", "type": EntityType.MACHINE}),
-            "filter": Dict({"entity_id": "2", "entity_type": EntityType.MACHINE}),
+            "entity": Dict({"id": "2", "type": "machine"}),
+            "filter": Dict({"entity_id": "2", "entity_type": "machine"}),
             "delta": FAKE_DELTA_MACHINE_PENDING,
             "entity_status": Dict(
                 {"status": "pending", "message": "Running", "vca_status": "running"}
@@ -224,8 +239,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "2", "type": EntityType.MACHINE}),
-            "filter": Dict({"entity_id": "1", "entity_type": EntityType.MACHINE}),
+            "entity": Dict({"id": "2", "type": "machine"}),
+            "filter": Dict({"entity_id": "1", "entity_type": "machine"}),
             "delta": FAKE_DELTA_MACHINE_PENDING,
             "entity_status": Dict(
                 {"status": "pending", "message": "Running", "vca_status": "running"}
@@ -235,8 +250,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "2", "type": EntityType.MACHINE}),
-            "filter": Dict({"entity_id": "2", "entity_type": EntityType.MACHINE}),
+            "entity": Dict({"id": "2", "type": "machine"}),
+            "filter": Dict({"entity_id": "2", "entity_type": "machine"}),
             "delta": FAKE_DELTA_MACHINE_STARTED,
             "entity_status": Dict(
                 {"status": "started", "message": "Running", "vca_status": "running"}
@@ -258,8 +273,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "2", "type": EntityType.MACHINE}),
-            "filter": Dict({"entity_id": "1", "entity_type": EntityType.MACHINE}),
+            "entity": Dict({"id": "2", "type": "machine"}),
+            "filter": Dict({"entity_id": "1", "entity_type": "machine"}),
             "delta": FAKE_DELTA_MACHINE_STARTED,
             "entity_status": Dict(
                 {"status": "started", "message": "Running", "vca_status": "running"}
@@ -269,8 +284,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "git/0", "type": EntityType.UNIT}),
-            "filter": Dict({"entity_id": "git", "entity_type": EntityType.APPLICATION}),
+            "entity": Dict({"id": "git/0", "type": "unit"}),
+            "filter": Dict({"entity_id": "git", "entity_type": "application"}),
             "delta": FAKE_DELTA_UNIT_PENDING,
             "entity_status": Dict(
                 {"status": "waiting", "message": "", "vca_status": "waiting"}
@@ -292,8 +307,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "git/0", "type": EntityType.UNIT}),
-            "filter": Dict({"entity_id": "2", "entity_type": EntityType.MACHINE}),
+            "entity": Dict({"id": "git/0", "type": "unit"}),
+            "filter": Dict({"entity_id": "2", "entity_type": "machine"}),
             "delta": FAKE_DELTA_UNIT_PENDING,
             "entity_status": Dict(
                 {"status": "waiting", "message": "", "vca_status": "waiting"}
@@ -303,8 +318,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "git/0", "type": EntityType.UNIT}),
-            "filter": Dict({"entity_id": "git", "entity_type": EntityType.APPLICATION}),
+            "entity": Dict({"id": "git/0", "type": "unit"}),
+            "filter": Dict({"entity_id": "git", "entity_type": "application"}),
             "delta": FAKE_DELTA_UNIT_STARTED,
             "entity_status": Dict(
                 {"status": "active", "message": "", "vca_status": "active"}
@@ -326,8 +341,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "git/0", "type": EntityType.UNIT}),
-            "filter": Dict({"entity_id": "1", "entity_type": EntityType.ACTION}),
+            "entity": Dict({"id": "git/0", "type": "unit"}),
+            "filter": Dict({"entity_id": "1", "entity_type": "action"}),
             "delta": FAKE_DELTA_UNIT_STARTED,
             "entity_status": Dict(
                 {"status": "active", "message": "", "vca_status": "active"}
@@ -337,8 +352,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "git", "type": EntityType.APPLICATION}),
-            "filter": Dict({"entity_id": "git", "entity_type": EntityType.APPLICATION}),
+            "entity": Dict({"id": "git", "type": "application"}),
+            "filter": Dict({"entity_id": "git", "entity_type": "application"}),
             "delta": FAKE_DELTA_APPLICATION_MAINTENANCE,
             "entity_status": Dict(
                 {
@@ -364,8 +379,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "git", "type": EntityType.APPLICATION}),
-            "filter": Dict({"entity_id": "2", "entity_type": EntityType.MACHINE}),
+            "entity": Dict({"id": "git", "type": "application"}),
+            "filter": Dict({"entity_id": "2", "entity_type": "machine"}),
             "delta": FAKE_DELTA_APPLICATION_MAINTENANCE,
             "entity_status": Dict(
                 {
@@ -379,8 +394,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "git", "type": EntityType.APPLICATION}),
-            "filter": Dict({"entity_id": "git", "entity_type": EntityType.APPLICATION}),
+            "entity": Dict({"id": "git", "type": "application"}),
+            "filter": Dict({"entity_id": "git", "entity_type": "application"}),
             "delta": FAKE_DELTA_APPLICATION_ACTIVE,
             "entity_status": Dict(
                 {"status": "active", "message": "Ready!", "vca_status": "active"}
@@ -402,8 +417,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "git", "type": EntityType.APPLICATION}),
-            "filter": Dict({"entity_id": "1", "entity_type": EntityType.ACTION}),
+            "entity": Dict({"id": "git", "type": "application"}),
+            "filter": Dict({"entity_id": "1", "entity_type": "action"}),
             "delta": FAKE_DELTA_APPLICATION_ACTIVE,
             "entity_status": Dict(
                 {"status": "active", "message": "Ready!", "vca_status": "active"}
@@ -413,8 +428,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "1", "type": EntityType.ACTION}),
-            "filter": Dict({"entity_id": "1", "entity_type": EntityType.ACTION}),
+            "entity": Dict({"id": "1", "type": "action"}),
+            "filter": Dict({"entity_id": "1", "entity_type": "action"}),
             "delta": FAKE_DELTA_ACTION_COMPLETED,
             "entity_status": Dict(
                 {
@@ -440,8 +455,8 @@ Deltas = [
     ),
     Dict(
         {
-            "entity": Dict({"id": "git", "type": EntityType.ACTION}),
-            "filter": Dict({"entity_id": "1", "entity_type": EntityType.MACHINE}),
+            "entity": Dict({"id": "git", "type": "action"}),
+            "filter": Dict({"entity_id": "1", "entity_type": "machine"}),
             "delta": FAKE_DELTA_ACTION_COMPLETED,
             "entity_status": Dict(
                 {