From 6e079f88e556e2cd142ec372bafb26435e6c9fd1 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 12 Feb 2021 00:11:43 +0100 Subject: Partially refractor muddle.moodle and add test --- test/moodle.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/moodle.py (limited to 'test') diff --git a/test/moodle.py b/test/moodle.py new file mode 100644 index 0000000..3669ef8 --- /dev/null +++ b/test/moodle.py @@ -0,0 +1,25 @@ +import pytest + +import pathlib +import configparser + +from muddle import paths +from muddle import moodle + +config_file = pathlib.Path(paths.default_config_file) +if not config_file.is_file(): + log.error(f"cannot read {config_file}") + sys.exit(1) + +config = configparser.ConfigParser() +config.read(config_file) + + +class TestMoodleInstance: + server = moodle.MoodleInstance(config["server"]["url"], config["server"]["token"]) + + def test_get_userid(self): + assert self.server.get_userid() != None + + def test_get_enrolled_courses(self): + assert type(next(self.server.get_enrolled_courses())) == moodle.Course -- cgit v1.2.1