Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vendor contract number and leasing rate #3791

Merged
merged 3 commits into from
Feb 21, 2024
Merged
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
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
Loading