@@ -0,0 +1,3228 @@
+# coding=utf-8%0Afrom __future__ import unicode_literals%0A%0Aimport simplemediawiki%0Aimport sys%0Aimport unittest%0Atry:%0A    import simplejson as json%0Aexcept ImportError:%0A    import json%0A%0Aif sys.version_info%5B0%5D == 3:%0A    import http.cookiejar as cookielib%0Aelif sys.version_info%5B0%5D == 2:%0A    import cookielib%0A%0AUNICODE_TEST = '%CE%BA%E1%BD%B9%CF%83%CE%BC%CE%B5'%0A%0A%0Aclass FetchHttpTest(unittest.TestCase):%0A    def setUp(self):%0A        self.user_agent = simplemediawiki.build_user_agent(%0A            'python-simplemediawiki test suite', simplemediawiki.__version__,%0A            'https://github.com/ianweller/python-simplemediawiki')%0A        self.mw = simplemediawiki.MediaWiki('https://httpbin.org/',%0A                                            user_agent=self.user_agent)%0A        self.data = None%0A%0A    def _do_post(self):%0A        self.data = json.loads(self.mw._fetch_http('https://httpbin.org/post',%0A                                                   %7B'butts': 'lol',%0A                                                    'unicode': UNICODE_TEST%7D))%0A%0A    def test_get(self):%0A        data = json.loads(self.mw._fetch_http('https://httpbin.org/get',%0A                                              %7B'butts': 'lol',%0A                                               'unicode': UNICODE_TEST%7D,%0A                                              force_get=True))%0A        assert data%5B'args'%5D%5B'format'%5D == 'json'%0A        assert data%5B'args'%5D%5B'unicode'%5D == UNICODE_TEST%0A%0A    def test_post(self):%0A        self._do_post()%0A        assert self.data is not None%0A        assert self.data%5B'form'%5D%5B'format'%5D == 'json'%0A        assert self.data%5B'form'%5D%5B'unicode'%5D == UNICODE_TEST%0A%0A    def test_user_agent(self):%0A        self._do_post()%0A        assert self.data%5B'headers'%5D%5B'User-Agent'%5D == self.user_agent%0A%0A    def test_gzip(self):%0A        data = json.loads(self.mw._fetch_http('https://httpbin.org/gzip', %7B%7D,%0A                                              force_get=True))%0A        assert data%5B'gzipped'%5D == True%0A%0A    def test_cookies(self):%0A        self.mw._fetch_http('https://httpbin.org/cookies/set',%0A                            %7B'unicode': UNICODE_TEST%7D,%0A                            force_get=True)%0A        data = json.loads(self.mw._fetch_http('https://httpbin.org/cookies', %7B%7D,%0A                                              force_get=True))%0A        assert 'unicode' in data%5B'cookies'%5D%0A        assert data%5B'cookies'%5D%5B'unicode'%5D == UNICODE_TEST%0A%0A    def test_persistent_cookiejar(self):%0A        cookiejar = cookielib.CookieJar()%0A        mw1 = simplemediawiki.MediaWiki('https://httpbin.org/',%0A                                        cookiejar=cookiejar,%0A                                        user_agent=self.user_agent)%0A        mw1._fetch_http('https://httpbin.org/cookies/set',%0A                        %7B'unicode': UNICODE_TEST%7D, force_get=True)%0A        mw2 = simplemediawiki.MediaWiki('https://httpbin.org/',%0A                                        cookiejar=cookiejar,%0A                                        user_agent=self.user_agent)%0A        data = json.loads(mw2._fetch_http('https://httpbin.org/cookies', %7B%7D,%0A                                          force_get=True))%0A        print(data)%0A        assert 'unicode' in data%5B'cookies'%5D%0A        assert data%5B'cookies'%5D%5B'unicode'%5D == UNICODE_TEST%0A

Add first test suite (in progress)