def tests_api_asset(self): for item in get_assets(): self.assertEqual(item['asset_id'], self.asset.id) self.assertEqual( item['ralph_id'], self.asset.device_info.ralph_device_id, ) self.assertEqual(item['slots'], self.asset.slots) self.assertEqual(item['price'], self.asset.price) self.assertEqual(item['is_deprecated'], self.asset.is_deprecated()) self.assertEqual(item['sn'], self.asset.sn) self.assertEqual(item['barcode'], self.asset.barcode)
def tests_api_asset(self): date = datetime.date(2014, 03, 29) for item in get_assets(date): self.assertEqual(item['asset_id'], self.asset.id) self.assertEqual( item['ralph_id'], self.asset.device_info.ralph_device_id, ) self.assertEqual(item['slots'], self.asset.slots) self.assertEqual(item['price'], self.asset.price) self.assertEqual( item['is_deprecated'], self.asset.is_deprecated(date) ) self.assertEqual(item['sn'], self.asset.sn) self.assertEqual(item['barcode'], self.asset.barcode)
def tests_api_asset(self): date = datetime.date(2014, 03, 29) for item in get_assets(date): self.assertEqual(item['asset_id'], self.asset.id) self.assertEqual( item['ralph_id'], self.asset.device_info.ralph_device_id, ) self.assertEqual(item['slots'], self.asset.slots) self.assertEqual(item['price'], self.asset.price) self.assertEqual(item['is_deprecated'], self.asset.is_deprecated(date)) self.assertEqual(item['sn'], self.asset.sn) self.assertEqual(item['barcode'], self.asset.barcode) self.assertEqual(item['venture_id'], self.stock_venture.id) self.assertEqual(item['is_blade'], self.category.is_blade) self.assertEqual(item['cores_count'], self.asset.cores_count)
def assets(**kwargs): """Updates the devices from Ralph Assets.""" date = kwargs['today'] usages = { 'core': get_core_usage(), 'power_consumption': get_power_consumption_usage(), 'collocation': get_collocation_usage(), } new_assets = total = 0 for data in get_assets(date): if update_assets( data, date, usages, ): new_assets += 1 total += 1 return True, '%d new assets, %d total' % (new_assets, total), kwargs
def assets(**kwargs): """Updates the devices from Ralph Assets.""" date = kwargs['today'] count = sum(update_assets(data, date) for data in get_assets()) return True, '%d new devices' % count, kwargs