diff --git a/src/ralph/data_center/migrations/0030_auto_20240221_1004.py b/src/ralph/data_center/migrations/0030_auto_20240221_1004.py new file mode 100644 index 0000000000..6b88191d88 --- /dev/null +++ b/src/ralph/data_center/migrations/0030_auto_20240221_1004.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('data_center', '0029_auto_20230920_1102'), + ] + + operations = [ + migrations.AddField( + model_name='datacenterasset', + name='leasing_rate', + field=models.FloatField(verbose_name='Vendor contact number', blank=True, null=True), + ), + migrations.AddField( + model_name='datacenterasset', + name='vendor_contract_number', + field=models.CharField(verbose_name='Vendor contract number', max_length=256, blank=True, null=True), + ), + ] diff --git a/src/ralph/data_center/models/physical.py b/src/ralph/data_center/models/physical.py index 8b0298c2e7..d1a10ede5a 100644 --- a/src/ralph/data_center/models/physical.py +++ b/src/ralph/data_center/models/physical.py @@ -461,6 +461,17 @@ class DataCenterAsset( choices=Orientation(), default=Orientation.front.id, ) + vendor_contract_number = models.CharField( + null=True, + blank=True, + max_length=256, + verbose_name=_('Vendor contract number'), + ) + leasing_rate = models.FloatField( + null=True, + blank=True, + verbose_name=_('Vendor contact number'), + ) slot_no = models.CharField( blank=True, help_text=_('Fill it if asset is blade server'), diff --git a/src/ralph/data_center/tests/test_api.py b/src/ralph/data_center/tests/test_api.py index a566d51c52..4e19719bb8 100644 --- a/src/ralph/data_center/tests/test_api.py +++ b/src/ralph/data_center/tests/test_api.py @@ -234,6 +234,20 @@ def test_patch_data_center_asset(self): self.assertTrue(self.dc_asset.force_depreciation) self.assertEqual(self.dc_asset.tags.count(), 1) + def test_update_vendor_contract_number_and_leasing_rate(self): + url = reverse('datacenterasset-detail', args=(self.dc_asset.id,)) + hostname = self.dc_asset.hostname + data = { + 'vendor_contract_number': 'abc-123', + 'leasing_rate': 123.45 + } + response = self.client.patch(url, data, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.dc_asset.refresh_from_db() + self.assertEqual(self.dc_asset.hostname, hostname) + self.assertEqual(self.dc_asset.vendor_contract_number, 'abc-123') + self.assertEqual(self.dc_asset.leasing_rate, 123.45) + def test_filter_by_configuration_path(self): url = reverse('datacenterasset-list') + '?configuration_path={}'.format( self.dc_asset.configuration_path.path, diff --git a/src/ralph/data_center/tests/test_models.py b/src/ralph/data_center/tests/test_models.py index 61deea69c5..ee53299a4f 100644 --- a/src/ralph/data_center/tests/test_models.py +++ b/src/ralph/data_center/tests/test_models.py @@ -543,9 +543,9 @@ def test_should_return_only_common_networks(self): (str(common_net.pk), common_net) ] expected_common_result = [(str(common_net.pk), common_net)] - self.assertEqual(rack_100_result, expected_rack100_result) + self.assertCountEqual(rack_100_result, expected_rack100_result) self.assertEqual(len(rack_100_result), 2) - self.assertEqual(common_result, expected_common_result) + self.assertCountEqual(common_result, expected_common_result) self.assertEqual(len(common_result), 1)