示例#1
0
 def setUp(self):
     # Allow the dependencies to be replaced so as not to affect unit tests in other test classes
     features.allowReplace = True
     features.Provide('FootballSeasonResultsParser',
                      MockFootballResultsParser)
     features.Provide('FootballRoundResultsParser',
                      MockFootballResultsParser)
     features.Provide('PrettyJson', lambda: mock_pretty_json_renderer)
示例#2
0
def get_application(test_case):
    global _application

    if _application is None:
        _application = Flask(__name__)
        _application.config['TESTING'] = True

        # The OS will pick the port that the application runs on.
        # This avoids two instances on the same machine trying to use the same port.
        _application.config['LIVESERVER_PORT'] = 0

        # A lambda expression is used to return the application instance to the requestor.
        # This is consistent with what has been implemented in ../app/wsgi.py.
        features.Provide('Application', lambda: _application)
        features.Provide('Api', Api, app=_application)
        features.Provide('SeasonResultsResource',
                         lambda: MockFootballSeasonResultsResource)
        features.Provide('SeasonResultsEndpoint', '/season')
        features.Provide('RoundResultsResource',
                         lambda: MockFootballRoundResultsResource)
        features.Provide('RoundResultsEndpoint', '/round/<round_number>')
        features.Provide('SystemStatus', MockSystemStatus,
                         _expected_url_to_check),
        features.Provide('RootResource', lambda: MockRootEndpointResource)
        features.Provide('RootEndpoint', '/')

    return _application
 def setUp(self):
     # Allow the dependencies to be replaced so as not to affect unit tests in other test classes
     features.allowReplace = True
     features.Provide('HttpRequest', MockHttpRequests)
     features.Provide('ApplicationInformation', MockApplicationInformation)
     features.Provide('HealthCheck',
                      MockHealthCheck,
                      app=self._application,
                      path='/testHealthCheck')
     features.Provide('EnvironmentDump',
                      MockEnvironmentDump,
                      app=self._application,
                      path='/testEnvironmentDump')
     features.Provide('ApplicationSectionName',
                      self._application_section_name)
示例#4
0
 def setUp(self):
     # Allow the dependencies to be replaced so as not to affect unit tests in other test classes
     features.allowReplace = True
     features.Provide('HttpRequest', MockHttpFootballRequests)
     features.Provide('HttpGetScoresForRoundUrlFormat', 'http://getresults.com?round={0}')
     features.Provide('HttpGetScoresForSeasonUrlFormat', _full_season_url)
     features.Provide('XpathGetTeams', '//div[@class="teamname"]/text()')
     features.Provide('XpathGetScores', '//div[@class="score"]/text()')
     features.Provide('XpathGetMatchTimes', '//div[@class="matchtime"]/text()')
     features.Provide('XpathGetVenues', '//div[@class="venuename"]/text()')
示例#5
0
# For health checking, the URL that gives all the results for the 2018 NPL Victoria season will be used
url_to_check = 'http://websites.sportstg.com/comp_info.cgi?a=ROUND&round=-1&client=0-10178-0-478257-0&pool=1'

# Attempt to get Github token from environment variables.
# If not found, set to empty string so that the environment dump endpoint does not fall over.
token_name = 'GITHUB_TOKEN'
token_value = ''

if token_name in os.environ:
    token_value = os.environ[token_name]

# Create Flask object for hosting the application.
# Note that a lambda expression is used for returning the application instance,
# otherwise classes such as FootballResultServer will not be able to use the object.
application = Flask('FootballResultsApi')
features.Provide('Application', lambda: application)

# Dependencies for parsing football results from a HTML page
features.Provide('HttpRequest', requests)
features.Provide(
    'HttpGetScoresForRoundUrlFormat',
    'http://websites.sportstg.com/comp_info.cgi?a=ROUND&round={0}&client=0-10178-0-478257-0&pool=1'
)
features.Provide(
    'HttpGetScoresForSeasonUrlFormat',
    'http://websites.sportstg.com/comp_info.cgi?a=ROUND&round=-1&client=0-10178-0-478257-0&pool=1'
)
features.Provide('XpathGetTeams', '//a[@class="teamnames"]/text()')
features.Provide('XpathGetScores', '//div[@class="big-score"]/text()')
features.Provide('XpathGetMatchTimes', '//div[@class="match-time"]/text()')
features.Provide('XpathGetVenues', '//a[@class="venuename"]/text()')