Skip to content

Commit

Permalink
Merge pull request #1035 from xor-xor/ralph_1850
Browse files Browse the repository at this point in the history
Removed module 'ralph.util.pricing' and the code that relates to it.
  • Loading branch information
andrzej-jankowski committed Aug 28, 2014
2 parents 6f48205 + 25ad3de commit e020550
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 1,730 deletions.
3 changes: 1 addition & 2 deletions src/ralph/discovery/management/commands/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import xlwt

from bob.csvutil import UnicodeWriter
from ralph.util import pricing
from ralph.business.models import Venture
from ralph.discovery.models import DeviceType, ReadOnlyDevice

Expand Down Expand Up @@ -95,7 +94,7 @@ def position(dev):
('Serial Number', field('sn')),
('Venture', subfield('venture', 'name')),
('Quoted Price', field('cached_price')),
('Cost', lambda d: '%.2f' % pricing.get_device_cost(d)),
('Cost', lambda d: 0.0), # a leftover from ralph.util.pricing
('Model', field('model')),
('Remarks', field('remarks')),
]
Expand Down
26 changes: 0 additions & 26 deletions src/ralph/discovery/plugins/cache_price.py

This file was deleted.

104 changes: 0 additions & 104 deletions src/ralph/discovery/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,110 +26,6 @@
from tastypie.test import ResourceTestCase


class DeviceWithPricingResourceTest(ResourceTestCase):

def setUp(self):
super(DeviceWithPricingResourceTest, self).setUp()
self.resource = 'devicewithpricing'
self.user = User.objects.create_user(
'ralph',
'ralph@ralph.local',
'ralph'
)

self.venture = Venture(name='Infra').save()
self.deprecation_kind = DeprecationKind(
name='12 months',
months=12
).save()
srv1 = {
'sn': 'srv-1',
'model_name': 'server',
'model_type': DeviceType.virtual_server,
'venture': self.venture,
'name': 'Srv 1',
'purchase_date': datetime.datetime(2020, 1, 1, 0, 0),
'deprecation_kind': self.deprecation_kind,
}
srv1_cpu = {
'model_name': 'Intel PCU1',
'label': 'CPU 1',
'priority': 0,
'family': 'Intsels',
'price': 120,
'count': 2,
'speed': 1200,
}
srv1_memory = {
'priority': 0,
'family': 'Noname RAM',
'label': 'Memory 1GB',
'price': 100,
'speed': 1033,
'size': 512,
'count': 6,
}
srv1_storage = {
'model_name': 'Store 1TB',
'label': 'store 1TB',
'priority': 0,
'family': 'Noname Store',
'price': 180,
'count': 10,
}
self.device = create_device(
device=srv1,
cpu=srv1_cpu,
memory=srv1_memory,
storage=srv1_storage,
)
self.device.save()

name = 'Splunk Volume 100 GiB'
symbol = 'splunkvolume'
model, created = ComponentModel.create(
ComponentType.unknown,
family=symbol,
name=name,
priority=0,
)
model_group, created = ComponentModelGroup.objects.get_or_create(
name='Group Splunk',
price=128,
type=ComponentType.unknown,
)
model.group = model_group
model.save()

res, created = SplunkUsage.concurrent_get_or_create(
device=self.device,
day=datetime.date.today(),
defaults={'model': model},
)
res.size = 10
res.save()

def test_get_list_json(self):
resp = self.api_client.get(
'/api/v0.9/{0}/'.format(self.resource),
format='json',
)
self.assertValidJSONResponse(resp)
device = self.deserialize(resp)['objects'][0]
self.assertEqual(device['id'], 1)
self.assertEqual(device['name'], 'Srv 1')
self.assertEqual(device['sn'], 'srv-1')
self.assertEqual(device['total_cost'], 2640)
self.assertDictEqual(
device['splunk'],
{
'splunk_size': 10,
'splunk_monthly_cost': 128.0,
'splunk_daily_cost': 128.0
}
)


class AccessToDiscoveyApiTest(TestCase):

def setUp(self):
Expand Down
15 changes: 0 additions & 15 deletions src/ralph/scan/postprocess/cache_price.py

This file was deleted.

Loading

0 comments on commit e020550

Please sign in to comment.