コード例 #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 ]")
コード例 #2
0
ファイル: test_head.py プロジェクト: downquark/phenny
    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 ]")
コード例 #3
0
ファイル: test_head.py プロジェクト: andreimarcu/phenny
    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)
コード例 #4
0
ファイル: test_head.py プロジェクト: goavki/phenny
 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)
コード例 #5
0
ファイル: test_head.py プロジェクト: vtluug/phenny
    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)
コード例 #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)
コード例 #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])
コード例 #8
0
ファイル: test_head.py プロジェクト: goavki/phenny
 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 ]')
コード例 #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 ]')