Skip to content

Commit

Permalink
Merge pull request #3791 from hipek8/add_vendor_contract_number_and_l…
Browse files Browse the repository at this point in the history
…easing_rate

Add vendor contract number and leasing rate
  • Loading branch information
hipek8 authored Feb 21, 2024
2 parents c165df3 + baa6b4a commit 5c434a4
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/ralph/data_center/migrations/0030_auto_20240221_1004.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
11 changes: 11 additions & 0 deletions src/ralph/data_center/models/physical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
14 changes: 14 additions & 0 deletions src/ralph/data_center/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/ralph/data_center/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 5c434a4

Please sign in to comment.