aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2021-02-12 00:11:43 +0100
committerNao Pross <np@0hm.ch>2021-02-12 00:11:43 +0100
commit6e079f88e556e2cd142ec372bafb26435e6c9fd1 (patch)
treeb64c11d0144d742845f075ae3f6db8dc46cb3f20 /test
parentBump up minimum required python version to 3.7 (diff)
downloadMuddle-6e079f88e556e2cd142ec372bafb26435e6c9fd1.tar.gz
Muddle-6e079f88e556e2cd142ec372bafb26435e6c9fd1.zip
Partially refractor muddle.moodle and add test
Diffstat (limited to '')
-rw-r--r--test/moodle.py25
1 files changed, 25 insertions, 0 deletions
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