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.')
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.')
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])
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)
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)
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)
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.")
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")
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')
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')
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])
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')