@@ -48,11 +48,12 @@ def test_get_single_data(self):
4848 "platform" : platform_id ,
4949 "name" : "mediaWiki" ,
5050 "metadata" : {
51- "namespaces " : [ 0 , 1 , 2 ] ,
51+ "activated " : True ,
5252 },
5353 }
5454 ]
5555 },
56+ "activated" : True ,
5657 }
5758 )
5859
@@ -85,18 +86,19 @@ def test_get_mediawiki_communities_data_multiple_platforms(self):
8586 "platform" : platform_id1 ,
8687 "name" : "mediaWiki" ,
8788 "metadata" : {
88- "namespaces " : [ 0 , 1 , 2 ] ,
89+ "activated " : True ,
8990 },
9091 },
9192 {
9293 "platform" : platform_id2 ,
9394 "name" : "mediaWiki" ,
9495 "metadata" : {
95- "namespaces " : [ 3 , 4 , 5 ] ,
96+ "activated " : True ,
9697 },
9798 },
9899 ]
99100 },
101+ "activated" : True ,
100102 }
101103 )
102104
@@ -107,6 +109,7 @@ def test_get_mediawiki_communities_data_multiple_platforms(self):
107109 "metadata" : {
108110 "baseURL" : "http://example1.com" ,
109111 "path" : "/api" ,
112+ "namespaces" : [0 , 1 , 2 ],
110113 },
111114 "community" : community_id ,
112115 "disconnectedAt" : None ,
@@ -123,6 +126,7 @@ def test_get_mediawiki_communities_data_multiple_platforms(self):
123126 "metadata" : {
124127 "baseURL" : "http://example2.com" ,
125128 "path" : "/api" ,
129+ "namespaces" : [3 , 4 , 5 ],
126130 },
127131 "community" : community_id ,
128132 "disconnectedAt" : None ,
@@ -171,18 +175,19 @@ def test_get_mediawiki_communities_data_filtered_platforms(self):
171175 "platform" : platform_id1 ,
172176 "name" : "mediaWiki" ,
173177 "metadata" : {
174- "namespaces " : [ 0 , 1 , 2 ] ,
178+ "activated " : True ,
175179 },
176180 },
177181 {
178182 "platform" : platform_id2 ,
179183 "name" : "mediaWiki" ,
180184 "metadata" : {
181- "namespaces " : [ 3 , 4 , 5 ] ,
185+ "activated " : True ,
182186 },
183187 },
184188 ]
185189 },
190+ "activated" : True ,
186191 }
187192 )
188193
@@ -193,6 +198,7 @@ def test_get_mediawiki_communities_data_filtered_platforms(self):
193198 "metadata" : {
194199 "baseURL" : "http://example1.com" ,
195200 "path" : "/api" ,
201+ "namespaces" : [0 , 1 , 2 ],
196202 },
197203 "community" : community_id ,
198204 "disconnectedAt" : None ,
@@ -209,6 +215,7 @@ def test_get_mediawiki_communities_data_filtered_platforms(self):
209215 "metadata" : {
210216 "baseURL" : "http://example2.com" ,
211217 "path" : "/api" ,
218+ "namespaces" : [3 , 4 , 5 ],
212219 },
213220 "community" : community_id ,
214221 "disconnectedAt" : None ,
@@ -232,3 +239,84 @@ def test_get_mediawiki_communities_data_filtered_platforms(self):
232239 "base_url" : "http://example1.com/api" ,
233240 },
234241 )
242+
243+ def test_get_mediawiki_communities_data_filtered_platforms_not_activated (self ):
244+ """
245+ Two mediawiki platforms for one community
246+ """
247+ platform_id1 = ObjectId ("6579c364f1120850414e0dc6" )
248+ platform_id2 = ObjectId ("6579c364f1120850414e0dc7" )
249+ community_id = ObjectId ("1009c364f1120850414e0dc5" )
250+
251+ self .client ["Core" ]["modules" ].insert_one (
252+ {
253+ "name" : "hivemind" ,
254+ "community" : community_id ,
255+ "options" : {
256+ "platforms" : [
257+ {
258+ "platform" : platform_id1 ,
259+ "name" : "mediaWiki" ,
260+ "metadata" : {
261+ "activated" : False ,
262+ },
263+ },
264+ {
265+ "platform" : platform_id2 ,
266+ "name" : "mediaWiki" ,
267+ "metadata" : {
268+ "activated" : True ,
269+ },
270+ },
271+ ]
272+ },
273+ "activated" : True ,
274+ }
275+ )
276+
277+ self .client ["Core" ]["platforms" ].insert_one (
278+ {
279+ "_id" : platform_id1 ,
280+ "name" : "mediaWiki" ,
281+ "metadata" : {
282+ "baseURL" : "http://example1.com" ,
283+ "path" : "/api" ,
284+ "namespaces" : [0 , 1 , 2 ],
285+ },
286+ "community" : community_id ,
287+ "disconnectedAt" : None ,
288+ "connectedAt" : datetime .now (),
289+ "createdAt" : datetime .now (),
290+ "updatedAt" : datetime .now (),
291+ }
292+ )
293+
294+ self .client ["Core" ]["platforms" ].insert_one (
295+ {
296+ "_id" : platform_id2 ,
297+ "name" : "mediaWiki" ,
298+ "metadata" : {
299+ "baseURL" : "http://example2.com" ,
300+ "path" : "/api" ,
301+ "namespaces" : [3 , 4 , 5 ],
302+ },
303+ "community" : community_id ,
304+ "disconnectedAt" : None ,
305+ "connectedAt" : datetime .now (),
306+ "createdAt" : datetime .now (),
307+ "updatedAt" : datetime .now (),
308+ }
309+ )
310+
311+ result = self .modules_mediawiki .get_learning_platforms ()
312+
313+ self .assertIsInstance (result , list )
314+ self .assertEqual (len (result ), 1 )
315+ self .assertEqual (
316+ result [0 ],
317+ {
318+ "community_id" : str (community_id ),
319+ "namespaces" : [3 , 4 , 5 ],
320+ "base_url" : "http://example2.com/api" ,
321+ },
322+ )
0 commit comments