diff --git a/neat/db.py b/neat/db.py index 22eb32f..37c5ade 100644 --- a/neat/db.py +++ b/neat/db.py @@ -27,5 +27,5 @@ class Database(object): :param vms: The vms table. :param vm_resource_usage: The vm_resource_usage table. """ - self._vms = vms - self._vm_resource_usage = vm_resource_usage + self.vms = vms + self.vm_resource_usage = vm_resource_usage diff --git a/neat/db_utils.py b/neat/db_utils.py index 6e17dac..5b89f0e 100644 --- a/neat/db_utils.py +++ b/neat/db_utils.py @@ -41,7 +41,7 @@ def init_db(sql_connection): vm_resource_usage = Table('vm_resource_usage', metadata, Column('id', Integer, primary_key=True), Column('vm_id', Integer, ForeignKey('vms.id'), nullable=False), - Column('timestamp', DateTime, server_default=text("sysdate")), + Column('timestamp', DateTime, server_default=text('CURRENT_TIMESTAMP')), Column('cpu_mhz', Integer, nullable=False)) metadata.create_all() diff --git a/tests/test_collector.py b/tests/test_collector.py index 26399bf..391e567 100644 --- a/tests/test_collector.py +++ b/tests/test_collector.py @@ -143,7 +143,7 @@ class Collector(TestCase): #shutil.rmtree(local_data_directory_tmp) assert files == 0 - @qc(1) - def fetch_remote_data(): - pass + # @qc(1) + # def fetch_remote_data(): + # pass #collector.fetch_remote_data() diff --git a/tests/test_db_utils.py b/tests/test_db_utils.py index ba6ba6b..38980eb 100644 --- a/tests/test_db_utils.py +++ b/tests/test_db_utils.py @@ -25,7 +25,6 @@ class DbUtils(TestCase): @qc(1) def init_db(): - assert False db = db_utils.init_db('sqlite:///:memory:') assert type(db) is neat.db.Database assert isinstance(db.vms, Table) @@ -34,4 +33,13 @@ class DbUtils(TestCase): ['id', 'uuid'] assert db.vm_resource_usage.c.keys() == \ ['id', 'vm_id', 'timestamp', 'cpu_mhz'] - assert db.vm_resource_usage.foreign_keys == ['vm_id'] + assert list(db.vm_resource_usage.foreign_keys)[0].target_fullname \ + == 'vms.id' + + @qc(1) + def insert_select(): + db = db_utils.init_db('sqlite:///:memory:') + db.vms.insert().execute(uuid='test') + assert db.vms.select().execute().first()['uuid'] == 'test' + db.vm_resource_usage.insert().execute(vm_id=1, cpu_mhz=1000) + assert db.vm_resource_usage.select().execute().first()['cpu_mhz'] == 1000