コード例 #1
0
ファイル: TestAstridDB.py プロジェクト: mmccarty/nell
    def test_astridCodeExists(self):

        # Note: this is not really a unit test, since it connects
        # to an external DB.  This DB can be changed by anyone,
        # though it's a safe bet that this projects won't change.
        adb = AstridDB(dbname = "turtle_sim", test = True)
        r = adb.astridCodeExists("my little pony")
        self.assertEquals(False, r)
        r = adb.astridCodeExists("AGBT01A_020")
        self.assertEquals(True, r)
コード例 #2
0
ファイル: TestAstridDB.py プロジェクト: mmccarty/nell
    def setUp(self):

        # pcodes should get converted to acodes
        self.pcodes = ["GBTMy-Project"
                    , "TGBT-MyLittlePony"
                    , "GBT12A-001"
                    , "BB240"
                    , "VLBA12A-222"
                      ]
        self.acodes = ["AGBTMy_Project"
                     , "TGBT_MyLittlePony"
                     , "AGBT12A_001"
                     , "ABB240"
                     , "AVLB12A_222"
                      ] 
        
        # make sure DB is clean
        adb = AstridDB(dbname = "turtle_sim", test = True)
        for acode in self.acodes:
            adb.removeAstridCode(acode)
コード例 #3
0
ファイル: DSSDatabase.py プロジェクト: mmccarty/nell
    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)
コード例 #4
0
ファイル: DSSDatabase.py プロジェクト: mmccarty/nell
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)
コード例 #5
0
ファイル: TestAstridDB.py プロジェクト: mmccarty/nell
    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))
コード例 #6
0
ファイル: TestAstridDB.py プロジェクト: mmccarty/nell
    def test_dssCode2astridCode(self):

        adb = AstridDB(dbname = "turtle_sim", test = True)
        for i in range(len(self.pcodes)):
            self.assertEquals(self.acodes[i]
                            , adb.dssCode2astridCode(self.pcodes[i]))