summaryrefslogtreecommitdiff
path: root/saharaclient/tests/unit/test_resource.py
diff options
context:
space:
mode:
authorTrevor McKay <tmckay@redhat.com>2014-04-21 10:16:26 -0400
committerTrevor McKay <tmckay@redhat.com>2014-04-22 10:24:17 -0400
commitb9a6e8b27d5960e8b68f9440983928dae7b0d109 (patch)
treef834406bbc87b555dbcf6f5273129a0977311781 /saharaclient/tests/unit/test_resource.py
parenta9dd45c7c16c31bae48992cb967d14942a04132b (diff)
downloadpython-saharaclient-b9a6e8b27d5960e8b68f9440983928dae7b0d109.tar.gz
Restructure tests directory in preparation for cli integration tests
Partial-implements: blueprint cli-integration-tests Change-Id: I927c250d787414fb855df3c9952dff743ba11e24
Diffstat (limited to 'saharaclient/tests/unit/test_resource.py')
-rw-r--r--saharaclient/tests/unit/test_resource.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/saharaclient/tests/unit/test_resource.py b/saharaclient/tests/unit/test_resource.py
new file mode 100644
index 0000000..e0526d8
--- /dev/null
+++ b/saharaclient/tests/unit/test_resource.py
@@ -0,0 +1,61 @@
+# Copyright (c) 2013 Mirantis Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import testtools
+
+from saharaclient.api import base
+
+
+class ResourceTest(testtools.TestCase):
+ def test_create_resource(self):
+ dict = {"name": "test"}
+ resource = TestResource(None, dict)
+ self.assertEqual("test", resource.name)
+ self.assertEqual("Test Description", resource.description)
+
+ def test_overwrite_default(self):
+ dict = {"name": "test",
+ "description": "Changed Description"}
+ resource = TestResource(None, dict)
+ self.assertEqual("test", resource.name)
+ self.assertEqual("Changed Description", resource.description)
+ self.assertEqual("extra", resource.extra)
+
+ def test_create_dont_modify_info_dict(self):
+ dict = {"name": "test",
+ "description": "Changed Description"}
+ dict_copy = dict.copy()
+ resource = TestResource(None, dict)
+ self.assertIsNotNone(resource)
+ self.assertEqual(dict_copy, dict)
+
+ def test_resource_str(self):
+ dict = {"name": "test",
+ "description": "Changed Description"}
+ resource = TestResource(None, dict)
+ rstr = str(resource)
+ self.assertIn(resource.resource_name, rstr)
+ self.assertIn("name", rstr)
+ self.assertIn("description", rstr)
+ self.assertIn("Changed Description", rstr)
+ self.assertNotIn("Test Description", rstr)
+ self.assertIn("extra", rstr)
+ self.assertNotIn("manager", rstr)
+
+
+class TestResource(base.Resource):
+ resource_name = 'Test Resource'
+ defaults = {'description': 'Test Description',
+ 'extra': "extra"}