def test_empty(self): c = self.conn.cursor() c.execute('INSERT INTO images(imagefile) VALUES ("image0")') args = argparse.Namespace(where_shadowing_objects='TRUE', where_objects='TRUE') # Should succeed without issues. dbFilter.filterObjectsInsideCertainObjects(c, args)
def test_1shadowing_0others(self): ''' A single shadowing object, no other objects. Nothing should be deleted. ''' c = self.conn.cursor() c.execute('INSERT INTO images(imagefile) VALUES ("image0")') c.execute( 'INSERT INTO objects(imagefile,objectid,x1,y1,width,height,name) ' 'VALUES ("image0",1,40,20,40,20,"shadowing")') args = argparse.Namespace(where_shadowing_objects='TRUE', where_objects='TRUE') dbFilter.filterObjectsInsideCertainObjects(c, args) c.execute('SELECT objectid FROM objects') object_ids = c.fetchall() self.assertEqual(object_ids, [(1, )])
def test_1shadowingBox_1insideBox(self): ''' 1 shadowing object (via a box), 1 other objects (via a box.) The other object is INSIDE the shadowing one. It should be deleted. ''' c = self.conn.cursor() c.execute('INSERT INTO images(imagefile) VALUES ("image0")') c.execute( 'INSERT INTO objects(imagefile,objectid,x1,y1,width,height,name) ' 'VALUES ("image0",1,40,20,40,20,"shadowing")') c.execute('INSERT INTO objects(imagefile,objectid,x1,y1,width,height) ' 'VALUES ("image0",2,40,20,40,20)') args = argparse.Namespace(where_shadowing_objects='name="shadowing"', where_objects='TRUE') dbFilter.filterObjectsInsideCertainObjects(c, args) c.execute('SELECT objectid FROM objects') object_ids = c.fetchall() self.assertEqual(object_ids, [(1, )])