def test_addProjects(self): adb = AstridDB(dbname = "turtle_sim", test = True, quiet = True) self.assertEquals(adb.host, "gbtdata.gbt.nrao.edu") self.assertEquals(adb.user, "turtle_admin") self.assertEquals(adb.dbname, "turtle_sim") # make sure the DB is clean for acode in self.acodes: self.assertEquals(False, adb.astridCodeExists(acode)) # here's what we're actually testing adb.addProjects(self.pcodes) # make sure they got in, then clean up for acode in self.acodes: self.assertEquals(True, adb.astridCodeExists(acode)) adb.removeAstridCode(acode) self.assertEquals(False, adb.astridCodeExists(acode))
class DSSDatabase(object): """ This class is responsible for populating a DSS database that has already been primed with static information (observing types table, etc.) with the data necessary for running the DSS for a semester. The main tasks are: transferring data from an intermediary DB that Carl populates, tranferring raw tables we get from Carl's system. To prepare the database for a specific semester (including things like rcvr schedules), this class should be extended. """ def __init__(self, database = "dss_prime" , interactive = False , test = False ): self.interactive = interactive # responsible for data transfers self.dss_prime = DSSPrime2DSS(database = database) # be careful w/ the turtle DB dbname = "turtle" if not test else "turtle_sim" self.astridDB = AstridDB(dbname = dbname, test = test) def create(self, semester): "Method for creating a new DSS database " # Transfer the stuff that is semester independent self.dss_prime.transfer() # we no longer create new DSS DB's really, except for testing # so won't bother w/ astrid codes here. def append(self, semester): "Method for appending new semester data to existing DSS database" self.dss_prime.transfer_only_new() # transfer project codes to astrid self.astridDB.addProjects(self.dss_prime.new_projects)