コード例 #1
0
ファイル: test_head.py プロジェクト: goavki/phenny
 def test_header_bad(self, mock_head):
     self.input.group.return_value = 'https://vtluug.org truncatedcone'
     mock_head.return_value = {'server': 'HTTPlikeapro'}
     head.head(self.phenny, self.input)
     mock_head.assert_called_once_with('https://vtluug.org')
     self.phenny.say.assert_called_once_with('There was no truncatedcone '
         'header in the response.')
コード例 #2
0
 def test_header_bad(self, mock_head):
     self.input.group.return_value = 'https://vtluug.org truncatedcone'
     mock_head.return_value = {'server': 'HTTPlikeapro'}
     head(self.phenny, self.input)
     mock_head.assert_called_once_with('https://vtluug.org')
     self.phenny.say.assert_called_once_with('There was no truncatedcone '
         'header in the response.')
コード例 #3
0
 def test_head_404(self, mock_head):
     self.input.group.return_value = 'https://vtluug.org/trigger_404'
     mock_head.side_effect = HTTPError(response=MagicMock(
         status_code='404'))
     head.head(self.phenny, self.input)
     mock_head.assert_called_once_with('https://vtluug.org/trigger_404')
     self.assertIn('404', self.phenny.say.call_args[0][0])
コード例 #4
0
ファイル: test_head.py プロジェクト: andreimarcu/phenny
    def test_head(self):
        input = Mock(group=lambda x: 'http://vtluug.org')
        head(self.phenny, input)

        out = self.phenny.reply.call_args[0][0]
        m = re.match('^200, text/html, utf-8, \d{4}\-\d{2}\-\d{2} '\
                '\d{2}:\d{2}:\d{2} UTC, [0-9\.]+ s$', out, flags=re.UNICODE)
        self.assertTrue(m)
コード例 #5
0
    def test_head(self):
        input = Mock(group=lambda x: 'http://vtluug.org')
        head(self.phenny, input)

        out = self.phenny.reply.call_args[0][0]
        m = re.match('^200, text/html, utf-8, \d{4}\-\d{2}\-\d{2} '\
                '\d{2}:\d{2}:\d{2} UTC, [0-9\.]+ s$', out, flags=re.UNICODE)
        self.assertTrue(m)
コード例 #6
0
ファイル: test_head.py プロジェクト: goavki/phenny
    def test_head(self, mock_head):
        self.input.group.return_value = 'https://vtluug.org'
        mock_head.return_value = {
            'Status': '200',
            'content-type': 'text/html; charset=utf-8',
            'last-modified': 'Thu, 29 Dec 2016 22:49:19 GMT',
            'content-length': '1000'
        }
        head.head(self.phenny, self.input)

        mock_head.assert_called_once_with('https://vtluug.org')
        out = self.phenny.reply.call_args[0][0]
        m = re.match('^200, text/html, utf-8, \d{4}\-\d{2}\-\d{2} '\
                '\d{2}:\d{2}:\d{2} UTC, 1000 bytes, [0-9\.]+ s$', out, flags=re.UNICODE)
        self.assertTrue(m)
コード例 #7
0
    def test_head(self, mock_head):
        self.input.group.return_value = 'https://vtluug.org'
        mock_head.return_value = {
            'Status': '200',
            'content-type': 'text/html; charset=utf-8',
            'last-modified': 'Thu, 29 Dec 2016 22:49:19 GMT',
            'content-length': '1000'
        }
        head(self.phenny, self.input)

        mock_head.assert_called_once_with('https://vtluug.org')
        out = self.phenny.reply.call_args[0][0]
        m = re.match('^200, text/html, utf-8, \d{4}\-\d{2}\-\d{2} '\
                '\d{2}:\d{2}:\d{2} UTC, 1000 bytes, [0-9\.]+ s$', out, flags=re.UNICODE)
        self.assertTrue(m)
コード例 #8
0
ファイル: test_head.py プロジェクト: andreimarcu/phenny
    def test_header_bad(self):
        input = Mock(group=lambda x: 'http://vtluug.org truncatedcone')
        head(self.phenny, input)

        self.phenny.say.assert_called_once_with("There was no truncatedcone "\
                "header in the response.")
コード例 #9
0
ファイル: test_head.py プロジェクト: andreimarcu/phenny
    def test_header(self):
        input = Mock(group=lambda x: 'http://vtluug.org Server')
        head(self.phenny, input)

        self.phenny.say.assert_called_once_with("Server: nginx")
コード例 #10
0
ファイル: test_head.py プロジェクト: andreimarcu/phenny
    def test_head_404(self):
        input = Mock(group=lambda x: 'http://vtluug.org/trigger_404')
        head(self.phenny, input)

        out = self.phenny.say.call_args[0][0]
        self.assertEqual(out, '404')
コード例 #11
0
    def test_header_bad(self):
        input = Mock(group=lambda x: 'http://vtluug.org truncatedcone')
        head(self.phenny, input)

        self.phenny.say.assert_called_once_with("There was no truncatedcone "\
                "header in the response.")
コード例 #12
0
    def test_header(self):
        input = Mock(group=lambda x: 'http://vtluug.org Server')
        head(self.phenny, input)

        self.phenny.say.assert_called_once_with("Server: nginx")
コード例 #13
0
    def test_head_404(self):
        input = Mock(group=lambda x: 'http://vtluug.org/trigger_404')
        head(self.phenny, input)

        out = self.phenny.say.call_args[0][0]
        self.assertEqual(out, '404')
コード例 #14
0
ファイル: test_head.py プロジェクト: goavki/phenny
 def test_header(self, mock_head):
     self.input.group.return_value = 'https://vtluug.org Server'
     mock_head.return_value = {'server': 'HTTPlikeapro'}
     head.head(self.phenny, self.input)
     mock_head.assert_called_once_with('https://vtluug.org')
     self.phenny.say.assert_called_once_with('Server: HTTPlikeapro')
コード例 #15
0
ファイル: test_head.py プロジェクト: goavki/phenny
 def test_head_404(self, mock_head):
     self.input.group.return_value = 'https://vtluug.org/trigger_404'
     mock_head.side_effect = HTTPError(response=MagicMock(status_code='404'))
     head.head(self.phenny, self.input)
     mock_head.assert_called_once_with('https://vtluug.org/trigger_404')
     self.assertIn('404', self.phenny.say.call_args[0][0])
コード例 #16
0
 def test_header(self, mock_head):
     self.input.group.return_value = 'https://vtluug.org Server'
     mock_head.return_value = {'server': 'HTTPlikeapro'}
     head(self.phenny, self.input)
     mock_head.assert_called_once_with('https://vtluug.org')
     self.phenny.say.assert_called_once_with('Server: HTTPlikeapro')