Skip to content

Commit 3ec1d29

Browse files
author
Brian Curtin
committed
Database create changes for proxy
Change-Id: I02b3740e380ba3950db3375cb0f41567b96bc01c
1 parent 41a8a73 commit 3ec1d29

2 files changed

Lines changed: 54 additions & 15 deletions

File tree

openstack/database/v1/_proxy.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@
1919

2020
class Proxy(proxy.BaseProxy):
2121

22-
def create_database(self, **data):
23-
return database.Database(data).create(self.session)
22+
def create_database(self, **attrs):
23+
"""Create a new database from attributes
24+
25+
:param dict attrs: Keyword arguments which will be used to create
26+
a :class:`~openstack.compute.v2.database.Database`,
27+
comprised of the properties on the Database class.
28+
29+
:returns: The results of server creation
30+
:rtype: :class:`~openstack.compute.v2.database.Database`
31+
"""
32+
return self._create(database.Database, **attrs)
2433

2534
def delete_database(self, value, ignore_missing=True):
2635
"""Delete a database
@@ -52,8 +61,17 @@ def get_flavor(self, **data):
5261
def list_flavor(self):
5362
return flavor.Flavor.list(self.session)
5463

55-
def create_instance(self, **data):
56-
return instance.Instance(data).create(self.session)
64+
def create_instance(self, **attrs):
65+
"""Create a new instance from attributes
66+
67+
:param dict attrs: Keyword arguments which will be used to create
68+
a :class:`~openstack.compute.v2.instance.Instance`,
69+
comprised of the properties on the Instance class.
70+
71+
:returns: The results of server creation
72+
:rtype: :class:`~openstack.compute.v2.instance.Instance`
73+
"""
74+
return self._create(instance.Instance, **attrs)
5775

5876
def delete_instance(self, value, ignore_missing=True):
5977
"""Delete an instance
@@ -93,8 +111,17 @@ def update_instance(self, value, **attrs):
93111
"""
94112
return self._update(instance.Instance, value, **attrs)
95113

96-
def create_user(self, **data):
97-
return user.User(data).create(self.session)
114+
def create_user(self, **attrs):
115+
"""Create a new user from attributes
116+
117+
:param dict attrs: Keyword arguments which will be used to create
118+
a :class:`~openstack.compute.v2.user.User`,
119+
comprised of the properties on the User class.
120+
121+
:returns: The results of server creation
122+
:rtype: :class:`~openstack.compute.v2.user.User`
123+
"""
124+
return self._create(user.User, **attrs)
98125

99126
def delete_user(self, value, ignore_missing=True):
100127
"""Delete a user

openstack/tests/unit/database/v1/test_proxy.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ def setUp(self):
2222
super(TestDatabaseProxy, self).setUp()
2323
self.proxy = _proxy.Proxy(self.session)
2424

25-
def test_database_create(self):
26-
self.verify_create('openstack.database.v1.database.Database.create',
27-
self.proxy.create_database)
25+
def test_database_create_attrs(self):
26+
kwargs = {"x": 1, "y": 2, "z": 3}
27+
self.verify_create2('openstack.proxy.BaseProxy._create',
28+
self.proxy.create_database,
29+
method_kwargs=kwargs,
30+
expected_args=[database.Database],
31+
expected_kwargs=kwargs)
2832

2933
def test_database_delete(self):
3034
self.verify_delete2(database.Database, self.proxy.delete_database,
@@ -54,9 +58,13 @@ def test_flavor_list(self):
5458
self.verify_list('openstack.database.v1.flavor.Flavor.list',
5559
self.proxy.list_flavor)
5660

57-
def test_instance_create(self):
58-
self.verify_create('openstack.database.v1.instance.Instance.create',
59-
self.proxy.create_instance)
61+
def test_instance_create_attrs(self):
62+
kwargs = {"x": 1, "y": 2, "z": 3}
63+
self.verify_create2('openstack.proxy.BaseProxy._create',
64+
self.proxy.create_instance,
65+
method_kwargs=kwargs,
66+
expected_args=[instance.Instance],
67+
expected_kwargs=kwargs)
6068

6169
def test_instance_delete(self):
6270
self.verify_delete2(instance.Instance, self.proxy.delete_instance,
@@ -88,9 +96,13 @@ def test_instance_update(self):
8896
"resource_or_id"],
8997
expected_kwargs=kwargs)
9098

91-
def test_user_create(self):
92-
self.verify_create('openstack.database.v1.user.User.create',
93-
self.proxy.create_user)
99+
def test_user_create_attrs(self):
100+
kwargs = {"x": 1, "y": 2, "z": 3}
101+
self.verify_create2('openstack.proxy.BaseProxy._create',
102+
self.proxy.create_user,
103+
method_kwargs=kwargs,
104+
expected_args=[user.User],
105+
expected_kwargs=kwargs)
94106

95107
def test_user_delete(self):
96108
self.verify_delete2(user.User, self.proxy.delete_user, False)

0 commit comments

Comments
 (0)