Skip to content

Commit eed7a36

Browse files
authoredFeb 14, 2025··
hotfix/fix-ci-errors (#98)
- Bumped pyVmomi to latest version to fix cyclic dependency in setup.py - Removed unnecessary test requirements - assertEquals has been deprecated since python 2.7 and replaced with assertEqual https://pydoc-zh.readthedocs.io/en/latest/library/unittest.html#deprecated-aliases - Returning anything other than None in test_ functions is deprecated - Removed test_config_schema.py because the self.shell.run() function was causing issues and the whole file is unnecessary anyway because several different configs are already tested in the test_action_vmwarelib_actions.py file
2 parents 5977631 + d789fbb commit eed7a36

9 files changed

+69
-154
lines changed
 

Diff for: ‎CHANGES.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change Log
22

3+
## v1.3.5
4+
5+
Updates:
6+
* Updated test files to work with latest CI updates (@jschoewe)
7+
8+
## v1.3.4
9+
10+
Updates:
11+
* `serialize.py` - Added vim.vm.BootOptions class to return readable values for that object. (@jschoewe)
12+
313
## v1.3.3
414

515
Updates:

Diff for: ‎actions/vmwarelib/serialize.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
vim.option.OptionValue,
2828
vim.SharesInfo,
2929
vim.StorageResourceManager.IOAllocationInfo,
30+
vim.vm.BootOptions,
3031
vim.vm.ConfigInfo,
3132
vim.vm.Summary,
3233
vim.vm.Summary.ConfigSummary,

Diff for: ‎pack.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ref: vsphere
33
name: vsphere
44
description: VMware vSphere
55
stackstorm_version: ">=2.9.0"
6-
version: 1.3.3
6+
version: 1.3.5
77
author: Paul Mulvihill
88
email: paul.mulvihill@pulsant.com
99
contributors:

Diff for: ‎requirements-tests.txt

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
# these old pins conflict with those in st2 causing CI to fail
2-
# feel free to update if you still want a pack-local cache of the deps
3-
#mock>=1.3.0,<2.0
4-
#unittest2>=1.1.0,<2.0
5-
#nose>=1.3.7
6-
#eventlet==0.25.1
7-
#requests[security]==2.23.0
8-
#pytz==2019.1
9-
pyvmomi==7.0.2
1+
pyvmomi==8.0.3.0.1

Diff for: ‎requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pyvmomi==7.0.2
1+
pyvmomi==8.0.3.0.1

Diff for: ‎tests/test_action_vmwarelib_actions.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414

1515
import mock
16-
17-
from vmwarelib.actions import BaseAction
1816
from vsphere_base_action_test_case import VsphereBaseActionTestCase
1917
from get_objects_with_tag import GetObjectsWithTag
2018

@@ -28,13 +26,23 @@ class BaseActionTestCase(VsphereBaseActionTestCase):
2826
# action_cls = BaseAction
2927
action_cls = GetObjectsWithTag
3028

31-
def test_init(self):
32-
action = self.get_action_instance(self._new_config)
33-
self.assertIsInstance(action, BaseAction)
29+
def test_init_config_new(self):
30+
action = self.get_action_instance(self.new_config)
31+
self.assertIsInstance(action, self.action_cls)
32+
33+
def test_init_config_blank(self):
34+
self.assertRaises(ValueError, self.action_cls, self.blank_config)
35+
36+
def test_init_config_old(self):
37+
self.assertRaises(ValueError, self.action_cls, self.old_config)
38+
39+
def test_init_config_old_partial(self):
40+
self.assertRaises(ValueError, self.action_cls, self.old_config_partial)
3441

35-
def test_init_blank_config(self):
36-
with self.assertRaises(ValueError):
37-
self.get_action_instance(self._blank_config)
42+
def test_init_config_new_partial(self):
43+
action = self.get_action_instance(self.new_config_partial)
44+
self.assertRaises(KeyError, action.establish_connection,
45+
vsphere="default")
3846

3947
def test_get_connection_info(self):
4048
action = self.get_action_instance(self._new_config)

Diff for: ‎tests/test_action_vmwarelib_tagging.py

+38-38
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_category_list(self, mock_get):
259259

260260
# assert
261261
mock_get.assert_called_with("/rest/com/vmware/cis/tagging/category")
262-
self.assertEquals(result, expected)
262+
self.assertEqual(result, expected)
263263

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

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

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

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

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

309309
# assert
310-
self.assertEquals(result, {"name": "b", "value": "xx"})
310+
self.assertEqual(result, {"name": "b", "value": "xx"})
311311

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

327327
# assert
328-
self.assertEquals(result, None)
328+
self.assertEqual(result, None)
329329

330330
def test_category_create_spec(self):
331331
action = self.create_class_object()
332332
create_spec = action.category_create_spec()
333-
self.assertEquals(create_spec, {"name": "",
334-
"description": "",
335-
"cardinality": "SINGLE",
336-
"associable_types": []})
333+
self.assertEqual(create_spec, {"name": "",
334+
"description": "",
335+
"cardinality": "SINGLE",
336+
"associable_types": []})
337337

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

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

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

398398
# assert
399399
mock_category_find_by_name.assert_called_with("name")
400-
self.assertEquals(result, "fake category")
400+
self.assertEqual(result, "fake category")
401401

402402
@mock.patch("vmwarelib.tagging.VmwareTagging.category_get")
403403
@mock.patch("vmwarelib.tagging.VmwareTagging.category_create")
@@ -426,7 +426,7 @@ def test_category_get_or_create_create_all_params(self, mock_category_find_by_na
426426
mock_category_create.assert_called_with(test_name, test_description, test_cardinality,
427427
test_associable_types)
428428
mock_category_get.assert_called_with("123")
429-
self.assertEquals(result, "fake category")
429+
self.assertEqual(result, "fake category")
430430

431431
@mock.patch("vmwarelib.tagging.VmwareTagging.category_get")
432432
@mock.patch("vmwarelib.tagging.VmwareTagging.category_create")
@@ -450,7 +450,7 @@ def test_category_get_or_create_create_no_params(self, mock_category_find_by_nam
450450
mock_category_find_by_name.assert_called_with(test_name)
451451
mock_category_create.assert_called_with(test_name, None, None, None)
452452
mock_category_get.assert_called_with("123")
453-
self.assertEquals(result, "fake category")
453+
self.assertEqual(result, "fake category")
454454

455455
############################################################################
456456

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

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

485485
# assert
486486
mock_get.assert_called_with("/rest/com/vmware/cis/tagging/tag")
487-
self.assertEquals(result, expected)
487+
self.assertEqual(result, expected)
488488

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

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

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

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

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

536536
# assert
537537
mock_tag_list.assert_called_with(test_category_id)
538-
self.assertEquals(result, {"name": "b", "value": "xx"})
538+
self.assertEqual(result, {"name": "b", "value": "xx"})
539539

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

562562
def test_tag_create_spec(self):
563563
action = self.create_class_object()
564564
create_spec = action.tag_create_spec()
565-
self.assertEquals(create_spec, {"name": "",
566-
"description": "",
567-
"category_id": ""})
565+
self.assertEqual(create_spec, {"name": "",
566+
"description": "",
567+
"category_id": ""})
568568

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

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

603603
# assert
604604
mock_tag_find_by_name.assert_called_with(test_tag_name, test_category_id)
605-
self.assertEquals(result, "fake tag")
605+
self.assertEqual(result, "fake tag")
606606

607607
@mock.patch("vmwarelib.tagging.VmwareTagging.tag_get")
608608
@mock.patch("vmwarelib.tagging.VmwareTagging.tag_create")
@@ -623,7 +623,7 @@ def test_tag_get_or_create_create(self, mock_tag_find_by_name,
623623
mock_tag_find_by_name.assert_called_with(test_tag_name, test_category_id)
624624
mock_tag_create.assert_called_with(test_tag_name, test_category_id, None)
625625
mock_tag_get.assert_called_with("123")
626-
self.assertEquals(result, "fake tag")
626+
self.assertEqual(result, "fake tag")
627627

628628
############################################################################
629629

@@ -632,14 +632,14 @@ def test_tag_get_or_create_create(self, mock_tag_find_by_name,
632632
def test_tag_association_endpoint(self):
633633
action = self.create_class_object()
634634
result = action.tag_association_endpoint()
635-
self.assertEquals(result,
636-
"/rest/com/vmware/cis/tagging/tag-association")
635+
self.assertEqual(result,
636+
"/rest/com/vmware/cis/tagging/tag-association")
637637

638638
def test_tag_association_endpoint_tag_id(self):
639639
action = self.create_class_object()
640640
result = action.tag_association_endpoint("123")
641-
self.assertEquals(result,
642-
"/rest/com/vmware/cis/tagging/tag-association/id:123")
641+
self.assertEqual(result,
642+
"/rest/com/vmware/cis/tagging/tag-association/id:123")
643643

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

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

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

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

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

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

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

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

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

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

735735
@mock.patch("vmwarelib.tagging.VmwareTagging.tag_association_attach")
736736
@mock.patch("vmwarelib.tagging.VmwareTagging.tag_association_detach_category")
@@ -751,4 +751,4 @@ def test_tag_association_replace(self, mock_tag_get,
751751
mock_tag_association_attach.assert_called_with("123",
752752
"vm",
753753
"vm-789")
754-
self.assertEquals(results, "expected")
754+
self.assertEqual(results, "expected")

Diff for: ‎tests/test_config_schema.py

-77
This file was deleted.

Diff for: ‎tests/vsphere_base_action_test_case.py

+1-20
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,6 @@ def new_config_partial(self):
5757
def old_config_partial(self):
5858
return self._old_config_partial
5959

60-
def test_run_config_blank(self):
61-
self.assertRaises(ValueError, self.action_cls, self.blank_config)
62-
63-
def test_run_config_old(self):
64-
self.assertRaises(ValueError, self.action_cls, self.old_config)
65-
66-
def test_run_config_new(self):
67-
action = self.get_action_instance(self.new_config)
68-
self.assertIsInstance(action, self.action_cls)
69-
return action
70-
71-
def test_run_config_old_partial(self):
72-
self.assertRaises(ValueError, self.action_cls, self.old_config_partial)
73-
74-
def test_run_config_new_partial(self):
75-
action = self.get_action_instance(self.new_config_partial)
76-
self.assertRaises(KeyError, action.establish_connection,
77-
vsphere="default")
78-
7960
def mock_one_vm(self, vm_id):
8061
"""
8162
Configure a single VM mock. Helps make writing tests against vm actions easier.
@@ -86,7 +67,7 @@ def mock_one_vm(self, vm_id):
8667
Returns:
8768
- (action, mock_vm)
8869
"""
89-
action = self.test_run_config_new()
70+
action = self.get_action_instance(self.new_config)
9071
action.establish_connection = mock.Mock()
9172
action.si_content = mock.Mock()
9273
action.si_content.rootFolder = mock.Mock()

0 commit comments

Comments
 (0)
Please sign in to comment.