Browse Source

add folder app, update folder content_type, better tests for apps

Guénaël Muller 6 years ago
parent
commit
e4d797d499

+ 11 - 0
backend/tracim_backend/models/applications.py View File

@@ -59,6 +59,16 @@ thread = Application(
59 59
 
60 60
 )
61 61
 
62
+folder = Application(
63
+    label='Folder',
64
+    slug='contents/folder',
65
+    fa_icon='folder-open-o',
66
+    hexcolor='#252525',
67
+    is_active=True,
68
+    config={},
69
+    main_route='',
70
+)
71
+
62 72
 _file = Application(
63 73
     label='Files',
64 74
     slug='contents/file',
@@ -95,5 +105,6 @@ applications = [
95 105
     markdownpluspage,
96 106
     _file,
97 107
     thread,
108
+    folder,
98 109
     calendar,
99 110
 ]

+ 4 - 3
backend/tracim_backend/models/contents.py View File

@@ -6,6 +6,7 @@ from tracim_backend.exceptions import ContentTypeNotExist
6 6
 from tracim_backend.exceptions import ContentStatusNotExist
7 7
 from tracim_backend.models.applications import html_documents
8 8
 from tracim_backend.models.applications import _file
9
+from tracim_backend.models.applications import folder
9 10
 from tracim_backend.models.applications import thread
10 11
 from tracim_backend.models.applications import markdownpluspage
11 12
 
@@ -171,10 +172,10 @@ html_documents_type = ContentType(
171 172
 # TODO - G.M - 31-05-2018 - Set Better folder params
172 173
 folder_type = ContentType(
173 174
     slug='folder',
174
-    fa_icon=thread.fa_icon,
175
-    hexcolor=thread.hexcolor,
175
+    fa_icon=folder.fa_icon,
176
+    hexcolor=folder.hexcolor,
176 177
     label='Folder',
177
-    creation_label='Create collection of any documents',
178
+    creation_label='Create a folder',
178 179
     available_statuses=CONTENT_STATUS.allowed(),
179 180
 )
180 181
 

+ 9 - 35
backend/tracim_backend/tests/functional/test_system.py View File

@@ -1,5 +1,6 @@
1 1
 # coding=utf-8
2 2
 from tracim_backend.tests import FunctionalTest
3
+from tracim_backend.models.applications import applications
3 4
 
4 5
 """
5 6
 Tests for /api/v2/system subpath endpoints.
@@ -24,41 +25,14 @@ class TestApplicationEndpoint(FunctionalTest):
24 25
         )
25 26
         res = self.testapp.get('/api/v2/system/applications', status=200)
26 27
         res = res.json_body
27
-        application = res[0]
28
-        assert application['label'] == "Text Documents"
29
-        assert application['slug'] == 'contents/html-document'
30
-        assert application['fa_icon'] == 'file-text-o'
31
-        assert application['hexcolor'] == '#3f52e3'
32
-        assert application['is_active'] is True
33
-        assert 'config' in application
34
-        application = res[1]
35
-        assert application['label'] == "Markdown Plus Documents"
36
-        assert application['slug'] == 'contents/markdownpluspage'
37
-        assert application['fa_icon'] == 'file-code-o'
38
-        assert application['hexcolor'] == '#f12d2d'
39
-        assert application['is_active'] is True
40
-        assert 'config' in application
41
-        application = res[2]
42
-        assert application['label'] == "Files"
43
-        assert application['slug'] == 'contents/file'
44
-        assert application['fa_icon'] == 'paperclip'
45
-        assert application['hexcolor'] == '#FF9900'
46
-        assert application['is_active'] is True
47
-        assert 'config' in application
48
-        application = res[3]
49
-        assert application['label'] == "Threads"
50
-        assert application['slug'] == 'contents/thread'
51
-        assert application['fa_icon'] == 'comments-o'
52
-        assert application['hexcolor'] == '#ad4cf9'
53
-        assert application['is_active'] is True
54
-        assert 'config' in application
55
-        application = res[4]
56
-        assert application['label'] == "Calendar"
57
-        assert application['slug'] == 'calendar'
58
-        assert application['fa_icon'] == 'calendar'
59
-        assert application['hexcolor'] == '#757575'
60
-        assert application['is_active'] is True
61
-        assert 'config' in application
28
+        assert len(res) == len(applications)
29
+        for counter, application in enumerate(applications):
30
+            assert res[counter]['label'] == application.label
31
+            assert res[counter]['slug'] == application.slug
32
+            assert res[counter]['fa_icon'] == application.fa_icon
33
+            assert res[counter]['hexcolor'] == application.hexcolor
34
+            assert res[counter]['is_active'] == application.is_active
35
+            assert res[counter]['config'] == application.config
62 36
 
63 37
     def test_api__get_applications__err_401__unregistered_user(self):
64 38
         """