From b0f9bddae8326754233ad26f429f66e049f2fed8 Mon Sep 17 00:00:00 2001 From: xliiv Date: Wed, 10 May 2017 12:18:11 +0200 Subject: [PATCH] Add new status `pre-liquidated` to DataCenterAssetStatus (#3062) --- .../migrations/0025_auto_20170510_1122.py | 20 +++++++++++++++++++ src/ralph/data_center/models/choices.py | 1 + src/ralph/data_center/tests/test_models.py | 17 ++++++++++++++++ .../data_importer/tests/test_demo_data.py | 2 +- 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/ralph/data_center/migrations/0025_auto_20170510_1122.py diff --git a/src/ralph/data_center/migrations/0025_auto_20170510_1122.py b/src/ralph/data_center/migrations/0025_auto_20170510_1122.py new file mode 100644 index 0000000000..227c4e0998 --- /dev/null +++ b/src/ralph/data_center/migrations/0025_auto_20170510_1122.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import ralph.lib.transitions.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('data_center', '0024_auto_20170331_1341'), + ] + + operations = [ + migrations.AlterField( + model_name='datacenterasset', + name='status', + field=ralph.lib.transitions.fields.TransitionField(default=1, choices=[(1, 'new'), (2, 'in use'), (3, 'free'), (4, 'damaged'), (5, 'liquidated'), (6, 'to deploy'), (7, 'cleaned'), (8, 'pre liquidated')]), + ), + ] diff --git a/src/ralph/data_center/models/choices.py b/src/ralph/data_center/models/choices.py index 93f58d58c9..5a7c07d6c4 100644 --- a/src/ralph/data_center/models/choices.py +++ b/src/ralph/data_center/models/choices.py @@ -13,6 +13,7 @@ class DataCenterAssetStatus(Choices): liquidated = _('liquidated') to_deploy = _('to deploy') cleaned = _('cleaned') + pre_liquidated = _("pre liquidated") class Orientation(Choices): diff --git a/src/ralph/data_center/tests/test_models.py b/src/ralph/data_center/tests/test_models.py index 9c787eb53d..b68cb57f37 100644 --- a/src/ralph/data_center/tests/test_models.py +++ b/src/ralph/data_center/tests/test_models.py @@ -493,3 +493,20 @@ def setUp(self): def test_masters(self): self.assertEqual(self.cluster_1.masters, [self.master]) + + +class TestDataCenterAssetStatuses(RalphTestCase): + def test_status_ids_are_consistent(self): + """ + Tests that adding choice keeps ids the same (choices should be + appended) + """ + statuses = DataCenterAssetStatus() + self.assertEqual( + statuses, + [ + (1, 'new'), (2, 'in use'), (3, 'free'), (4, 'damaged'), + (5, 'liquidated'), (6, 'to deploy'), (7, 'cleaned'), + (8, 'pre liquidated') + ] + ) diff --git a/src/ralph/data_importer/tests/test_demo_data.py b/src/ralph/data_importer/tests/test_demo_data.py index 9a7dc67b99..56bb1a5a40 100644 --- a/src/ralph/data_importer/tests/test_demo_data.py +++ b/src/ralph/data_importer/tests/test_demo_data.py @@ -10,6 +10,6 @@ class DemoDataTestCase(TestCase): def test_demo_data_command(self): management.call_command('demodata') - self.assertEqual(DataCenterAsset.objects.count(), 382) + self.assertEqual(DataCenterAsset.objects.count(), 422) self.assertEqual(BackOfficeAsset.objects.count(), 224) self.assertEqual(get_user_model().objects.count(), 33)