Skip to content

Commit

Permalink
Merge pull request #19 from AugustH/new_calls2
Browse files Browse the repository at this point in the history
New Version
  • Loading branch information
AugustH committed Jul 14, 2018
2 parents 5eb5012 + fec91fb commit a8af9c4
Show file tree
Hide file tree
Showing 26 changed files with 2,057 additions and 300 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: python
python:
- '2.6'
- '2.7'
- 'pypy'
- 'pypy3'
- '3.3'
- '3.4'
- '3.5'
- '3.6'
- '3.7'
install:
- pip install tox coveralls
script:
Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2013-2016, Markus Unterwaditzer
Copyright (c) 2018, August Hörandl

Some rights reserved.

Expand Down
23 changes: 22 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
Changelog
=========

* work in progress:

* Dropped Python 2.6 support, added Python up to 3.7

* Code completion support for all objects

* Added str() and reps() for all objects for easier debugging

* Added new/missing API calls:

* last_import_time
* substitutions
* timegrid_units
* students
* exam_types
* exams
* timetable_with_absences
* class_reg_events

* Code cleanup

* 0.1.9:

* Add requests as a dependency and use it instead of urllib. Big security
Expand All @@ -19,7 +40,7 @@ Changelog
recognized, webuntis will now try to use the error message sent in the
response. See 67d6fa2_.

.. _67d6fa2: https://github.com/untitaker/python-webuntis/commit/67d6fa21f7c199d89704d07dbba5219b0875b75e
.. _67d6fa2: https://github.com/python-webuntis/python-webuntis/commit/67d6fa21f7c199d89704d07dbba5219b0875b75e

* 0.1.7:

Expand Down
4 changes: 2 additions & 2 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Initially i started writing this library with the goal to abstract away all the
pain that otherwise would result in direct interaction with the API. This is
still an unreached goal. Some things like the problem with time and date is
unsolvable. So if you think some part of the library could be easier to use,
`please let me know!
<https://github.com/untitaker/python-webuntis/issues/new>`_ I don't want
`please let us know!
<https://github.com/python-webuntis/python-webuntis/issues/new>`_ I don't want
python-webuntis to become as inconsistent and *weird* as the API it is
wrapping.

Expand Down
10 changes: 10 additions & 0 deletions docs/session.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@ Things you can do with the API
.. automethod:: statusdata
.. automethod:: subjects
.. automethod:: teachers
.. automethod:: statusdata
.. automethod:: last_import_time
.. automethod:: substitutions
.. automethod:: timegrid_units
.. automethod:: students
.. automethod:: exam_types
.. automethod:: exams
.. automethod:: timetable_with_absences
.. automethod:: class_reg_events

20 changes: 8 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
#!/usr/bin/env python
'''
"""
This file is part of python-webuntis
:copyright: (c) 2012 by Markus Unterwaditzer.
:license: BSD, see LICENSE for more details.
'''
"""

from setuptools import setup, find_packages
from sys import version_info

dependencies = ['requests']

if version_info < (2,6):
dependencies.append('simplejson')

if version_info < (2,7):
dependencies.append('ordereddict')

setup(
name='webuntis',
version='0.1.9',
version='0.1.10',
author='Markus Unterwaditzer',
author_email='markus@unterwaditzer.net',
packages=find_packages(),
include_package_data=True,
url='http://dev.unterwaditzer.net/python-webuntis/',
url='https://github.com/python-webuntis/python-webuntis',
license='new-style BSD',
description='Bindings for WebUntis API',
long_description=open('README.rst').read(),
Expand All @@ -35,10 +29,12 @@
'Operating System :: OS Independent',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: PyPy'
]
)
32 changes: 16 additions & 16 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'''
"""
This file is part of python-webuntis
:copyright: (c) 2012 by Markus Unterwaditzer.
:license: BSD, see LICENSE for more details.
'''

"""

import re
import unittest
Expand All @@ -18,6 +17,7 @@
from copy import deepcopy

try:
# noinspection PyCompatibility
from StringIO import StringIO as BytesIO # Python 2
except ImportError:
from io import BytesIO # Python 3
Expand All @@ -27,8 +27,8 @@


def get_json_resource(name):
with open(os.path.join(data_path, name)) as f:
return json.load(f)
with open(os.path.join(data_path, name)) as f:
return json.load(f)


class WebUntisTestCase(unittest.TestCase):
Expand All @@ -37,7 +37,7 @@ def cb(*args, **kwargs): # pragma: no cover
raise Exception('These are offline tests.')

self.request_patcher = patcher = \
mock.patch('webuntis.utils.remote._send_request', new=cb)
mock.patch('webuntis.utils.remote._send_request', new=cb)
patcher.start()

def tearDown(self):
Expand All @@ -47,15 +47,16 @@ def tearDown(self):
logging.warning(
'Failed to tear the request_patcher down properly.')

# noinspection PyMethodOverriding
def assertRaisesRegex(self, exc, regexp, callback, *a, **kw):
with pytest.raises(exc) as excinfo:
callback(*a, **kw)

assert re.search(regexp, repr(excinfo.value)), excinfo.value

def assert_strict_equal(self, x, *args):
'''Stricter version of assert_equal that doesn't do implicit conversion
between unicode and strings'''
"""Stricter version of assert_equal that doesn't do implicit conversion
between unicode and strings"""
for y in args:
self._assert_strict_equal_impl(x, y)

Expand All @@ -64,7 +65,7 @@ def _assert_strict_equal_impl(self, x, y):
return
assert x == y
assert issubclass(type(x), type(y)) or issubclass(type(y), type(x)), \
'%s != %s' % (type(x), type(y))
'%s != %s' % (type(x), type(y))
if isinstance(x, (bytes, str)) or x is None:
return
elif isinstance(x, dict) or isinstance(y, dict):
Expand All @@ -81,7 +82,6 @@ def _assert_strict_equal_impl(self, x, y):
assert repr(x) == repr(y), repr((x, y))[:200]



stub_session_parameters = {
'useragent': 'fooagent',
'school': 'fooschool',
Expand All @@ -98,7 +98,7 @@ def cb(*args, **kwargs): # pragma: no cover
raise Exception('These are offline tests.')

self.request_patcher = patcher = \
mock.patch('webuntis.utils.remote._send_request', new=cb)
mock.patch('webuntis.utils.remote._send_request', new=cb)
patcher.start()

self.session = webuntis.Session(**stub_session_parameters)
Expand All @@ -112,18 +112,18 @@ def tearDown(self):

self.session = None



def mock_results(methods, swallow_not_found=False):
'''Mock API methods more easily.
"""Mock API methods more easily.
:type methods: dict
:param methods: A dictionary containing one callable for each API method.
:type swallow_not_found: bool
:param swallow_not_found: Whether to return {'result': {}} on unmocked API
methods.
'''
"""

def new(url, jsondata, headers, http_session):
method = jsondata['method']
try:
Expand All @@ -148,8 +148,8 @@ def new(url, jsondata, headers, http_session):


def raw_vs_object(jsondata, result):
'''zip json data and results, but grouped by id instead of order. Also runs
some checks that hashes are unique.'''
"""zip json data and results, but grouped by id instead of order. Also runs
some checks that hashes are unique."""
raw_lookup = dict((x['id'], x) for x in jsondata)
known_hashes = set()

Expand Down

0 comments on commit a8af9c4

Please sign in to comment.