Updated stack tests to only use an admin user when necessary.
[snaps.git] / snaps / domain / test / stack_tests.py
index e0e1ae7..2ad690a 100644 (file)
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 import unittest
-from snaps.domain.stack import Stack, Resource
+from snaps.domain.stack import Stack, Resource, Output
 
 
 class StackDomainObjectTests(unittest.TestCase):
@@ -23,14 +23,23 @@ class StackDomainObjectTests(unittest.TestCase):
     """
 
     def test_construction_positional(self):
-        stack = Stack('name', 'id')
+        stack = Stack(
+            'name', 'id', 'stack_proj_id', 'fine', 'good')
         self.assertEqual('name', stack.name)
         self.assertEqual('id', stack.id)
+        self.assertEqual('stack_proj_id', stack.stack_project_id)
+        self.assertEqual('fine', stack.status)
+        self.assertEqual('good', stack.status_reason)
 
     def test_construction_named(self):
-        stack = Stack(stack_id='id', name='name')
+        stack = Stack(
+            stack_id='id', name='name', stack_project_id='stack_proj_id',
+            status='fine', status_reason='good')
         self.assertEqual('name', stack.name)
         self.assertEqual('id', stack.id)
+        self.assertEqual('stack_proj_id', stack.stack_project_id)
+        self.assertEqual('fine', stack.status)
+        self.assertEqual('good', stack.status_reason)
 
 
 class ResourceDomainObjectTests(unittest.TestCase):
@@ -39,11 +48,40 @@ class ResourceDomainObjectTests(unittest.TestCase):
     """
 
     def test_construction_positional(self):
-        resource = Resource('foo', 'bar')
+        resource = Resource('res_name', 'foo', 'bar', 'status', 'reason')
+        self.assertEqual('res_name', resource.name)
         self.assertEqual('foo', resource.type)
         self.assertEqual('bar', resource.id)
+        self.assertEqual('status', resource.status)
+        self.assertEqual('reason', resource.status_reason)
 
     def test_construction_named(self):
-        resource = Resource(resource_id='bar', resource_type='foo')
+        resource = Resource(
+            status_reason=None, status=None, resource_id='bar',
+            resource_type='foo', name='res_name')
+        self.assertEqual('res_name', resource.name)
         self.assertEqual('foo', resource.type)
         self.assertEqual('bar', resource.id)
+        self.assertIsNone(resource.status)
+        self.assertIsNone(resource.status_reason)
+
+
+class OutputDomainObjectTests(unittest.TestCase):
+    """
+    Tests the construction of the snaps.domain.Resource class
+    """
+
+    def test_construction_kwargs(self):
+        kwargs = {'description': 'foo', 'output_key': 'test_key',
+                  'output_value': 'bar'}
+        resource = Output(**kwargs)
+        self.assertEqual('foo', resource.description)
+        self.assertEqual('test_key', resource.key)
+        self.assertEqual('bar', resource.value)
+
+    def test_construction_named(self):
+        resource = Output(description='foo', output_key='test_key',
+                          output_value='bar')
+        self.assertEqual('foo', resource.description)
+        self.assertEqual('test_key', resource.key)
+        self.assertEqual('bar', resource.value)