def test_getSweeperOptions(self): logger = MagicMock() opts = ['test', '-d'] sopts = getSweeperOptions(logger, opts) logger.toggleMask.assert_any_call(0b0001011) self.assertTrue(sopts.test(SweeperOptions.DEBUG_LOGGING)) opts = ['test', '-c'] sopts = getSweeperOptions(logger, opts) self.assertTrue(sopts.test(SweeperOptions.CURRENT_SEASON_ONLY)) opts = ['test', '-h'] exitFn = sys.exit exitCalled = False def mockExit(statusCode): nonlocal exitCalled exitCalled = True sys.exit = mockExit sopts = getSweeperOptions(logger, opts) self.assertTrue(exitCalled) opts = ['test', '-a', '1'] sopts = getSweeperOptions(logger, opts) self.assertTrue(sopts.test(SweeperOptions.ALGO)) self.assertEquals(sopts.algoId, 1) opts = ['test', '-a'] exitCalled = False sopts = getSweeperOptions(logger, opts) self.assertTrue(exitCalled) opts = ['test', '-l', 'league mnemonic TD'] sopts = getSweeperOptions(logger, opts) self.assertTrue(sopts.test(SweeperOptions.LEAGUE)) self.assertEquals(sopts.leagueMnemonic, 'league mnemonic TD') opts = ['test', '-l'] exitCalled = False sopts = getSweeperOptions(logger, opts) self.assertTrue(exitCalled) sys.exit = exitFn
in enumerate(sorted(tables.items(), key=lambda x : x[0])): collapsibleTheme = 'c' if fixturesTable.getHighlights() else 'b' groups += COLLAPSIBLE_GROUP.format(groupName=name, fixturesTable= \ addPriorities(modTable(fixturesTable.asHTML(fullyFormed=False))), \ formTable=modTable(formTable.asHTML(fullyFormed=False)), \ leagueTable=modTable(leagueTable.asHTML(fullyFormed=False)), groupId=groupId, collapsibleTheme=collapsibleTheme) html = HTML_HEAD + HTML_BODY.format(groups=groups) log.debug(html) with open('web/predictions.html', 'w') as f: f.write(html) if show: webbrowser.open(os.getcwd() + '/web/predictions.html') if __name__ == '__main__': from sweeper.utils import getSweeperOptions, SweeperOptions log = Logger() sopts = getSweeperOptions(log, sys.argv) if not sopts.test(SweeperOptions.ALGO): print('ERROR: No algo id provided, python createwebpage -h for help') sys.exit(1) league = sopts.leagueMnemonic if sopts.test(SweeperOptions.LEAGUE) else None date = sopts.date if sopts.test(SweeperOptions.DATE) else \ datetime.today().strftime('%Y-%m-%d') createWebPage(log, sopts.algoId, date, league, \ sopts.test(SweeperOptions.SHOW))