Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## v1.3.5

Updates:
* Updated test files to work with latest CI updates (@jschoewe)

## v1.3.4

Updates:
Expand Down
2 changes: 1 addition & 1 deletion pack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ref: vsphere
name: vsphere
description: VMware vSphere
stackstorm_version: ">=2.9.0"
version: 1.3.4
version: 1.3.5
author: Paul Mulvihill
email: [email protected]
contributors:
Expand Down
10 changes: 1 addition & 9 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
# these old pins conflict with those in st2 causing CI to fail
# feel free to update if you still want a pack-local cache of the deps
#mock>=1.3.0,<2.0
#unittest2>=1.1.0,<2.0
#nose>=1.3.7
#eventlet==0.25.1
#requests[security]==2.23.0
#pytz==2019.1
pyvmomi==7.0.2
pyvmomi==8.0.3.0.1
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyvmomi==7.0.2
pyvmomi==8.0.3.0.1
24 changes: 16 additions & 8 deletions tests/test_action_vmwarelib_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and

import mock

from vmwarelib.actions import BaseAction
from vsphere_base_action_test_case import VsphereBaseActionTestCase
from get_objects_with_tag import GetObjectsWithTag

Expand All @@ -28,13 +26,23 @@ class BaseActionTestCase(VsphereBaseActionTestCase):
# action_cls = BaseAction
action_cls = GetObjectsWithTag

def test_init(self):
action = self.get_action_instance(self._new_config)
self.assertIsInstance(action, BaseAction)
def test_init_config_new(self):
action = self.get_action_instance(self.new_config)
self.assertIsInstance(action, self.action_cls)

def test_init_config_blank(self):
self.assertRaises(ValueError, self.action_cls, self.blank_config)

def test_init_config_old(self):
self.assertRaises(ValueError, self.action_cls, self.old_config)

def test_init_config_old_partial(self):
self.assertRaises(ValueError, self.action_cls, self.old_config_partial)

def test_init_blank_config(self):
with self.assertRaises(ValueError):
self.get_action_instance(self._blank_config)
def test_init_config_new_partial(self):
action = self.get_action_instance(self.new_config_partial)
self.assertRaises(KeyError, action.establish_connection,
vsphere="default")

def test_get_connection_info(self):
action = self.get_action_instance(self._new_config)
Expand Down
76 changes: 38 additions & 38 deletions tests/test_action_vmwarelib_tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def test_category_list(self, mock_get):

# assert
mock_get.assert_called_with("/rest/com/vmware/cis/tagging/category")
self.assertEquals(result, expected)
self.assertEqual(result, expected)

@mock.patch("vmwarelib.tagging.VmwareTagging.get")
def test_category_get(self, mock_get):
Expand All @@ -274,7 +274,7 @@ def test_category_get(self, mock_get):

# assert
mock_get.assert_called_with("/rest/com/vmware/cis/tagging/category/id:1234")
self.assertEquals(result, expected)
self.assertEqual(result, expected)

@mock.patch("vmwarelib.tagging.VmwareTagging.delete")
def test_category_delete(self, mock_delete):
Expand All @@ -289,7 +289,7 @@ def test_category_delete(self, mock_delete):

# assert
mock_delete.assert_called_with("/rest/com/vmware/cis/tagging/category/id:1234")
self.assertEquals(result, expected)
self.assertEqual(result, expected)

@mock.patch("vmwarelib.tagging.VmwareTagging.category_get")
@mock.patch("vmwarelib.tagging.VmwareTagging.category_list")
Expand All @@ -307,7 +307,7 @@ def test_category_find_by_name(self, mock_category_list, mock_category_get):
result = action.category_find_by_name("b")

# assert
self.assertEquals(result, {"name": "b", "value": "xx"})
self.assertEqual(result, {"name": "b", "value": "xx"})

@mock.patch("vmwarelib.tagging.VmwareTagging.category_get")
@mock.patch("vmwarelib.tagging.VmwareTagging.category_list")
Expand All @@ -325,15 +325,15 @@ def test_category_find_by_name_not_found(self, mock_category_list, mock_category
result = action.category_find_by_name("abc123")

# assert
self.assertEquals(result, None)
self.assertEqual(result, None)

def test_category_create_spec(self):
action = self.create_class_object()
create_spec = action.category_create_spec()
self.assertEquals(create_spec, {"name": "",
"description": "",
"cardinality": "SINGLE",
"associable_types": []})
self.assertEqual(create_spec, {"name": "",
"description": "",
"cardinality": "SINGLE",
"associable_types": []})

@mock.patch("vmwarelib.tagging.VmwareTagging.post")
def test_category_create_all_params(self, mock_post):
Expand All @@ -360,7 +360,7 @@ def test_category_create_all_params(self, mock_post):
# assert
mock_post.assert_called_with("/rest/com/vmware/cis/tagging/category",
payload={"create_spec": expected_create_spec})
self.assertEquals(result, "expected result")
self.assertEqual(result, "expected result")

@mock.patch("vmwarelib.tagging.VmwareTagging.post")
def test_category_create_no_params(self, mock_post):
Expand All @@ -382,7 +382,7 @@ def test_category_create_no_params(self, mock_post):
# assert
mock_post.assert_called_with("/rest/com/vmware/cis/tagging/category",
payload={"create_spec": expected_create_spec})
self.assertEquals(result, "expected result")
self.assertEqual(result, "expected result")

@mock.patch("vmwarelib.tagging.VmwareTagging.category_find_by_name")
def test_category_get_or_create_get(self, mock_category_find_by_name):
Expand All @@ -397,7 +397,7 @@ def test_category_get_or_create_get(self, mock_category_find_by_name):

# assert
mock_category_find_by_name.assert_called_with("name")
self.assertEquals(result, "fake category")
self.assertEqual(result, "fake category")

@mock.patch("vmwarelib.tagging.VmwareTagging.category_get")
@mock.patch("vmwarelib.tagging.VmwareTagging.category_create")
Expand Down Expand Up @@ -426,7 +426,7 @@ def test_category_get_or_create_create_all_params(self, mock_category_find_by_na
mock_category_create.assert_called_with(test_name, test_description, test_cardinality,
test_associable_types)
mock_category_get.assert_called_with("123")
self.assertEquals(result, "fake category")
self.assertEqual(result, "fake category")

@mock.patch("vmwarelib.tagging.VmwareTagging.category_get")
@mock.patch("vmwarelib.tagging.VmwareTagging.category_create")
Expand All @@ -450,7 +450,7 @@ def test_category_get_or_create_create_no_params(self, mock_category_find_by_nam
mock_category_find_by_name.assert_called_with(test_name)
mock_category_create.assert_called_with(test_name, None, None, None)
mock_category_get.assert_called_with("123")
self.assertEquals(result, "fake category")
self.assertEqual(result, "fake category")

############################################################################

Expand All @@ -470,7 +470,7 @@ def test_tag_list_category(self, mock_post):
# assert
mock_post.assert_called_with("/rest/com/vmware/cis/tagging/tag/id:1234",
params={"~action": "list-tags-for-category"})
self.assertEquals(result, expected)
self.assertEqual(result, expected)

@mock.patch("vmwarelib.tagging.VmwareTagging.get")
def test_tag_list_no_category(self, mock_get):
Expand All @@ -484,7 +484,7 @@ def test_tag_list_no_category(self, mock_get):

# assert
mock_get.assert_called_with("/rest/com/vmware/cis/tagging/tag")
self.assertEquals(result, expected)
self.assertEqual(result, expected)

@mock.patch("vmwarelib.tagging.VmwareTagging.get")
def test_tag_get(self, mock_get):
Expand All @@ -499,7 +499,7 @@ def test_tag_get(self, mock_get):

# assert
mock_get.assert_called_with("/rest/com/vmware/cis/tagging/tag/id:1234")
self.assertEquals(result, expected)
self.assertEqual(result, expected)

@mock.patch("vmwarelib.tagging.VmwareTagging.delete")
def test_tag_delete(self, mock_delete):
Expand All @@ -514,7 +514,7 @@ def test_tag_delete(self, mock_delete):

# assert
mock_delete.assert_called_with("/rest/com/vmware/cis/tagging/tag/id:1234")
self.assertEquals(result, expected)
self.assertEqual(result, expected)

@mock.patch("vmwarelib.tagging.VmwareTagging.tag_get")
@mock.patch("vmwarelib.tagging.VmwareTagging.tag_list")
Expand All @@ -535,7 +535,7 @@ def test_tag_find_by_name(self, mock_tag_list, mock_tag_get):

# assert
mock_tag_list.assert_called_with(test_category_id)
self.assertEquals(result, {"name": "b", "value": "xx"})
self.assertEqual(result, {"name": "b", "value": "xx"})

@mock.patch("vmwarelib.tagging.VmwareTagging.tag_get")
@mock.patch("vmwarelib.tagging.VmwareTagging.tag_list")
Expand All @@ -557,14 +557,14 @@ def test_tag_find_not_found(self, mock_tag_list, mock_tag_get):
mock_tag_list.assert_called_with(None)
mock_tag_get.assert_has_calls([mock.call("1"), mock.call("2"), mock.call("3")],
any_order=True)
self.assertEquals(result, None)
self.assertEqual(result, None)

def test_tag_create_spec(self):
action = self.create_class_object()
create_spec = action.tag_create_spec()
self.assertEquals(create_spec, {"name": "",
"description": "",
"category_id": ""})
self.assertEqual(create_spec, {"name": "",
"description": "",
"category_id": ""})

@mock.patch("vmwarelib.tagging.VmwareTagging.post")
def test_tag_create(self, mock_post):
Expand All @@ -585,7 +585,7 @@ def test_tag_create(self, mock_post):
# assert
mock_post.assert_called_with("/rest/com/vmware/cis/tagging/tag",
payload={"create_spec": expected_create_spec})
self.assertEquals(result, "expected result")
self.assertEqual(result, "expected result")

@mock.patch("vmwarelib.tagging.VmwareTagging.tag_find_by_name")
def test_tag_get_or_create_get(self, mock_tag_find_by_name):
Expand All @@ -602,7 +602,7 @@ def test_tag_get_or_create_get(self, mock_tag_find_by_name):

# assert
mock_tag_find_by_name.assert_called_with(test_tag_name, test_category_id)
self.assertEquals(result, "fake tag")
self.assertEqual(result, "fake tag")

@mock.patch("vmwarelib.tagging.VmwareTagging.tag_get")
@mock.patch("vmwarelib.tagging.VmwareTagging.tag_create")
Expand All @@ -623,7 +623,7 @@ def test_tag_get_or_create_create(self, mock_tag_find_by_name,
mock_tag_find_by_name.assert_called_with(test_tag_name, test_category_id)
mock_tag_create.assert_called_with(test_tag_name, test_category_id, None)
mock_tag_get.assert_called_with("123")
self.assertEquals(result, "fake tag")
self.assertEqual(result, "fake tag")

############################################################################

Expand All @@ -632,14 +632,14 @@ def test_tag_get_or_create_create(self, mock_tag_find_by_name,
def test_tag_association_endpoint(self):
action = self.create_class_object()
result = action.tag_association_endpoint()
self.assertEquals(result,
"/rest/com/vmware/cis/tagging/tag-association")
self.assertEqual(result,
"/rest/com/vmware/cis/tagging/tag-association")

def test_tag_association_endpoint_tag_id(self):
action = self.create_class_object()
result = action.tag_association_endpoint("123")
self.assertEquals(result,
"/rest/com/vmware/cis/tagging/tag-association/id:123")
self.assertEqual(result,
"/rest/com/vmware/cis/tagging/tag-association/id:123")

@mock.patch("vmwarelib.tagging.VmwareTagging.post")
def test_tag_association_attach(self, mock_post):
Expand All @@ -651,7 +651,7 @@ def test_tag_association_attach(self, mock_post):
params={'~action': "attach"},
payload={"object_id": {"id": "vm-789",
"type": "vm"}})
self.assertEquals(result, "response")
self.assertEqual(result, "response")

@mock.patch("vmwarelib.tagging.VmwareTagging.post")
def test_tag_association_attach_multiple(self, mock_post):
Expand All @@ -665,7 +665,7 @@ def test_tag_association_attach_multiple(self, mock_post):
payload={"tag_ids": test_tag_ids,
"object_id": {"id": "vm-789",
"type": "vm"}})
self.assertEquals(result, "response")
self.assertEqual(result, "response")

@mock.patch("vmwarelib.tagging.VmwareTagging.post")
def test_tag_association_detach(self, mock_post):
Expand All @@ -677,7 +677,7 @@ def test_tag_association_detach(self, mock_post):
params={'~action': 'detach'},
payload={"object_id": {"id": "vm-789",
"type": "vm"}})
self.assertEquals(result, "response")
self.assertEqual(result, "response")

@mock.patch("vmwarelib.tagging.VmwareTagging.post")
def test_tag_association_list_attached_tags(self, mock_post):
Expand All @@ -689,7 +689,7 @@ def test_tag_association_list_attached_tags(self, mock_post):
params={'~action': 'list-attached-tags'},
payload={"object_id": {"id": "vm-789",
"type": "vm"}})
self.assertEquals(result, "response")
self.assertEqual(result, "response")

@mock.patch("vmwarelib.tagging.VmwareTagging.post")
def test_tag_association_list_attached_objects(self, mock_post):
Expand All @@ -699,7 +699,7 @@ def test_tag_association_list_attached_objects(self, mock_post):

mock_post.assert_called_with("/rest/com/vmware/cis/tagging/tag-association/id:123",
params={'~action': 'list-attached-objects'})
self.assertEquals(result, "response")
self.assertEqual(result, "response")

@mock.patch("vmwarelib.tagging.VmwareTagging.tag_association_detach")
@mock.patch("vmwarelib.tagging.VmwareTagging.tag_get")
Expand All @@ -714,7 +714,7 @@ def test_tag_association_detach_category(self, mock_tag_association_list_attache
{"name": "3", "category_id": "c2"}]

results = action.tag_association_detach_category("c2", "vm", "vm-123")
self.assertEquals(results, [{"name": "3", "category_id": "c2"}])
self.assertEqual(results, [{"name": "3", "category_id": "c2"}])

@mock.patch("vmwarelib.tagging.VmwareTagging.tag_association_detach")
@mock.patch("vmwarelib.tagging.VmwareTagging.tag_get")
Expand All @@ -730,7 +730,7 @@ def test_tag_association_detach_category_no_match(self,
{"name": "3", "category_id": "c2"}]

results = action.tag_association_detach_category("xyz", "vm", "vm-123")
self.assertEquals(results, [])
self.assertEqual(results, [])

@mock.patch("vmwarelib.tagging.VmwareTagging.tag_association_attach")
@mock.patch("vmwarelib.tagging.VmwareTagging.tag_association_detach_category")
Expand All @@ -751,4 +751,4 @@ def test_tag_association_replace(self, mock_tag_get,
mock_tag_association_attach.assert_called_with("123",
"vm",
"vm-789")
self.assertEquals(results, "expected")
self.assertEqual(results, "expected")
Loading