<commit_before>import unittest
from monkey import monkeypatch_requests
from tempodb import endpoint as p


class TestEndpoint(unittest.TestCase):
    def setUp(self):
        self.end = p.HTTPEndpoint('my_id', 'foo', 'bar',
                                  'http://www.nothing.com')
        monkeypatch_requests(self.end)

    def test_make_url_args_list(self):
        params = {'foo': [1, 'foo']}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=1&foo=foo')

    def test_make_url_args_tuple(self):
        params = {'foo': (1, 'foo')}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=1&foo=foo')

    def test_make_url_args_dict(self):
        params = {'foo': {'bar': 'baz',
                          'abc': 'def'}}
        ret = p.make_url_args(params)
        pass1 = 'foo%5Bbar%5D=baz' in ret
        pass2 = 'foo%5Babc%5D=def' in ret
        self.assertTrue(pass1)
        self.assertTrue(pass2)

    def test_make_url_args_bool_true(self):
        params = {'foo': True}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=true')

    def test_make_url_args_bool_false(self):
        params = {'foo': False}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=false')

    def test_make_url_args_bool_none(self):
        params = {'foo': None}
        ret = p.make_url_args(params)
        self.assertEquals(ret, '')

    def test_make_url_args_bool_bare_value_str(self):
        params = {'foo': 'bar'}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=bar')

    def test_make_url_args_bool_bare_value_non_str(self):
        params = {'foo': 2.0}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=2.0')

    def test_endpoint_constructor(self):
        self.assertEquals(self.end.base_url, 'http://www.nothing.com/')
        self.assertEquals(self.end.headers['User-Agent'],
                          'tempodb-python/%s' % '1.0.0')
        self.assertEquals(self.end.headers['Accept-Encoding'], 'gzip')
        self.assertTrue(hasattr(self.end, 'auth'))

    def test_endpoint_constructor_with_slash(self):
        self.end = p.HTTPEndpoint('my_id', 'foo', 'bar',
                                  'http://www.nothing.com/')
        self.assertEquals(self.end.base_url, 'http://www.nothing.com/')
        self.assertEquals(self.end.headers['User-Agent'],
                          'tempodb-python/%s' % '1.0.0')
        self.assertEquals(self.end.headers['Accept-Encoding'], 'gzip')
        self.assertTrue(hasattr(self.end, 'auth'))

    def test_endpoint_post(self):
        url = 'series/'
        body = 'foobar'
        self.end.pool.post.return_value = True
        self.end.post(url, body)
        self.end.pool.post.assert_called_once_with(
            'http://www.nothing.com/series/',
            data=body,
            auth=self.end.auth)

    def test_endpoint_get(self):
        url = 'series/'
        self.end.pool.get.return_value = True
        self.end.get(url)
        self.end.pool.get.assert_called_once_with(
            'http://www.nothing.com/series/',<commit_msg>bump tests to version 1.0.1<commit_after>import unittest
from monkey import monkeypatch_requests
from tempodb import endpoint as p


class TestEndpoint(unittest.TestCase):
    def setUp(self):
        self.end = p.HTTPEndpoint('my_id', 'foo', 'bar',
                                  'http://www.nothing.com')
        monkeypatch_requests(self.end)

    def test_make_url_args_list(self):
        params = {'foo': [1, 'foo']}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=1&foo=foo')

    def test_make_url_args_tuple(self):
        params = {'foo': (1, 'foo')}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=1&foo=foo')

    def test_make_url_args_dict(self):
        params = {'foo': {'bar': 'baz',
                          'abc': 'def'}}
        ret = p.make_url_args(params)
        pass1 = 'foo%5Bbar%5D=baz' in ret
        pass2 = 'foo%5Babc%5D=def' in ret
        self.assertTrue(pass1)
        self.assertTrue(pass2)

    def test_make_url_args_bool_true(self):
        params = {'foo': True}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=true')

    def test_make_url_args_bool_false(self):
        params = {'foo': False}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=false')

    def test_make_url_args_bool_none(self):
        params = {'foo': None}
        ret = p.make_url_args(params)
        self.assertEquals(ret, '')

    def test_make_url_args_bool_bare_value_str(self):
        params = {'foo': 'bar'}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=bar')

    def test_make_url_args_bool_bare_value_non_str(self):
        params = {'foo': 2.0}
        ret = p.make_url_args(params)
        self.assertEquals(ret, 'foo=2.0')

    def test_endpoint_constructor(self):
        self.assertEquals(self.end.base_url, 'http://www.nothing.com/')
        self.assertEquals(self.end.headers['User-Agent'],
                          'tempodb-python/%s' % '1.0.1')
        self.assertEquals(self.end.headers['Accept-Encoding'], 'gzip')
        self.assertTrue(hasattr(self.end, 'auth'))

    def test_endpoint_constructor_with_slash(self):
        self.end = p.HTTPEndpoint('my_id', 'foo', 'bar',
                                  'http://www.nothing.com/')
        self.assertEquals(self.end.base_url, 'http://www.nothing.com/')
        self.assertEquals(self.end.headers['User-Agent'],
                          'tempodb-python/%s' % '1.0.1')
        self.assertEquals(self.end.headers['Accept-Encoding'], 'gzip')
        self.assertTrue(hasattr(self.end, 'auth'))

    def test_endpoint_post(self):
        url = 'series/'
        body = 'foobar'
        self.end.pool.post.return_value = True
        self.end.post(url, body)
        self.end.pool.post.assert_called_once_with(
            'http://www.nothing.com/series/',
            data=body,
            auth=self.end.auth)

    def test_endpoint_get(self):
        url = 'series/'
        self.end.pool.get.return_value = True
        self.end.get(url)
        self.end.pool.get.assert_called_once_with(
            'http://www.nothing.com/series/',
{'fraction_non_alphanumeric': 0.1429025087329311, 'fraction_numerical': 0.007462686567164179, 'mean_word_length': 2.3630539241857984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 12, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6164268', 'n_tokens_mistral': 2133, 'n_tokens_neox': 2071, 'n_words': 315}