Skip to content
Permalink
Browse files

Fixes ValueError when parsing a float as int. Added testcase for that…

… bug.

Change-Id: I73ada2c3b73db922adcfcfb1aa9c3a0c1bd9db8b
  • Loading branch information...
Axel Dimroth
Axel Dimroth committed Jul 11, 2019
1 parent 61a235b commit a6909876c6022c1e20088314fb1cbaa54859fb33
@@ -46,7 +46,7 @@ def parse_mongodb_collections(info):
data = parsed.setdefault("%s %s" % (db_name, collection), {})
if key in required_keys_int:
try:
data[key] = int(value)
data[key] = int(float(value))
except ValueError:
pass
return parsed
@@ -0,0 +1,242 @@
# -*- encoding: utf-8
# yapf: disable


checkname = 'mongodb_collections'


info = [[u'intern', u'tickets', u'lastExtentSize', u'8495104'],
[u'intern', u'tickets', u'avgObjSize', u'629.275794789'],
[u'intern', u'tickets', u'totalIndexSize', u'2681728'],
[u'intern', u'tickets', u'storageSize', u'16875520'],
[u'intern',
u'tickets',
u'indexSizes',
u"{u'state_1': 539616, u'_id_customer_1_id_1': 1177344, u'_id_': 588672, u'date_1': 376096}"],
[u'intern', u'tickets', u'size', u'10965760'],
[u'intern', u'aqlogentries', u'lastExtentSize', u'66732032'],
[u'intern', u'aqlogentries', u'avgObjSize', u'177.614253465'],
[u'intern', u'aqlogentries', u'totalIndexSize', u'86248624'],
[u'intern', u'aqlogentries', u'storageSize', u'245678080'],
[u'intern',
u'aqlogentries',
u'indexSizes',
u"{u'_id_': 33660592, u'date_1': 26294016, u'id_1': 26294016}"],
[u'intern', u'aqlogentries', u'size', u'184185448'],
[u'intern', u'customers', u'lastExtentSize', u'5664768'],
[u'intern', u'customers', u'avgObjSize', u'1872.20849858'],
[u'intern', u'customers', u'totalIndexSize', u'1038352'],
[u'intern', u'customers', u'storageSize', u'11251712'],
[u'intern',
u'customers',
u'indexSizes',
u"{u'id_1': 196224, u'partnered._id_partner_1': 122640, u'extra_emails_canonized_1': 196224, u'support_contract.id_1': 122640, u'_id_': 130816, u'folder_1': 269808}"],
[u'intern', u'customers', u'size', u'6608896'],
[u'intern', u'trainings', u'lastExtentSize', u'1196032'],
[u'intern', u'trainings', u'avgObjSize', u'2101.39534884'],
[u'intern', u'trainings', u'totalIndexSize', u'32704'],
[u'intern', u'trainings', u'storageSize', u'1515520'],
[u'intern', u'trainings', u'indexSizes', u"{u'_id_': 8176, u'id_1': 24528}"],
[u'intern', u'trainings', u'size', u'542160'],
[u'intern', u'contacts', u'lastExtentSize', u'5242880'],
[u'intern', u'contacts', u'avgObjSize', u'286.96436564'],
[u'intern', u'contacts', u'totalIndexSize', u'2109408'],
[u'intern', u'contacts', u'storageSize', u'6983680'],
[u'intern',
u'contacts',
u'indexSizes',
u"{u'_id_customer_1_id_1': 793072, u'_id_': 400624, u'email_canonized_1': 915712}"],
[u'intern', u'contacts', u'size', u'3333952'],
[u'intern', u'invoices', u'lastExtentSize', u'8388608'],
[u'intern', u'invoices', u'avgObjSize', u'593.262302765'],
[u'intern', u'invoices', u'totalIndexSize', u'1831424'],
[u'intern', u'invoices', u'storageSize', u'11173888'],
[u'intern',
u'invoices',
u'indexSizes',
u"{u'client_1': 318864, u'_id_': 441504, u'_id_customer_1': 711312, u'id_1': 359744}"],
[u'intern', u'invoices', u'size', u'7594944'],
[u'intern', u'billedissues', u'lastExtentSize', u'8192'],
[u'intern', u'billedissues', u'avgObjSize', u'80.0'],
[u'intern', u'billedissues', u'totalIndexSize', u'8176'],
[u'intern', u'billedissues', u'storageSize', u'8192'],
[u'intern', u'billedissues', u'indexSizes', u"{u'_id_': 8176}"],
[u'intern', u'billedissues', u'size', u'80'],
[u'intern', u'phonebookentries', u'lastExtentSize', u'32768'],
[u'intern', u'phonebookentries', u'avgObjSize', u'90.0289855072'],
[u'intern', u'phonebookentries', u'totalIndexSize', u'16352'],
[u'intern', u'phonebookentries', u'storageSize', u'40960'],
[u'intern',
u'phonebookentries',
u'indexSizes',
u"{u'_id_': 8176, u'name_1': 8176}"],
[u'intern', u'phonebookentries', u'size', u'12424'],
[u'intern', u'ticketsteps', u'lastExtentSize', u'461258752'],
[u'intern', u'ticketsteps', u'avgObjSize', u'8784.25975962'],
[u'intern', u'ticketsteps', u'totalIndexSize', u'21609168'],
[u'intern', u'ticketsteps', u'storageSize', u'1747308544.0'],
[u'intern',
u'ticketsteps',
u'indexSizes',
u"{u'_id_': 5993008, u'_id_ticket_1': 5903072, u'date_1': 4676672, u'id_1': 5036416}"],
[u'intern', u'ticketsteps', u'size', u'1579383552.0'],
[u'intern', u'faqs', u'lastExtentSize', u'36864'],
[u'intern', u'faqs', u'avgObjSize', u'1137.18518519'],
[u'intern', u'faqs', u'totalIndexSize', u'16352'],
[u'intern', u'faqs', u'storageSize', u'36864'],
[u'intern', u'faqs', u'indexSizes', u"{u'_id_': 8176, u'id_1': 8176}"],
[u'intern', u'faqs', u'size', u'30704'],
[u'intern', u'bookings', u'lastExtentSize', u'81920'],
[u'intern', u'bookings', u'avgObjSize', u'259.759036145'],
[u'intern', u'bookings', u'totalIndexSize', u'24528'],
[u'intern', u'bookings', u'storageSize', u'102400'],
[u'intern', u'bookings', u'indexSizes', u"{u'_id_': 24528}"],
[u'intern', u'bookings', u'size', u'86240'],
[u'intern', u'quotes', u'lastExtentSize', u'4194304'],
[u'intern', u'quotes', u'avgObjSize', u'1698.60401146'],
[u'intern', u'quotes', u'totalIndexSize', u'286160'],
[u'intern', u'quotes', u'storageSize', u'5586944'],
[u'intern',
u'quotes',
u'indexSizes',
u"{u'client_1': 57232, u'_id_': 65408, u'_id_customer_1': 106288, u'id_1': 57232}"],
[u'intern', u'quotes', u'size', u'2964064'],
[u'intern', u'syllabuses', u'lastExtentSize', u'262144'],
[u'intern', u'syllabuses', u'avgObjSize', u'4487.78378378'],
[u'intern', u'syllabuses', u'totalIndexSize', u'8176'],
[u'intern', u'syllabuses', u'storageSize', u'327680'],
[u'intern', u'syllabuses', u'indexSizes', u"{u'_id_': 8176}"],
[u'intern', u'syllabuses', u'size', u'166048'],
[u'intern', u'testaccounts', u'lastExtentSize', u'147456'],
[u'intern', u'testaccounts', u'avgObjSize', u'156.681114551'],
[u'intern', u'testaccounts', u'totalIndexSize', u'57232'],
[u'intern', u'testaccounts', u'storageSize', u'192512'],
[u'intern',
u'testaccounts',
u'indexSizes',
u"{u'_id_': 24528, u'id_1': 32704}"],
[u'intern', u'testaccounts', u'size', u'50608'],
[u'intern', u'phonecalls', u'lastExtentSize', u'2097152'],
[u'intern', u'phonecalls', u'avgObjSize', u'131.656059191'],
[u'intern', u'phonecalls', u'totalIndexSize', u'817600'],
[u'intern', u'phonecalls', u'storageSize', u'2793472'],
[u'intern',
u'phonecalls',
u'indexSizes',
u"{u'_id_': 457856, u'end_-1': 359744}"],
[u'intern', u'phonecalls', u'size', u'1832784'],
[u'intern', u'projects', u'lastExtentSize', u'115826688'],
[u'intern', u'projects', u'avgObjSize', u'20874.201489'],
[u'intern', u'projects', u'totalIndexSize', u'1978592'],
[u'intern', u'projects', u'storageSize', u'418279424'],
[u'intern',
u'projects',
u'indexSizes',
u"{u'_id_customer_1_id_1': 1038352, u'_id_': 498736, u'date_1': 441504}"],
[u'intern', u'projects', u'size', u'305619184'],
[u'intern', u'system.indexes', u'lastExtentSize', u'36864'],
[u'intern', u'system.indexes', u'avgObjSize', u'81.6363636364'],
[u'intern', u'system.indexes', u'totalIndexSize', u'0'],
[u'intern', u'system.indexes', u'storageSize', u'45056'],
[u'intern', u'system.indexes', u'indexSizes', u'{}'],
[u'intern', u'system.indexes', u'size', u'3592'],
[u'local', u'startup_log', u'lastExtentSize', u'10485760'],
[u'local', u'startup_log', u'avgObjSize', u'914.090909091'],
[u'local', u'startup_log', u'totalIndexSize', u'0'],
[u'local', u'startup_log', u'storageSize', u'10485760'],
[u'local', u'startup_log', u'indexSizes', u'{}'],
[u'local', u'startup_log', u'size', u'40220']]


discovery = {'': [(u'intern aqlogentries', {}),
(u'intern billedissues', {}),
(u'intern bookings', {}),
(u'intern contacts', {}),
(u'intern customers', {}),
(u'intern faqs', {}),
(u'intern invoices', {}),
(u'intern phonebookentries', {}),
(u'intern phonecalls', {}),
(u'intern projects', {}),
(u'intern quotes', {}),
(u'intern syllabuses', {}),
(u'intern system.indexes', {}),
(u'intern testaccounts', {}),
(u'intern tickets', {}),
(u'intern ticketsteps', {}),
(u'intern trainings', {}),
(u'local startup_log', {})]}


checks = {'': [(u'intern aqlogentries',
{},
[(0, 'Uncompressed size in memory: 175.65 MB', []),
(0, 'Allocated for document storage: 234.30 MB', [])]),
(u'intern billedissues',
{},
[(0, 'Uncompressed size in memory: 80.00 B', []),
(0, 'Allocated for document storage: 8.00 kB', [])]),
(u'intern bookings',
{},
[(0, 'Uncompressed size in memory: 84.22 kB', []),
(0, 'Allocated for document storage: 100.00 kB', [])]),
(u'intern contacts',
{},
[(0, 'Uncompressed size in memory: 3.18 MB', []),
(0, 'Allocated for document storage: 6.66 MB', [])]),
(u'intern customers',
{},
[(0, 'Uncompressed size in memory: 6.30 MB', []),
(0, 'Allocated for document storage: 10.73 MB', [])]),
(u'intern faqs',
{},
[(0, 'Uncompressed size in memory: 29.98 kB', []),
(0, 'Allocated for document storage: 36.00 kB', [])]),
(u'intern invoices',
{},
[(0, 'Uncompressed size in memory: 7.24 MB', []),
(0, 'Allocated for document storage: 10.66 MB', [])]),
(u'intern phonebookentries',
{},
[(0, 'Uncompressed size in memory: 12.13 kB', []),
(0, 'Allocated for document storage: 40.00 kB', [])]),
(u'intern phonecalls',
{},
[(0, 'Uncompressed size in memory: 1.75 MB', []),
(0, 'Allocated for document storage: 2.66 MB', [])]),
(u'intern projects',
{},
[(0, 'Uncompressed size in memory: 291.46 MB', []),
(0, 'Allocated for document storage: 398.90 MB', [])]),
(u'intern quotes',
{},
[(0, 'Uncompressed size in memory: 2.83 MB', []),
(0, 'Allocated for document storage: 5.33 MB', [])]),
(u'intern syllabuses',
{},
[(0, 'Uncompressed size in memory: 162.16 kB', []),
(0, 'Allocated for document storage: 320.00 kB', [])]),
(u'intern system.indexes',
{},
[(0, 'Uncompressed size in memory: 3.51 kB', []),
(0, 'Allocated for document storage: 44.00 kB', [])]),
(u'intern testaccounts',
{},
[(0, 'Uncompressed size in memory: 49.42 kB', []),
(0, 'Allocated for document storage: 188.00 kB', [])]),
(u'intern tickets',
{},
[(0, 'Uncompressed size in memory: 10.46 MB', []),
(0, 'Allocated for document storage: 16.09 MB', [])]),
(u'intern ticketsteps',
{},
[(0, 'Uncompressed size in memory: 1.47 GB', []),
(0, 'Allocated for document storage: 1.63 GB', [])]),
(u'intern trainings',
{},
[(0, 'Uncompressed size in memory: 529.45 kB', []),
(0, 'Allocated for document storage: 1.45 MB', [])]),
(u'local startup_log',
{},
[(0, 'Uncompressed size in memory: 39.28 kB', []),
(0, 'Allocated for document storage: 10.00 MB', [])])]}

0 comments on commit a690987

Please sign in to comment.
You can’t perform that action at this time.