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
 
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
 _file = Application(
72
 _file = Application(
63
     label='Files',
73
     label='Files',
64
     slug='contents/file',
74
     slug='contents/file',
95
     markdownpluspage,
105
     markdownpluspage,
96
     _file,
106
     _file,
97
     thread,
107
     thread,
108
+    folder,
98
     calendar,
109
     calendar,
99
 ]
110
 ]

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

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

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

1
 # coding=utf-8
1
 # coding=utf-8
2
 from tracim_backend.tests import FunctionalTest
2
 from tracim_backend.tests import FunctionalTest
3
+from tracim_backend.models.applications import applications
3
 
4
 
4
 """
5
 """
5
 Tests for /api/v2/system subpath endpoints.
6
 Tests for /api/v2/system subpath endpoints.
24
         )
25
         )
25
         res = self.testapp.get('/api/v2/system/applications', status=200)
26
         res = self.testapp.get('/api/v2/system/applications', status=200)
26
         res = res.json_body
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
     def test_api__get_applications__err_401__unregistered_user(self):
37
     def test_api__get_applications__err_401__unregistered_user(self):
64
         """
38
         """