예제 #1
0
    def test_get_response(self):
        from smoketest.directives import CheckDirective
        from smoketest.settings import get_ca_path
        elem = {
            'url': 'http://www.usnews.com',
        }
        options = Mock()
        options.scheme = None
        options.port = '8999'
        options.level = 'sand14'
        options.cachebust = False
        options.dry_run = False
        directive = CheckDirective(elem, options)
        directive.session = Mock()

        url = 'http://www.usnews.com'
        extra_headers = {'a': 'b'}
        response = directive.get_response(url, extra_headers)
        directive.session.get.assert_called_once_with(
            url,
            verify=get_ca_path(),
            allow_redirects=False,
            timeout=directive.timeout,
            headers=extra_headers
        )
        self.assertEqual(response, directive.session.get.return_value)
예제 #2
0
    def test_run_for_platform(self):
        from smoketest.directives import CheckDirective

        platform = Mock()
        platform.headers = {'X-Test-Header': 'some-value'}
        elem = {
            'url': 'http://www.usnews.com',
        }
        options = Mock()
        options.scheme = None
        options.port = ''
        options.level = 'live'
        options.cachebust = False
        options.dry_run = False
        directive = CheckDirective(elem, options)
        directive.tests = []
        directive.get_response = MagicMock()
        directive._run_for_platform(platform)
        directive.get_response.assert_called_once_with(
            'http://www.usnews.com',
            platform.headers,
        )
예제 #3
0
 def test_run(self):
     from smoketest.directives import CheckDirective
     elem = {
         'url': 'http://www.usnews.com',
     }
     options = Mock()
     options.scheme = None
     options.port = '8999'
     options.level = 'sand14'
     options.cachebust = False
     options.dry_run = False
     directive = CheckDirective(elem, options)
     directive._run_for_platform = MagicMock()
     directive.platforms = [
         Mock(),
         Mock(),
     ]
     directive.run()
     directive._run_for_platform.assert_any_calls(
         directive.platforms[0],
     )
     directive._run_for_platform.assert_any_calls(
         directive.platforms[1],
     )