# Path: github2/request.py
# DEFAULT_GITHUB_URL = "https://github.com"
# LOGGER = logging.getLogger('github2.request')
# _HTTPLIB2_BUNDLE = path.realpath(path.dirname(httplib2.CA_CERTS))
# SYSTEM_CERTS = not _HTTPLIB2_BUNDLE.startswith(path.dirname(httplib2.__file__))
# CA_CERTS = None
# CURL_CERTS = False
#             CA_CERTS = cert_file
#             SYSTEM_CERTS = True
#         CA_CERTS = '/usr/local/share/certs/ca-root-nss.crt'
#         SYSTEM_CERTS = True
#     CA_CERTS = getenv('CURL_CA_BUNDLE')
#     CURL_CERTS = True
#     CA_CERTS = path.join(path.dirname(path.abspath(__file__)),
#                          "DigiCert_High_Assurance_EV_Root_CA.crt")
# def charset_from_headers(headers):
#     def __init__(self, message, content, code):
#     def __init__(self, username=None, api_token=None, url_prefix=None,
#                  requests_per_second=None, access_token=None,
#                  cache=None, proxy_host=None, proxy_port=None,
#                  github_url=None):
#     def encode_authentication_data(self, extra_post_data):
#     def get(self, *path_components):
#     def post(self, *path_components, **extra_post_data):
#     def put(self, *path_components, **extra_post_data):
#     def delete(self, *path_components, **extra_post_data):
#     def make_request(self, path, extra_post_data=None, method="GET"):
#     def raw_request(self, url, extra_post_data, method="GET"):
#     def http_headers(self):
# class GithubError(Exception):
# class HttpError(RuntimeError):
# class GithubRequest(object):


import unittest
    import unittest2
    from urllib.parse import parse_qs  # For Python 3
        from urlparse import parse_qs  # NOQA
        from cgi import parse_qs  # NOQA
    from nose.tools import (assert_dict_contains_subset, assert_dict_equal)
from github2 import request
class TestAuthEncode(unittest.TestCase):

    """Test processing of authentication data."""

    def setUp(self):
        self.r = request.GithubRequest()

    def test_unauthenticated(self):
        assert_params({}, self.r.encode_authentication_data({}))

    def test_access_token(self):
        try:
            self.r.access_token = 'hex string'
            assert_params({'access_token': ['hex string', ]},
                          self.r.encode_authentication_data({}))
        finally:
            self.r.access_token = None

    def test_user_token(self):
        try:
            self.r.username = 'user'
            self.r.api_token = 'hex string'
            token_params = {'login': ['user', ], 'token': ['hex string', ]}
            assert_params(token_params, self.r.encode_authentication_data({}))
        finally:
            self.r.username = self.r.api_token = None


class TestParameterEncoding(unittest.TestCase):
    def setUp(self):

# Path: github2/request.py
# DEFAULT_GITHUB_URL = "https://github.com"
# LOGGER = logging.getLogger('github2.request')
# _HTTPLIB2_BUNDLE = path.realpath(path.dirname(httplib2.CA_CERTS))
# SYSTEM_CERTS = not _HTTPLIB2_BUNDLE.startswith(path.dirname(httplib2.__file__))
# CA_CERTS = None
# CURL_CERTS = False
#             CA_CERTS = cert_file
#             SYSTEM_CERTS = True
#         CA_CERTS = '/usr/local/share/certs/ca-root-nss.crt'
#         SYSTEM_CERTS = True
#     CA_CERTS = getenv('CURL_CA_BUNDLE')
#     CURL_CERTS = True
#     CA_CERTS = path.join(path.dirname(path.abspath(__file__)),
#                          "DigiCert_High_Assurance_EV_Root_CA.crt")
# def charset_from_headers(headers):
#     def __init__(self, message, content, code):
#     def __init__(self, username=None, api_token=None, url_prefix=None,
#                  requests_per_second=None, access_token=None,
#                  cache=None, proxy_host=None, proxy_port=None,
#                  github_url=None):
#     def encode_authentication_data(self, extra_post_data):
#     def get(self, *path_components):
#     def post(self, *path_components, **extra_post_data):
#     def put(self, *path_components, **extra_post_data):
#     def delete(self, *path_components, **extra_post_data):
#     def make_request(self, path, extra_post_data=None, method="GET"):
#     def raw_request(self, url, extra_post_data, method="GET"):
#     def http_headers(self):
# class GithubError(Exception):
# class HttpError(RuntimeError):
# class GithubRequest(object):


# Path: tests/test_request.py
import unittest
    import unittest2
    from urllib.parse import parse_qs  # For Python 3
        from urlparse import parse_qs  # NOQA
        from cgi import parse_qs  # NOQA
    from nose.tools import (assert_dict_contains_subset, assert_dict_equal)
from github2 import request

class TestAuthEncode(unittest.TestCase):

    """Test processing of authentication data."""

    def setUp(self):
        self.r = request.GithubRequest()

    def test_unauthenticated(self):
        assert_params({}, self.r.encode_authentication_data({}))

    def test_access_token(self):
        try:
            self.r.access_token = 'hex string'
            assert_params({'access_token': ['hex string', ]},
                          self.r.encode_authentication_data({}))
        finally:
            self.r.access_token = None

    def test_user_token(self):
        try:
            self.r.username = 'user'
            self.r.api_token = 'hex string'
            token_params = {'login': ['user', ], 'token': ['hex string', ]}
            assert_params(token_params, self.r.encode_authentication_data({}))
        finally:
            self.r.username = self.r.api_token = None


class TestParameterEncoding(unittest.TestCase):
    def setUp(self):

        self.r = request.GithubRequest()