distil/tests/test_database_module.py
adriant c8f82b1e3d adding copyright and licensing
Change-Id: Id0df9dff49a5f2f6dde523c57ef7bae61f85418d
2014-08-27 13:11:35 +12:00

35 lines
1.2 KiB
Python

# Copyright (C) 2014 Catalyst IT Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from . import test_interface, helpers
from distil import database
from datetime import timedelta
class TestDatabaseModule(test_interface.TestInterface):
def test_get_from_db(self):
"""Test to ensure the data in the database matches the data entered."""
num_resources = 32
num_tenants = 5
helpers.fill_db(self.session, num_tenants, num_resources, self.end)
db = database.Database(self.session)
for i in range(num_tenants):
usage = db.usage(self.start, self.start + timedelta(days=60),
"tenant_id_" + str(i))
self.assertEqual(usage.count(), num_resources)