import pytest
import pprint


@pytest.mark.usefixture('client')
class TestClient(object):
    """ Tests the Client object. """

    def test_course(self, client):
        course_dict = {'id': 2}
        course = client.course(course_dict).get()
        pprint.pprint(vars(course))
        assert course.name is not None

    def test_module(self, client):
        module_dict = {'id': 1}
        module = client.module(module_dict).get()
        pprint.pprint(vars(module))
        assert module is not None

    def test_notification(self, client):
        notification_dict = {'id': 5}
        with pytest.raises(Exception):
            client.notification(notification_dict).get()

    def test_permission(self, client):
        permission_dict = {'id': 2}
        with pytest.raises(Exception):
            client.permission(permission_dict).get()

    def test_quiz(self, client):
        quiz_dict = {'id': 2}
        quiz = client.quiz(quiz_dict).get()
        assert quiz.module_id is not None

    def test_role(self, client):
        role_dict = {'id': 2}
        r = client.role(role_dict).get()
        assert r.name is not None

    # def test_test(self, client):import pytest
    #     test_dict = {'id': 2}
    #     t = client.test(test_dict).get()
    #     pprint.pprint(vars(t))
    #     assert t is not None

    def test_user(self, client):
        user_dict = {'shortname': 'tigris'}
        u = client.user(user_dict).get()
        pprint.pprint(u)
        assert u.id is not None 
