diff --git a/magnum/tests/unit/api/controllers/v1/test_cluster.py b/magnum/tests/unit/api/controllers/v1/test_cluster.py index 9c37ff40e..503758488 100644 --- a/magnum/tests/unit/api/controllers/v1/test_cluster.py +++ b/magnum/tests/unit/api/controllers/v1/test_cluster.py @@ -386,11 +386,8 @@ def test_replace_ok_by_name(self, mock_utcnow): self.assertEqual(self.cluster_obj.cluster_template_id, response['cluster_template_id']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_replace_ok_by_name_not_found(self, mock_utcnow): + def test_replace_ok_by_name_not_found(self): name = 'not_found' - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.patch_json('/clusters/%s' % name, [{'path': '/name', 'value': name, @@ -399,11 +396,8 @@ def test_replace_ok_by_name_not_found(self, mock_utcnow): self.assertEqual('application/json', response.content_type) self.assertEqual(404, response.status_code) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_replace_ok_by_uuid_not_found(self, mock_utcnow): + def test_replace_ok_by_uuid_not_found(self): uuid = uuidutils.generate_uuid() - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.patch_json('/clusters/%s' % uuid, [{'path': '/cluster_id', 'value': uuid, @@ -425,11 +419,7 @@ def test_replace_cluster_template_id_failed(self): self.assertEqual(400, response.status_code) self.assertTrue(response.json['errors']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_replace_ok_by_name_multiple_cluster(self, mock_utcnow): - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time - + def test_replace_ok_by_name_multiple_cluster(self): obj_utils.create_test_cluster(self.context, name='test_cluster', uuid=uuidutils.generate_uuid()) obj_utils.create_test_cluster(self.context, name='test_cluster', @@ -626,25 +616,19 @@ def _simulate_cluster_create(self, cluster, master_count, node_count, cluster.create() return cluster - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_cluster(self, mock_utcnow): + def test_create_cluster(self): bdict = apiutils.cluster_post_data() - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json('/clusters', bdict) self.assertEqual('application/json', response.content_type) self.assertEqual(202, response.status_int) self.assertTrue(uuidutils.is_uuid_like(response.json['uuid'])) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_cluster_resource_limit_reached(self, mock_utcnow): + def test_create_cluster_resource_limit_reached(self): # override max_cluster_per_project to 1 CONF.set_override('max_clusters_per_project', 1, group='quotas') bdict = apiutils.cluster_post_data() - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time # create first cluster response = self.post_json('/clusters', bdict) diff --git a/magnum/tests/unit/api/controllers/v1/test_federation.py b/magnum/tests/unit/api/controllers/v1/test_federation.py index c321e3ef8..97bd65586 100644 --- a/magnum/tests/unit/api/controllers/v1/test_federation.py +++ b/magnum/tests/unit/api/controllers/v1/test_federation.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -import datetime from unittest import mock from oslo_config import cfg @@ -285,13 +284,10 @@ def _simulate_federation_create(self, federation, create_timeout): federation.create() return federation - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_federation(self, mock_utcnow): + def test_create_federation(self): bdict = apiutils.federation_post_data( uuid=uuidutils.generate_uuid(), hostcluster_id=self.hostcluster.uuid) - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json('/federations', bdict) self.assertEqual('application/json', response.content_type) diff --git a/magnum/tests/unit/api/controllers/v1/test_nodegroup.py b/magnum/tests/unit/api/controllers/v1/test_nodegroup.py index a2b757c97..de6ab0eb3 100644 --- a/magnum/tests/unit/api/controllers/v1/test_nodegroup.py +++ b/magnum/tests/unit/api/controllers/v1/test_nodegroup.py @@ -293,11 +293,8 @@ def _simulate_nodegroup_create(self, cluster, nodegroup): nodegroup.create() return nodegroup - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_nodegroup(self, mock_utcnow): + def test_create_nodegroup(self): ng_dict = apiutils.nodegroup_post_data() - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json(self.url, ng_dict) self.assertEqual('application/json', response.content_type) @@ -305,12 +302,9 @@ def test_create_nodegroup(self, mock_utcnow): self.assertTrue(uuidutils.is_uuid_like(response.json['uuid'])) self.assertFalse(response.json['is_default']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_nodegroup_without_node_count(self, mock_utcnow): + def test_create_nodegroup_without_node_count(self): ng_dict = apiutils.nodegroup_post_data() del ng_dict['node_count'] - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json(self.url, ng_dict) self.assertEqual('application/json', response.content_type) @@ -318,13 +312,10 @@ def test_create_nodegroup_without_node_count(self, mock_utcnow): # Verify node_count defaults to 1 self.assertEqual(1, response.json['node_count']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_nodegroup_with_zero_nodes(self, mock_utcnow): + def test_create_nodegroup_with_zero_nodes(self): ng_dict = apiutils.nodegroup_post_data() ng_dict['node_count'] = 0 ng_dict['min_node_count'] = 0 - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json(self.url, ng_dict) self.assertEqual('application/json', response.content_type) @@ -332,67 +323,49 @@ def test_create_nodegroup_with_zero_nodes(self, mock_utcnow): # Verify node_count is set to zero self.assertEqual(0, response.json['node_count']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_nodegroup_with_max_node_count(self, mock_utcnow): + def test_create_nodegroup_with_max_node_count(self): ng_dict = apiutils.nodegroup_post_data(max_node_count=5) - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json(self.url, ng_dict) self.assertEqual('application/json', response.content_type) self.assertEqual(202, response.status_int) self.assertEqual(5, response.json['max_node_count']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_nodegroup_with_role(self, mock_utcnow): + def test_create_nodegroup_with_role(self): ng_dict = apiutils.nodegroup_post_data(role='test-role') - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json(self.url, ng_dict) self.assertEqual('application/json', response.content_type) self.assertEqual(202, response.status_int) self.assertEqual('test-role', response.json['role']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_nodegroup_with_labels(self, mock_utcnow): + def test_create_nodegroup_with_labels(self): labels = {'label1': 'value1'} ng_dict = apiutils.nodegroup_post_data(labels=labels) - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json(self.url, ng_dict) self.assertEqual('application/json', response.content_type) self.assertEqual(202, response.status_int) self.assertEqual(labels, response.json['labels']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_nodegroup_with_image_id(self, mock_utcnow): + def test_create_nodegroup_with_image_id(self): ng_dict = apiutils.nodegroup_post_data(image_id='test_image') - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json(self.url, ng_dict) self.assertEqual('application/json', response.content_type) self.assertEqual(202, response.status_int) self.assertEqual('test_image', response.json['image_id']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_nodegroup_with_flavor(self, mock_utcnow): + def test_create_nodegroup_with_flavor(self): ng_dict = apiutils.nodegroup_post_data(flavor_id='test_flavor') - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json(self.url, ng_dict) self.assertEqual('application/json', response.content_type) self.assertEqual(202, response.status_int) self.assertEqual('test_flavor', response.json['flavor_id']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_nodegroup_only_name(self, mock_utcnow): + def test_create_nodegroup_only_name(self): ng_dict = {'name': 'test_ng'} - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json(self.url, ng_dict) self.assertEqual('application/json', response.content_type) @@ -409,11 +382,8 @@ def test_create_nodegroup_only_name(self, mock_utcnow): self.assertEqual(1, response.json['node_count']) self.assertIsNone(response.json['max_node_count']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_create_nodegroup_invalid_node_count(self, mock_utcnow): + def test_create_nodegroup_invalid_node_count(self): ng_dict = apiutils.nodegroup_post_data(node_count=7, max_node_count=5) - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time response = self.post_json(self.url, ng_dict, expect_errors=True) self.assertEqual('application/json', response.content_type) @@ -710,11 +680,7 @@ def test_remove_min_node_count(self, mock_utcnow): response['updated_at']).replace(tzinfo=None) self.assertEqual(test_time, return_updated_at) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_remove_internal_attr(self, mock_utcnow): - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time - + def test_remove_internal_attr(self): response = self.patch_json(self.url + self.nodegroup.name, [{'path': '/node_count', 'op': 'remove'}], expect_errors=True) @@ -722,11 +688,7 @@ def test_remove_internal_attr(self, mock_utcnow): self.assertEqual(400, response.status_code) self.assertIsNotNone(response.json['errors']) - @mock.patch('oslo_utils.timeutils.utcnow') - def test_remove_non_existent_property(self, mock_utcnow): - test_time = datetime.datetime(2000, 1, 1, 0, 0) - mock_utcnow.return_value = test_time - + def test_remove_non_existent_property(self): response = self.patch_json(self.url + self.nodegroup.name, [{'path': '/not_there', 'op': 'remove'}], expect_errors=True) diff --git a/releasenotes/source/2024.1.rst b/releasenotes/source/2024.1.rst index 4977a4f1a..6896656be 100644 --- a/releasenotes/source/2024.1.rst +++ b/releasenotes/source/2024.1.rst @@ -3,4 +3,4 @@ =========================== .. release-notes:: - :branch: stable/2024.1 + :branch: unmaintained/2024.1