Esempio n. 1
0
 def test_get_export(self):
     '''Tests if you can pull the export record from the database that have been imported/shredded.'''
     mappedObjects = dbobjects.DatabaseObjects(pg_db)
     theExport = mappedObjects.queryDB(dbobjects.Export)[0]
     if settings.DEBUG:
         print theExport.export_software_vendor
     self.assertEqual(theExport.export_software_vendor, "HMIS_'R_Us")
Esempio n. 2
0
 def test_get_other_names(self):
     '''Tests that there are 0 'othername' records in the database
     '''
     mappedObjects = dbobjects.DatabaseObjects(pg_db)
     cnt_other_names = mappedObjects.queryDB(dbobjects.OtherNames).count()
     
     self.assertEqual(cnt_other_names,0)
Esempio n. 3
0
 def test_get_person_historical(self):
     '''Test if you can pull person_historical records from the database that have been imported/shredded
     '''
     mappedObjects = dbobjects.DatabaseObjects(pg_db)
     ph = mappedObjects.queryDB(dbobjects.PersonHistorical).all()
     
     for historical in ph:    
         if settings.DEBUG:
             print 'historical.person_historical_id_num=%s' %historical.person_historical_id_num
         
     self.assertEqual(len(ph),6)
Esempio n. 4
0
 def test_get_export_children(self):
     '''Tests if you can pull the exports related records from the database that have been imported/shredded.
     mapper(Export, export_table, properties={'fk_export_to_person': relation(Person), 'fk_export_to_database': relation(Database)})
     '''
     mappedObjects = dbobjects.DatabaseObjects(pg_db)
     # first get the export object then get it's related objects
     theExports = mappedObjects.queryDB(dbobjects.Export)
     for export in theExports:
         child = export.fk_export_to_person[0]
     if settings.DEBUG:
         print child.person_legal_first_name_unhashed
         
     #self.assertEqual(child.person_legal_first_name_unhashed, "George")
     self.assertTrue((child.person_social_security_number_unhashed=="111111111") and (child.person_legal_first_name_unhashed=="George"))
Esempio n. 5
0
 def test_get_person_historicals_children_backref(self):
     '''Tests if you can pull the children (IncomeAndSources) of person historical and get back to the person record for all records who earned $100
     mapper(PersonHistorical, person_historical_table, properties={'fk_income_and_sources': relation(IncomeAndSources), 'fk_veteran': relation(Veteran),'fk_hud_homeless_episodes': relation(HUDHomelessEpisodes),'fk_person_address': relation(PersonAddress)})
     '''
     
     mappedObjects = dbobjects.DatabaseObjects(pg_db)
     ias = mappedObjects.queryDB(dbobjects.IncomeAndSources).filter_by(amount=100).all()
     
     for ia in ias:
         if settings.DEBUG:
             print 'IncomeAndSources.person_historical_id_num=%s' % ia.income_source_code
     
     p = ias[0].fk_income_and_sources_to_person_historical.fk_person_historical_to_person
     
     self.assertEqual(p.person_social_security_number_unhashed,'111111111')
Esempio n. 6
0
 def test_get_exports_children_backref(self):
     '''Tests if you can pull the exports related records from the database that have been imported/shredded.
     mapper(Export, export_table, properties={'fk_export_to_person': relation(Person), 'fk_export_to_database': relation(Database)})
     '''
     mappedObjects = dbobjects.DatabaseObjects(pg_db)
     theExports = mappedObjects.queryDB(dbobjects.Export).first()
     if settings.DEBUG:
         print 'Software Vendor: %s' % theExports.export_software_vendor
         
     dbo = theExports.fk_export_to_database[0]
     print 'type: %s' % type(dbo)
     
     if settings.DEBUG:
         print 'dbo.database_contact_phone=%s' %dbo.database_contact_phone
     
     self.assertTrue(dbo.database_email=='*****@*****.**')
Esempio n. 7
0
 def test_number_of_persons_who_live_in_anytown_florida(self):
     '''Query database for count of people who live in anytown Florida
     '''
     settings.DEBUG_ALCHEMY = True
     mappedObjects = dbobjects.DatabaseObjects(pg_db)
     '''
         session.query(User).join('addresses').\
     ...     filter(Address.email_address=='*****@*****.**').all()
         .join(['bars', 'bats', 'widgets'])
     '''
     veteranCnt = mappedObjects.queryDB(dbobjects.Person).\
     join(['fk_person_to_person_historical','fk_person_historical_to_person_address']).\
     filter_by(city='Anytown', state='Florida').count()
     
     if settings.DEBUG:
         people = mappedObjects.queryDB(dbobjects.Person).\
             join(['fk_person_to_person_historical','fk_person_historical_to_person_address']).\
             filter_by(city='Anytown', state='Florida').all()
         for person in people:
             print '%s is from AnyTown, FL' % person.person_legal_first_name_unhashed
     
     self.assertEqual(veteranCnt,1)