def get_db_size(request, project): """Return the size of the DB on disk in MB.""" size_tuple = perftest_refdata.get_db_size(project) #JSON can't serialize a decimal, so converting size_MB to string result = [] for item in size_tuple: item["size_mb"] = str(item["size_mb"]) result.append(item) return HttpResponse(json.dumps(result), content_type=API_CONTENT_TYPE)
def test_get_db_size(ptm): """Test the get_db_size method.""" sizes = perftest_refdata.get_db_size(ptm.project) db_names = [x["db_name"] for x in sizes] exp_db_names = [ u'{0}_objectstore_1'.format(ptm.project), u'{0}_perftest_1'.format(ptm.project), ] assert set(db_names) == set(exp_db_names) for db in sizes: assert db["size_mb"] > 0