-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_pre_process.py
More file actions
49 lines (39 loc) · 1.6 KB
/
test_pre_process.py
File metadata and controls
49 lines (39 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from pre_process import *
import os
import shutil
import pytest
import configparser
import logging
config = configparser.ConfigParser()
config.read(os.path.join(os.getcwd(), 'pytest.ini'))
download_all_assignments = (config['pre_process']['download_all_assignments'] == 'True')
is_travis = 'TRAVIS' in os.environ
class TestPreProcess(object):
def test_initialize_canvas(self):
edtech_course = initialize_canvas(26123)
assert edtech_course.name == 'CS6460: Educational Technology'
# @pytest.mark.skip(reason="just saving time")
def test_download_from_canvas(self):
path = os.path.join(os.getcwd(), '.pytest_cache', 'pdfs')
if os.path.exists(path):
shutil.rmtree(path)
os.makedirs(path)
edtech_course = initialize_canvas(26123)
origin = "Carlos Souza"
destination = path
download_from_canvas(origin, destination, edtech_course)
assert len(os.listdir(path)) > 0
@pytest.mark.skipif((not download_all_assignments) and (not is_travis),
reason="only to download all files (long process)")
def test_download_all_assignments(self):
path = os.path.join(os.getcwd(), 'pdfs')
if not os.path.exists(path):
os.makedirs(path)
edtech_course = initialize_canvas(26123)
origin = "Class Assignment Library"
destination = path
download_from_canvas(origin, destination, edtech_course)
assert len(os.listdir(path)) > 100
def test_train_model(self):
model = train_model(2)
assert type(model) is gensim.models.doc2vec.Doc2Vec