diff options
author | 2012-02-03 14:45:32 +0100 | |
---|---|---|
committer | 2012-02-03 14:46:54 +0100 | |
commit | f01bc94a33d8644da65b5fa895c222e9ee057b50 (patch) | |
tree | 3bfc837901a54f97a30f1d24431d8322906de192 /pygithub3/tests | |
parent | Pypi environment by setuptools (diff) | |
download | python-github3-f01bc94a33d8644da65b5fa895c222e9ee057b50.tar.xz python-github3-f01bc94a33d8644da65b5fa895c222e9ee057b50.zip |
Fix imports to new environment
Absolute imports as PEP8 tells
Diffstat (limited to 'pygithub3/tests')
-rw-r--r-- | pygithub3/tests/__init__.py | 0 | ||||
-rw-r--r-- | pygithub3/tests/test_errors.py | 36 |
2 files changed, 36 insertions, 0 deletions
diff --git a/pygithub3/tests/__init__.py b/pygithub3/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/pygithub3/tests/__init__.py diff --git a/pygithub3/tests/test_errors.py b/pygithub3/tests/test_errors.py new file mode 100644 index 0000000..36f33d9 --- /dev/null +++ b/pygithub3/tests/test_errors.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from unittest import TestCase +from requests.exceptions import HTTPError +from core import client +import errors +import json + +class TestErrorsWithoutAuth(TestCase): + """docstring for TestRequestsLibrary""" + + def setUp(self): + self.client = client.Client() + + def test_malformed_url(self): + self.assertRaises(HTTPError, self.client.request, 'get', 'fake') + +class TestErrorsAuthenticated(TestCase): + """docstring for TestErrorsAuthenticaed""" + + def setUp(self): + self.client = client.Client( + login='pygit', + password='pygithub3' + ) + + def test_400_parsing_json(self): + data = 'strinf' + self.assertRaises(errors.BadRequest, self.client.request, + 'post', 'user/repos', data=data) + + def test_400_json_hash(self): + data = json.dumps({'names': 'david'}) + with self.assertRaises(errors.UnprocessableEntity) as cm: + self.client.request('post', 'user/repos', data=data) |