|
0 |
diff --git a/lti_app/tests/remarks.txt b/lti_app/tests/remarks.txt
|
|
1 |
index e69de29..b5f210b 100644
|
|
2 |
--- a/lti_app/tests/remarks.txt
|
|
3 |
+++ b/lti_app/tests/remarks.txt
|
|
4 |
@@ -0,0 +1,29 @@
|
|
5 |
+Remarks:
|
|
6 |
+========
|
|
7 |
+
|
|
8 |
+Here are changes to use a local WIMS server, provided by an installed
|
|
9 |
+'wims' debian package.
|
|
10 |
+
|
|
11 |
+for a local wims service, let define WIMS_URL:
|
|
12 |
+----------------------------------------------
|
|
13 |
+
|
|
14 |
+export WIMS_URL=http://127.0.0.1/wims/wims.cgi
|
|
15 |
+
|
|
16 |
+also, to take in account a slow host, let's define:
|
|
17 |
+
|
|
18 |
+export WIMSAPI_TIMEOUT=30
|
|
19 |
+
|
|
20 |
+There must be a connection file named "myself":
|
|
21 |
+-----------------------------------------------
|
|
22 |
+
|
|
23 |
+On the wims' server side, there must be a file log/classes/.connections/myself
|
|
24 |
+with such lines:
|
|
25 |
+
|
|
26 |
+ident_site=127.0.0.1
|
|
27 |
+ident_protocol=http
|
|
28 |
+ident_agent=python-requests
|
|
29 |
+ident_password=toto
|
|
30 |
+ident_type=json
|
|
31 |
+ident_deny=
|
|
32 |
+
|
|
33 |
+There must be no class with number 60001 prior to running the test
|
|
34 |
diff --git a/lti_app/tests/test_views.py b/lti_app/tests/test_views.py
|
|
35 |
index 36fd6a1..d2cfab7 100644
|
|
36 |
--- a/lti_app/tests/test_views.py
|
|
37 |
+++ b/lti_app/tests/test_views.py
|
|
38 |
@@ -226,10 +226,9 @@ class WimsClassTestCase(TestCase):
|
|
39 |
request.POST = params
|
|
40 |
|
|
41 |
wims = WIMS.objects.create(url=WIMS_URL, name="WIMS UPEM",
|
|
42 |
- ident="wrong", passwd="wrong", rclass="myclass")
|
|
43 |
+ ident="myself", passwd="wrong", rclass="myclass")
|
|
44 |
LMS.objects.create(guid="elearning.upem.fr", url="https://elearning.u-pem.fr/",
|
|
45 |
name="Moodle UPEM", key=KEY, secret=SECRET)
|
|
46 |
-
|
|
47 |
r = views.wims_class(request, wims.pk)
|
|
48 |
self.assertContains(r, "Identification Failure : bad login/pwd", status_code=502)
|
|
49 |
|
|
50 |
@@ -268,7 +267,7 @@ class WimsClassTestCase(TestCase):
|
|
51 |
request.POST = params
|
|
52 |
|
|
53 |
wims = WIMS.objects.create(url="https://can.not.join.fr/", name="WIMS UPEM",
|
|
54 |
- ident="wrong", passwd="wrong", rclass="myclass")
|
|
55 |
+ ident="myself", passwd="wrong", rclass="myclass")
|
|
56 |
LMS.objects.create(guid="elearning.upem.fr", url="https://elearning.u-pem.fr/",
|
|
57 |
name="Moodle UPEM", key=KEY, secret=SECRET)
|
|
58 |
|
|
59 |
@@ -533,7 +532,7 @@ class WimsSheetTestCase(TestCase):
|
|
60 |
request.POST = params
|
|
61 |
|
|
62 |
wims = WIMS.objects.create(url=WIMS_URL, name="WIMS UPEM",
|
|
63 |
- ident="wrong", passwd="wrong", rclass="myclass")
|
|
64 |
+ ident="myself", passwd="wrong", rclass="myclass")
|
|
65 |
LMS.objects.create(guid="elearning.upem.fr", url="https://elearning.u-pem.fr/",
|
|
66 |
name="Moodle UPEM", key=KEY, secret=SECRET)
|
|
67 |
|
|
68 |
@@ -573,7 +572,7 @@ class WimsSheetTestCase(TestCase):
|
|
69 |
request.POST = params
|
|
70 |
|
|
71 |
wims = WIMS.objects.create(url="https://can.not.join.fr/", name="WIMS UPEM",
|
|
72 |
- ident="wrong", passwd="wrong", rclass="myclass")
|
|
73 |
+ ident="myself", passwd="wrong", rclass="myclass")
|
|
74 |
LMS.objects.create(guid="elearning.upem.fr", url="https://elearning.u-pem.fr/",
|
|
75 |
name="Moodle UPEM", key=KEY, secret=SECRET)
|
|
76 |
|
|
77 |
@@ -1031,7 +1030,7 @@ class WimsExamTestCase(TestCase):
|
|
78 |
request.POST = params
|
|
79 |
|
|
80 |
wims = WIMS.objects.create(url=WIMS_URL, name="WIMS UPEM",
|
|
81 |
- ident="wrong", passwd="wrong", rclass="myclass")
|
|
82 |
+ ident="myself", passwd="wrong", rclass="myclass")
|
|
83 |
LMS.objects.create(guid="elearning.upem.fr", url="https://elearning.u-pem.fr/",
|
|
84 |
name="Moodle UPEM", key=KEY, secret=SECRET)
|
|
85 |
|
|
86 |
@@ -1071,7 +1070,7 @@ class WimsExamTestCase(TestCase):
|
|
87 |
request.POST = params
|
|
88 |
|
|
89 |
wims = WIMS.objects.create(url="https://can.not.join.fr/", name="WIMS UPEM",
|
|
90 |
- ident="wrong", passwd="wrong", rclass="myclass")
|
|
91 |
+ ident="myself", passwd="wrong", rclass="myclass")
|
|
92 |
LMS.objects.create(guid="elearning.upem.fr", url="https://elearning.u-pem.fr/",
|
|
93 |
name="Moodle UPEM", key=KEY, secret=SECRET)
|
|
94 |
|
|
95 |
diff --git a/lti_app/tests/utils.py b/lti_app/tests/utils.py
|
|
96 |
index 3728056..5e7ccf2 100644
|
|
97 |
--- a/lti_app/tests/utils.py
|
|
98 |
+++ b/lti_app/tests/utils.py
|
|
99 |
@@ -47,16 +47,25 @@ def command(cmd):
|
|
100 |
def untar_archive():
|
|
101 |
"""Deploy the archive 'resources/6948902.tgz' into the WIMS class (assuming its running in a
|
|
102 |
container called 'wims') and return its qclass."""
|
|
103 |
+ import apt
|
|
104 |
archive = os.path.join(os.path.dirname(__file__), "resources/6948902.tgz")
|
|
105 |
- command("docker cp %s wims-minimal:/home/wims/log/classes/" % archive)
|
|
106 |
- command('docker exec wims-minimal bash -c '
|
|
107 |
- '"tar -xzf /home/wims/log/classes/6948902.tgz -C /home/wims/log/classes/"')
|
|
108 |
- command('docker exec wims-minimal bash -c "chmod 644 /home/wims/log/classes/6948902/.def"')
|
|
109 |
- command('docker exec wims-minimal bash -c "chown wims:wims /home/wims/log/classes/6948902 -R"')
|
|
110 |
- command('docker exec wims-minimal bash -c "rm /home/wims/log/classes/6948902.tgz"')
|
|
111 |
- command("docker exec wims-minimal bash -c "
|
|
112 |
- "\"echo ':6948902,20200626,Institution,test,en,0,H4,dmi,S S,+myself/myclass+,' "
|
|
113 |
- '>> /home/wims/log/classes/.index"')
|
|
114 |
+ if apt.Cache()["wims"].is_installed :
|
|
115 |
+ # The package wims is installed, let us use the legacy WIMS service
|
|
116 |
+ command(f'sudo -u wims -s /usr/bin/tar -xzf {archive} -C /var/lib/wims/log/classes/')
|
|
117 |
+ command('sudo -u wims -s /usr/bin/chmod 644 /var/lib/wims/log/classes/6948902/.def')
|
|
118 |
+ command('sudo -u wims -s /usr/bin/chown wims:wims /var/lib/wims/log/classes/6948902 -R')
|
|
119 |
+ command("""sudo -u wims -s /bin/bash -c "/usr/bin/echo ':6948902,20200626,Institution,test,en,0,H4,dmi,S S,+myself/myclass+,' >> /var/lib/wims/log/classes/.index" """)
|
|
120 |
+ else:
|
|
121 |
+ # No wims package installed, we shall use docker
|
|
122 |
+ command("docker cp %s wims-minimal:/home/wims/log/classes/" % archive)
|
|
123 |
+ command('docker exec wims-minimal bash -c '
|
|
124 |
+ '"tar -xzf /home/wims/log/classes/6948902.tgz -C /home/wims/log/classes/"')
|
|
125 |
+ command('docker exec wims-minimal bash -c "chmod 644 /home/wims/log/classes/6948902/.def"')
|
|
126 |
+ command('docker exec wims-minimal bash -c "chown wims:wims /home/wims/log/classes/6948902 -R"')
|
|
127 |
+ command('docker exec wims-minimal bash -c "rm /home/wims/log/classes/6948902.tgz"')
|
|
128 |
+ command("docker exec wims-minimal bash -c "
|
|
129 |
+ "\"echo ':6948902,20200626,Institution,test,en,0,H4,dmi,S S,+myself/myclass+,' "
|
|
130 |
+ '>> /home/wims/log/classes/.index"')
|
|
131 |
return 6948902
|
|
132 |
|
|
133 |
|