Skip to content
Snippets Groups Projects
Commit e548962d authored by Marcelo Lacerda's avatar Marcelo Lacerda
Browse files

Improved test for incomplete inventory

parent f5f69e8b
No related branches found
No related tags found
No related merge requests found
......@@ -74,11 +74,30 @@ def test_clean_proinfo_inventory(cur):
def test_move_incomplete_proinfo_inventory(cur):
print 'Incomplete inventory entries are moved to rejected_inventory'
cur.execute("INSERT INTO proinfo_inventory(inep, macaddr) VALUES ('invalid', '0:0:0:0');")
inv = []
inv.append("INSERT INTO proinfo_inventory(project, inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES (0, 'PR97201405', '0:0:0:0', 'Linux', 'Ubuntu 10.04.4 LTS', '2.6.35-25-generic', 'Intel(R) Celeron(R) CPU E1200 @', 160, '1016076 ST3160318AS_6VY4BK6R', 150, 10);")
inv.append("INSERT INTO proinfo_inventory(project, inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES (0, 'invalid', '00:00:00:00:00:01', 'Linux', 'Ubuntu 10.04.4 LTS', '2.6.35-25-generic', 'Intel(R) Celeron(R) CPU E1200 @', 160, '1016076 ST3160318AS_6VY4BK6R', 150, 10);")
inv.append("INSERT INTO proinfo_inventory(project, inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES (4, 'PR97201405', '00:00:00:00:00:01', 'Linux', 'Ubuntu 10.04.4 LTS', '2.6.35-25-generic', 'Intel(R) Celeron(R) CPU E1200 @', 160, '1016076 ST3160318AS_6VY4BK6R', 150, 10);")
inv.append("INSERT INTO proinfo_inventory(inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES ('PR97201405', '00:00:00:00:00:01', null, 'Ubuntu 10.04.4 LTS', '2.6.35-25-generic', 'Intel(R) Celeron(R) CPU E1200 @', 160, '1016076 ST3160318AS_6VY4BK6R', 150, 10);")
inv.append("INSERT INTO proinfo_inventory(inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES ('PR97201405', '00:00:00:00:00:01', 'Linux', null, '2.6.35-25-generic', 'Intel(R) Celeron(R) CPU E1200 @', 160, '1016076 ST3160318AS_6VY4BK6R', 150, 10);")
inv.append("INSERT INTO proinfo_inventory(inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES ('PR97201405', '00:00:00:00:00:01', 'Linux', 'Ubuntu 10.04.4 LTS', null, 'Intel(R) Celeron(R) CPU E1200 @', 160, '1016076 ST3160318AS_6VY4BK6R', 150, 10);")
inv.append("INSERT INTO proinfo_inventory(inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES ('PR97201405', '00:00:00:00:00:01', 'Linux', 'Ubuntu 10.04.4 LTS', '2.6.35-25-generic', null, 160, '1016076 ST3160318AS_6VY4BK6R', 150, 10);")
inv.append("INSERT INTO proinfo_inventory(inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES ('PR97201405', '00:00:00:00:00:01', 'Linux', 'Ubuntu 10.04.4 LTS', '2.6.35-25-generic', 'Intel(R) Celeron(R) CPU E1200 @', null, '1016076 ST3160318AS_6VY4BK6R', 150, 10);")
inv.append("INSERT INTO proinfo_inventory(inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES ('PR97201405', '00:00:00:00:00:01', 'Linux', 'Ubuntu 10.04.4 LTS', '2.6.35-25-generic', 'Intel(R) Celeron(R) CPU E1200 @', 160, null, 150, 10);")
inv.append("INSERT INTO proinfo_inventory(inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES ('PR97201405', '00:00:00:00:00:01', 'Linux', 'Ubuntu 10.04.4 LTS', '2.6.35-25-generic', 'Intel(R) Celeron(R) CPU E1200 @', 160, '1016076 ST3160318AS_6VY4BK6R', null, 10);")
inv.append("INSERT INTO proinfo_inventory(inep, macaddr, os_type, os_distro, os_kernel, processor, memory, disk1_model, disk1_size, disk1_used) VALUES ('PR97201405', '00:00:00:00:00:01', 'Linux', 'Ubuntu 10.04.4 LTS', '2.6.35-25-generic', 'Intel(R) Celeron(R) CPU E1200 @', 160, '1016076 ST3160318AS_6VY4BK6R', 150, null);")
for i in inv:
cur.execute(i)
cur.execute("SELECT COUNT(*) FROM dim_inventory;")
oldCount = cur.fetchone()[0]
cur.execute('SELECT load_dw();')
cur.execute("SELECT COUNT(*) FROM dim_inventory AS i JOIN dim_school AS s ON sch_id = i.id WHERE inep = 'invalid';")
count = cur.fetchone()[0]
assert 0 == count
cur.execute("SELECT COUNT(*) FROM dim_inventory;")
newCount = cur.fetchone()[0]
assert newCount == oldCount
cur.execute("SELECT COUNT(*) FROM rejected_inventory;")
assert len(inv) == cur.fetchone()[0]
def main():
from sys import argv, exit
......@@ -93,7 +112,7 @@ def main():
test_inventory_data(cur)
test_inventory_multi_hd(cur, count)
test_move_incomplete_proinfo_inventory(cur)
test_one_per_day_multiple_load(cur)
# test_one_per_day_multiple_load(cur) Probably never going to happen
print 'Ok'
except AssertionError:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment