Ejemplo n.º 1
0
    def test_snarfuri(self):
        self.phenny.config.prefix = '.'
        self.phenny.config.linx_api_key = ""
        input = Mock(group=lambda x=0: 'http://google.com', sender='#phenny')
        snarfuri(self.phenny, input)

        self.phenny.msg.assert_called_once_with('#phenny', "[ Google ]")
Ejemplo n.º 2
0
    def test_snarfuri(self):
        self.phenny.config.prefix = '.'
        input = Mock(group=lambda x=0: 'http://google.com',
                sender='#phenny')
        snarfuri(self.phenny, input)

        self.phenny.msg.assert_called_once_with('#phenny', "[ Google ]")
Ejemplo n.º 3
0
    def test_snarfuri_405(self):
        self.phenny.config.prefix = '.'
        self.phenny.config.linx_api_key = ""
        input = Mock(group=lambda x=0: 'http://ozuma.sakura.ne.jp/httpstatus/405',
                sender='#phenny')
        snarfuri(self.phenny, input)

        self.assertEqual(self.phenny.msg.called, False)
Ejemplo n.º 4
0
 def test_snarfuri_405(self, mock_get, mock_head):
     mock_head.side_effect = HTTPError(response=MagicMock(status_code='405'))
     mock_get.side_effect = HTTPError(response=MagicMock(status_code='405'))
     self.input.group.return_value = 'http://405notallowed.com'
     head.snarfuri(self.phenny, self.input)
     mock_head.assert_called_once_with('http://405notallowed.com')
     self.assertEqual(mock_get.call_args[0][0], 'http://405notallowed.com')
     self.assertFalse(self.phenny.msg.called)
Ejemplo n.º 5
0
    def test_snarfuri_405(self):
        self.phenny.config.prefix = '.'
        self.phenny.config.linx_api_key = ""
        input = Mock(group=lambda x=0: 'http://ozuma.sakura.ne.jp/httpstatus/405',
                sender='#phenny')
        snarfuri(self.phenny, input)

        self.assertEqual(self.phenny.msg.called, False)
Ejemplo n.º 6
0
 def test_snarfuri_405(self, mock_get, mock_head):
     mock_head.side_effect = HTTPError(response=MagicMock(status_code='405'))
     mock_get.side_effect = HTTPError(response=MagicMock(status_code='405'))
     self.input.group.return_value = 'http://405notallowed.com'
     snarfuri(self.phenny, self.input)
     mock_head.assert_called_once_with('http://405notallowed.com')
     self.assertEqual(mock_get.call_args[0][0], 'http://405notallowed.com')
     self.assertFalse(self.phenny.msg.called)
Ejemplo n.º 7
0
 def test_snarfuri(self, mock_rget, mock_wget, mock_head):
     mock_head.return_value = {
         'status': '200',
         'content-type': 'text/html; charset=utf-8'
     }
     mock_wget.return_value = '<html><title>Some Page</title></html>'
     self.input.group.return_value = 'https://www.somepage.com'
     mock_rget.return_value.url = self.input.group.return_value
     snarfuri(self.phenny, self.input)
     mock_head.assert_called_once_with('https://www.somepage.com')
     mock_wget.assert_called_once_with('https://www.somepage.com')
     self.assertIn('Some Page', self.phenny.msg.call_args[0][1])
Ejemplo n.º 8
0
 def test_snarfuri(self, mock_wget, mock_head):
     mock_head.return_value = {
         'status': '200',
         'content-type': 'text/html; charset=utf-8'
     }
     mock_wget.return_value = '<html><title>Some Page</title></html>'
     self.input.group.return_value = 'https://www.somepage.com'
     self.assertFalse('https://www.somepage.com' in self.phenny.recent_titles)
     head.snarfuri(self.phenny, self.input)
     self.assertTrue('https://www.somepage.com' in self.phenny.recent_titles)
     mock_head.assert_called_once_with('https://www.somepage.com')
     mock_wget.assert_called_once_with('https://www.somepage.com')
     self.phenny.msg.assert_called_once_with(self.input.sender, '[ Some Page ]')
Ejemplo n.º 9
0
 def test_snarfuri(self, mock_wget, mock_head):
     mock_head.return_value = {
         'status': '200',
         'content-type': 'text/html; charset=utf-8'
     }
     mock_wget.return_value = '<html><title>Some Page</title></html>'
     self.input.group.return_value = 'https://www.somepage.com'
     self.assertFalse(
         'https://www.somepage.com' in self.phenny.recent_titles)
     head.snarfuri(self.phenny, self.input)
     self.assertTrue(
         'https://www.somepage.com' in self.phenny.recent_titles)
     mock_head.assert_called_once_with('https://www.somepage.com')
     mock_wget.assert_called_once_with('https://www.somepage.com')
     self.phenny.msg.assert_called_once_with(self.input.sender,
                                             '[ Some Page ]')