Beispiel #1
0
    def testLoad_2009_04_12(self):
        gamedayDirectory = GamedayDirectoryStructure(
            GamedayConfig.mlbGamedayApplicationURL, "mlb")

        gamedayGameURLs = gamedayDirectory.getGameURLsForDay(
            ("2009", "04", "12"))

        for gameURL in gamedayGameURLs:
            xmlProvider = GamedayXMLProvider(gameURL)

            gameStatsWorkList = GameStatsWorkList()

            gameLoader = GamedayGameLoader(self.db, xmlProvider,
                                           gameStatsWorkList)

            if gameLoader.isAlreadyLoaded():
                gameLoader.delete()

            logging.info("loading:" + xmlProvider.getGameName())

            gameLoader.loadGame()

            loaded = gameLoader.isAlreadyLoaded()

            self.assertTrue(loaded)

        logging.info("")
        logging.info("load complete!")
Beispiel #2
0
    def testLoad_2009_04_12(self):
        gamedayDirectory = GamedayDirectoryStructure(GamedayConfig.mlbGamedayApplicationURL, "mlb")

        gamedayGameURLs = gamedayDirectory.getGameURLsForDay(("2009", "04", "12"))

        for gameURL in gamedayGameURLs:
            xmlProvider = GamedayXMLProvider(gameURL)

            gameStatsWorkList = GameStatsWorkList()

            gameLoader = GamedayGameLoader(self.db, xmlProvider, gameStatsWorkList)

            if gameLoader.isAlreadyLoaded():
                gameLoader.delete()

            logging.info("loading:" + xmlProvider.getGameName())

            gameLoader.loadGame()

            loaded = gameLoader.isAlreadyLoaded()

            self.assertTrue(loaded)

        logging.info("")
        logging.info("load complete!")
Beispiel #3
0
    def setUp(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2008/month_09/day_24/gid_2008_09_24_pitmlb_milmlb_1/"
        
        xmlProvider = GamedayXMLProvider(url)
            
        hitXML = xmlProvider.getHitXML()

        doc = xml.dom.minidom.parseString(hitXML)
        
        self.elements = doc.getElementsByTagName('hip')
Beispiel #4
0
    def consume(self, item):
        gameURL = item

        xmlProvider = GamedayXMLProvider(gameURL)

        playerBioWorkList = PlayerBioWorkList()

        gameLoader = GamedayGameLoader(self.db, xmlProvider, playerBioWorkList)

        if not gameLoader.isAlreadyLoaded():
            logging.info("loading:" + xmlProvider.getGameName())

            gameLoader.loadGame()
Beispiel #5
0
 def consume(self, item):
     gameURL = item
     
     xmlProvider = GamedayXMLProvider(gameURL)
         
     playerBioWorkList = PlayerBioWorkList()
         
     gameLoader = GamedayGameLoader(self.db, xmlProvider, playerBioWorkList)
         
     if not gameLoader.isAlreadyLoaded():
         logging.info("loading:" + xmlProvider.getGameName())
             
         gameLoader.loadGame()
Beispiel #6
0
    def testGetInningXMLs_ExtraInnings(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_23/gid_2011_04_23_houmlb_milmlb_1/"

        self.xmlProvider = GamedayXMLProvider(url)

        inningXMLs = self.xmlProvider.getInningXMLs()

        self.assertEqual(10, len(inningXMLs))

        _10thInningXML = inningXMLs[9]

        found = str(_10thInningXML).find('inning num="10"')
        self.assertTrue(found > 0)
Beispiel #7
0
 def consume(self, item):
     gameURL = item
     
     xmlProvider = GamedayXMLProvider(gameURL)
     
     gameStatsWorkList = GameStatsWorkList()
     
     gameLoader = GamedayGameLoader(self.db, xmlProvider, gameStatsWorkList)
     
     if not gameLoader.isAlreadyLoaded():
         logging.info("loading:" + xmlProvider.getGameName())
         
         gameLoader.loadGame()
     else:
         logging.info("skipping previously loaded:" + xmlProvider.getGameName())
Beispiel #8
0
def main():

    options = commandLineOptionsParser.parseDeleteOptions()

    logging.info("Starting delete!")

    league = options.league

    gamedayDirectory = GamedayDirectoryStructure(BBOSConfig.gamedayURL, league)

    if not options.game:
        logging.error(
            "delete only accepts league and -g gameName as parameters")

    gamedayGameURLs = gamedayDirectory.getGameURLsForGame(options.game)

    xmlProvider = GamedayXMLProvider(gamedayGameURLs[0])

    db = DB()

    gameStatsWorkList = GameStatsWorkList()

    gameLoader = GamedayGameLoader(db, xmlProvider, gameStatsWorkList)

    gameLoader.delete()

    logging.info("")
    logging.info("delete complete!")
    def runAndStorePerformanceTest(self, gamedayGameURLs):
        beforeSeconds = time.time()
        
        for gameURL in gamedayGameURLs:
            xmlProvider = GamedayXMLProvider(gameURL)
        
            gameStatsWorkList = GameStatsWorkList()
        
            gameLoader = GamedayGameLoader(self.db, xmlProvider, gameStatsWorkList)
        
            gameLoader.delete()
        
            gameLoader.loadGame()
        
            gameLoader.delete()
        
        totalSeconds = time.time() - beforeSeconds
        timeHere = time.localtime()
        readableTime = time.asctime(timeHere)
        
        performanceTrackingFileContents = fileUtils.slurp(self.performanceFileName)
        
        performanceResult = "\n" + readableTime + "," + str(totalSeconds) + "," + str(len(gamedayGameURLs))
        
        performanceTrackingFileContents.append(performanceResult)
        
        fileUtils.spit(self.performanceFileName, performanceTrackingFileContents)
              

        
        
Beispiel #10
0
    def consume(self, item):
        gameURL = item

        xmlProvider = GamedayXMLProvider(gameURL)

        gameStatsWorkList = GameStatsWorkList()

        gameLoader = GamedayGameLoader(self.db, xmlProvider, gameStatsWorkList)

        if not gameLoader.isAlreadyLoaded():
            logging.info("loading:" + xmlProvider.getGameName())

            gameLoader.loadGame()
        else:
            logging.info("skipping previously loaded:" +
                         xmlProvider.getGameName())
Beispiel #11
0
    def test1Game(self):
        gamedayDirectory = GamedayDirectoryStructure(BBOSConfig.gamedayURL, "mlb")
    
        #gameName = "gid_2015_04_02_lanmlb_anamlb_1"
        gameName = "gid_2015_05_04_texmlb_houmlb_1"
        #gameName = "gid_2007_03_01_cinmlb_pitmlb_1"
        
        gamedayGameURLs = gamedayDirectory.getGameURLsForGame(gameName)
        
        for gameURL in gamedayGameURLs:
            logging.info( "gameURL:" + gameURL )
            xmlProvider = GamedayXMLProvider(gameURL)
            
            gameStatsWorkList = GameStatsWorkList()
            
            gameLoader = GamedayGameLoader(self.db, xmlProvider, gameStatsWorkList)
            
            if gameLoader.isAlreadyLoaded():
                gameLoader.delete()
            
            logging.info( "deleting:" + xmlProvider.getGameName() )
                
            gameLoader.delete()
            
            logging.info( "loading:" + xmlProvider.getGameName() )
                
            gameLoader.loadGame()
             
            loaded = gameLoader.isAlreadyLoaded();
            
            self.assertTrue(loaded)      
    
        logging.info( "" )
        logging.info( "load complete!" ) 
                   
    
           
              

        
        
    def testGetInningXMLs_ExtraInnings(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_23/gid_2011_04_23_houmlb_milmlb_1/"
        
        self.xmlProvider = GamedayXMLProvider(url)
        
        inningXMLs = self.xmlProvider.getInningXMLs()
        
        self.assertEqual(10, len(inningXMLs))

        _10thInningXML = inningXMLs[9]
        
        found = str(_10thInningXML).find('inning num="10"')
        self.assertTrue(found > 0)
    def testLoad(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2008/month_04/day_12/gid_2008_04_12_milmlb_nynmlb_1/"

        xmlProvider = GamedayXMLProvider(url)

        gameLoader = GamedayGameLoader(self.db, xmlProvider)

        gameLoader.delete()

        gameLoader.loadGame()

        loaded = gameLoader.isAlreadyLoaded()

        self.assertTrue(loaded)
Beispiel #14
0
    def testLoad2006(self):
        url = "http://gd2.mlb.com/components/game/mlb//year_2006/month_02/day_28/gid_2006_02_28_falbbc_slnmlb_1/"

        xmlProvider = GamedayXMLProvider(url)

        gameLoader = GamedayGameLoader(self.db, xmlProvider)

        gameLoader.delete()

        gameLoader.loadGame()

        loaded = gameLoader.isAlreadyLoaded()

        self.assertTrue(loaded)
Beispiel #15
0
    def testLoad2006_03_30sea(self):
        url = "http://gd2.mlb.com/components/game/mlb//year_2006/month_03/day_30/gid_2006_03_30_seamlb_sdnmlb_1/"

        xmlProvider = GamedayXMLProvider(url)

        gameLoader = GamedayGameLoader(self.db, xmlProvider)

        gameLoader.delete()

        gameLoader.loadGame()

        loaded = gameLoader.isAlreadyLoaded()

        self.assertTrue(loaded)
    def testLoad2009_09_25(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2009/month_09/day_25/gid_2009_09_25_balmlb_clemlb_1/"

        xmlProvider = GamedayXMLProvider(url)

        gameLoader = GamedayGameLoader(self.db, xmlProvider,
                                       self.gameStatsWorkList)

        gameLoader.delete()

        gameLoader.loadGame()

        loaded = gameLoader.isAlreadyLoaded()

        self.assertTrue(loaded)
    def testLoad04_02_2008(self):
        url = "http://gd2.mlb.com/components/game/mlb//year_2008/month_04/day_02/gid_2008_04_02_milmlb_chnmlb_1/"

        xmlProvider = GamedayXMLProvider(url)

        gameLoader = GamedayGameLoader(self.db, xmlProvider,
                                       self.gameStatsWorkList)

        gameLoader.delete()

        gameLoader.loadGame()

        loaded = gameLoader.isAlreadyLoaded()

        self.assertTrue(loaded)
    def testLoad10_16_2006(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2008/month_09/day_24/gid_2006_10_16_nynmlb_slnmlb_1/"

        xmlProvider = GamedayXMLProvider(url)

        gameLoader = GamedayGameLoader(self.db, xmlProvider,
                                       self.gameStatsWorkList)

        gameLoader.delete()

        gameLoader.loadGame()

        loaded = gameLoader.isAlreadyLoaded()

        self.assertTrue(loaded)
    def testLoad(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2006/month_06/day_08/gid_2006_06_08_tormlb_balmlb_1/"

        xmlProvider = GamedayXMLProvider(url)

        playerBioWorkList = PlayerBioWorkList()

        gameLoader = GamedayGameLoader(self.db, xmlProvider, playerBioWorkList)

        gameLoader.delete()

        gameLoader.loadGame()

        loaded = gameLoader.isAlreadyLoaded()

        self.assertTrue(loaded)
 def setUp(self):
     url = "http://gd2.mlb.com/components/game/mlb/year_2008/month_09/day_24/gid_2008_09_24_pitmlb_milmlb_1/"
     
     self.xmlProvider = GamedayXMLProvider(url)
Beispiel #21
0
class GameXMLProviderFTest(FTest):
    def setUp(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2008/month_09/day_24/gid_2008_09_24_pitmlb_milmlb_1/"

        self.xmlProvider = GamedayXMLProvider(url)

    def testGetHitXML(self):
        hitXML = self.xmlProvider.getHitXML()

        doc = xml.dom.minidom.parseString(hitXML)

        elements = doc.getElementsByTagName('hip')

        self.assertEqual(41, len(elements))

    def testGetInningXMLs(self):
        inningXMLs = self.xmlProvider.getInningXMLs()

        self.assertEqual(9, len(inningXMLs))

        firstInning = inningXMLs[0]

        doc = xml.dom.minidom.parseString(firstInning)

        top = doc.getElementsByTagName('top')
        firstAndOnlyTop = top[0]
        atbats = firstAndOnlyTop.getElementsByTagName('atbat')

        self.assertEqual(6, len(atbats))

    def testGetInningXMLs_ExtraInnings(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_23/gid_2011_04_23_houmlb_milmlb_1/"

        self.xmlProvider = GamedayXMLProvider(url)

        inningXMLs = self.xmlProvider.getInningXMLs()

        self.assertEqual(10, len(inningXMLs))

        _10thInningXML = inningXMLs[9]

        found = str(_10thInningXML).find('inning num="10"')
        self.assertTrue(found > 0)

    def testGetGameXML(self):
        xmlContent = self.xmlProvider.getGameXML()

        doc = xml.dom.minidom.parseString(xmlContent)

        elements = doc.getElementsByTagName('team')

        self.assertEqual(2, len(elements))

    def testGetPlayerXML(self):
        xmlContent = self.xmlProvider.getPlayerXML()

        doc = xml.dom.minidom.parseString(xmlContent)

        elements = doc.getElementsByTagName('team')

        self.assertEqual(2, len(elements))

    def testPlayerBIOXMLs(self):
        playerXMLs = self.xmlProvider.getPlayerBIOXMLs()

        self.assertEqual(83 + 42, len(playerXMLs))

        firstBIO = playerXMLs[0]

        doc = xml.dom.minidom.parseString(firstBIO)

        top = doc.getElementsByTagName('Player')
        firstAndOnlyPlayer = top[0]
        name = firstAndOnlyPlayer.getAttribute('first_name')

        self.assertEqual("Mike", name)

    def testGetGameName(self):
        gameName = self.xmlProvider.getGameName()

        self.assertEqual("gid_2008_09_24_pitmlb_milmlb_1", gameName)
Beispiel #22
0
    def setUp(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2008/month_09/day_24/gid_2008_09_24_pitmlb_milmlb_1/"

        self.xmlProvider = GamedayXMLProvider(url)
class GameXMLProviderFTest(FTest):
    
    def setUp(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2008/month_09/day_24/gid_2008_09_24_pitmlb_milmlb_1/"
        
        self.xmlProvider = GamedayXMLProvider(url)
            
    def testGetHitXML(self):
        hitXML = self.xmlProvider.getHitXML()

        doc = xml.dom.minidom.parseString(hitXML)
        
        elements = doc.getElementsByTagName('hip')
        
        self.assertEqual(41, len(elements))      
              
    def testGetInningXMLs(self):
        inningXMLs = self.xmlProvider.getInningXMLs()
        
        self.assertEqual(9, len(inningXMLs))

        firstInning = inningXMLs[0]
        
        doc = xml.dom.minidom.parseString(firstInning)
        
        top = doc.getElementsByTagName('top')
        firstAndOnlyTop = top[0]
        atbats = firstAndOnlyTop.getElementsByTagName('atbat')
        
        self.assertEqual(6, len(atbats)) 
               
    def testGetInningXMLs_ExtraInnings(self):
        url = "http://gd2.mlb.com/components/game/mlb/year_2011/month_04/day_23/gid_2011_04_23_houmlb_milmlb_1/"
        
        self.xmlProvider = GamedayXMLProvider(url)
        
        inningXMLs = self.xmlProvider.getInningXMLs()
        
        self.assertEqual(10, len(inningXMLs))

        _10thInningXML = inningXMLs[9]
        
        found = str(_10thInningXML).find('inning num="10"')
        self.assertTrue(found > 0)
               
    def testGetGameXML(self):
        xmlContent = self.xmlProvider.getGameXML()

        doc = xml.dom.minidom.parseString(xmlContent)
        
        elements = doc.getElementsByTagName('team')
        
        self.assertEqual(2, len(elements)) 
               
    def testGetPlayerXML(self):
        xmlContent = self.xmlProvider.getPlayerXML()

        doc = xml.dom.minidom.parseString(xmlContent)
        
        elements = doc.getElementsByTagName('team')
        
        self.assertEqual(2, len(elements))   
                     
    def testPlayerBIOXMLs(self):
        playerXMLs = self.xmlProvider.getPlayerBIOXMLs()
        
        self.assertEqual(83+42, len(playerXMLs))

        firstBIO = playerXMLs[0]
        
        doc = xml.dom.minidom.parseString(firstBIO)
        
        top = doc.getElementsByTagName('Player')
        firstAndOnlyPlayer = top[0]
        name = firstAndOnlyPlayer.getAttribute('first_name')
        
        self.assertEqual("Mike", name) 
               
    def testGetGameName(self):
        gameName = self.xmlProvider.getGameName()

        self.assertEqual("gid_2008_09_24_pitmlb_milmlb_1", gameName)