diff --git a/test/a_file.file/meta.json b/test/a_file.file/meta.json index 1b6bd2d..fac4a8f 100644 --- a/test/a_file.file/meta.json +++ b/test/a_file.file/meta.json @@ -2,6 +2,6 @@ "type":"file", "title":"automatically uploaded file: ds150_course_logo.pdf", "filename":"ds150_course_logo.pdf", - "modules":["Automatically Added Test Module", "Another automatically added test module"], + "modules":["Automatically Added Test Module", "Another automatically added test module", "module created by file upload"], "destination": "automatically_uploaded_files/a_subfolder" } \ No newline at end of file diff --git a/test/test_file.py b/test/test_file.py index 0c8fd84..bc48ef4 100644 --- a/test/test_file.py +++ b/test/test_file.py @@ -4,6 +4,7 @@ import markdown2canvas as mc import pytest +import datetime @pytest.fixture(scope='class') def course(): @@ -16,12 +17,16 @@ def course(): yield canvas.get_course(test_course_id) @pytest.fixture(scope='class') -def content(course): +def content(): import os folder = 'a_file.file' yield mc.File(folder) +@pytest.fixture(scope='class') +def file(course): + yield course.get_files(search_term = 'ds150_course_logo.pdf')[0] + class TestFile(): @@ -33,9 +38,16 @@ def test_meta(self, content): def test_can_publish(self, course, content): content.publish(course,overwrite=True) assert content.is_already_uploaded(course) + + def test_in_modules(self,course,content): + content.publish(course,overwrite=True) for m in content.metadata['modules']: assert content.is_in_module(course, m) + module_test = course.get_modules(search_term = m)[0] + assert module_test.get_module_items(search_term = 'ds150')[0].title == 'automatically uploaded file: ds150_course_logo.pdf' + def test_in_folder(self,course,file): + assert file.folder_id == course.get_folders(search_term='a_subfolder')[0].id def test_already_online_raises(self, course, content): # publish once, forcefully. @@ -46,5 +58,14 @@ def test_already_online_raises(self, course, content): content.publish(course,overwrite=False) # default is False + def test_attributes(self, course, content, file): + content.publish(course,overwrite=True) + assert file.filename == 'ds150_course_logo.pdf' + assert file.modified_at_date.day == datetime.date.today().day + + + + +