Exemplo n.º 1
0
    def test_history_format_latest(self):
        """Test channel history API call with latest timestamp longer than 6 decimals"""

        http_requests = setup_http_server()

        client = SlackClient('aaaa', max_items=5)

        # Call API
        _ = client.history('C011DUKE8', oldest=1, latest=1427135733.00006771)

        expected = {
            'channel': ['C011DUKE8'],
            'oldest': ['0.999990'],
            'latest': ['1427135733.000068'],
            'count': ['5']
        }

        self.assertEqual(len(http_requests), 1)

        req = http_requests[0]
        self.assertEqual(req.method, 'GET')
        self.assertRegex(req.path, '/channels.history')
        self.assertDictEqual(req.querystring, expected)
        self.assertIn((SlackClient.AUTHORIZATION_HEADER, 'Bearer aaaa'),
                      req.headers._headers)
Exemplo n.º 2
0
    def test_history(self):
        """Test channel history API call"""

        http_requests = setup_http_server()

        client = SlackClient('aaaa', max_items=5)

        # Call API
        _ = client.history('C011DUKE8',
                           oldest=1, latest=1427135733.000068)

        expected = {
            'channel': ['C011DUKE8'],
            'oldest': ['1'],
            'latest': ['1427135733.000068'],
            'token': ['aaaa'],
            'count': ['5']
        }

        self.assertEqual(len(http_requests), 1)

        req = http_requests[0]
        self.assertEqual(req.method, 'GET')
        self.assertRegex(req.path, '/channels.history')
        self.assertDictEqual(req.querystring, expected)
Exemplo n.º 3
0
    def test_slack_error(self):
        """Test if an exception is raised when an error is returned by the server"""

        setup_http_server()

        client = SlackClient('aaaa', max_items=5)

        with self.assertRaises(SlackClientError):
            _ = client.history('CH0')