Fix day filter
[cds-indico.git] / indico / util / mimetypes_test.py
blobdd132c6c1289153eefac52b0b39f7476c976edd5
1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 import pytest
19 from indico.util.mimetypes import icon_from_mimetype
22 @pytest.mark.parametrize(('mimetype', 'expected_icon'), (
23 ('application/applixware', 'default_icon'),
24 ('application/atom+xml', 'icon-file-xml'),
25 ('application/cdmi-capability', 'default_icon'),
26 ('application/dssc+der', 'default_icon'),
27 ('application/ecmascript', 'default_icon'),
28 ('application/json', 'icon-file-css'),
29 ('application/msword', 'icon-file-word'),
30 ('application/pdf', 'icon-file-pdf'),
31 ('application/prs.cww', 'default_icon'),
32 ('application/relax-ng-compact-syntax', 'default_icon'),
33 ('application/resource-lists+xml', 'icon-file-xml'),
34 ('application/vnd.3gpp.pic-bw-large', 'default_icon'),
35 ('application/vnd.openofficeorg.extension', 'default_icon'),
36 ('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'icon-file-presentation'),
37 ('application/vnd.openxmlformats-officedocument.presentationml.slide', 'default_icon'),
38 ('application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'default_icon'),
39 ('application/vnd.openxmlformats-officedocument.presentationml.template', 'default_icon'),
40 ('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'icon-file-excel'),
41 ('application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'default_icon'),
42 ('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'icon-file-word'),
43 ('application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'default_icon'),
44 ('application/vnd.oasis.opendocument.chart', 'icon-file-openoffice'),
45 ('application/vnd.oasis.opendocument.chart', 'icon-file-openoffice'),
46 ('application/vnd.oasis.opendocument.chart-template', 'icon-file-openoffice'),
47 ('application/vnd.oasis.opendocument.database', 'icon-file-openoffice'),
48 ('application/vnd.oasis.opendocument.formula', 'icon-file-openoffice'),
49 ('application/vnd.oasis.opendocument.formula-template', 'icon-file-openoffice'),
50 ('application/vnd.oasis.opendocument.graphics', 'icon-file-openoffice'),
51 ('application/vnd.oasis.opendocument.graphics-template', 'icon-file-openoffice'),
52 ('application/vnd.oasis.opendocument.image', 'icon-file-openoffice'),
53 ('application/vnd.oasis.opendocument.image-template', 'icon-file-openoffice'),
54 ('application/vnd.oasis.opendocument.presentation', 'icon-file-openoffice'),
55 ('application/vnd.oasis.opendocument.presentation-template', 'icon-file-openoffice'),
56 ('application/vnd.oasis.opendocument.spreadsheet', 'icon-file-openoffice'),
57 ('application/vnd.oasis.opendocument.spreadsheet-template', 'icon-file-openoffice'),
58 ('application/vnd.oasis.opendocument.text', 'icon-file-openoffice'),
59 ('application/vnd.oasis.opendocument.text-master', 'icon-file-openoffice'),
60 ('application/vnd.oasis.opendocument.text-template', 'icon-file-openoffice'),
61 ('application/vnd.oasis.opendocument.text-web', 'icon-file-openoffice'),
62 ('application/vnd.ms-artgalry', 'default_icon'),
63 ('application/vnd.ms-cab-compressed', 'default_icon'),
64 ('application/vnd.ms-excel', 'icon-file-excel'),
65 ('application/vnd.ms-excel.addin.macroenabled.12', 'default_icon'),
66 ('application/vnd.ms-excel.sheet.binary.macroenabled.12', 'default_icon'),
67 ('application/vnd.ms-excel.sheet.macroenabled.12', 'default_icon'),
68 ('application/vnd.ms-excel.template.macroenabled.12', 'default_icon'),
69 ('application/vnd.ms-fontobject', 'default_icon'),
70 ('application/vnd.ms-htmlhelp', 'default_icon'),
71 ('application/vnd.ms-ims', 'default_icon'),
72 ('application/vnd.ms-lrm', 'default_icon'),
73 ('application/vnd.ms-officetheme', 'default_icon'),
74 ('application/vnd.ms-pki.seccat', 'default_icon'),
75 ('application/vnd.ms-pki.stl', 'default_icon'),
76 ('application/vnd.ms-powerpoint', 'icon-file-presentation'),
77 ('application/vnd.ms-powerpoint.addin.macroenabled.12', 'default_icon'),
78 ('application/vnd.ms-powerpoint.presentation.macroenabled.12', 'default_icon'),
79 ('application/vnd.ms-powerpoint.slide.macroenabled.12', 'default_icon'),
80 ('application/vnd.ms-powerpoint.slideshow.macroenabled.12', 'default_icon'),
81 ('application/vnd.ms-powerpoint.template.macroenabled.12', 'default_icon'),
82 ('application/vnd.ms-project', 'default_icon'),
83 ('application/vnd.ms-word.document.macroenabled.12', 'default_icon'),
84 ('application/vnd.ms-word.template.macroenabled.12', 'default_icon'),
85 ('application/vnd.ms-works', 'default_icon'),
86 ('application/vnd.ms-wpl', 'default_icon'),
87 ('application/vnd.ms-xpsdocument', 'default_icon'),
88 ('application/vnd.zzazz.deck+xml', 'icon-file-xml'),
89 ('application/x-7z-compressed', 'icon-file-zip'),
90 ('application/x-ace-compressed', 'icon-file-zip'),
91 ('application/x-bzip', 'icon-file-zip'),
92 ('application/x-bzip2', 'icon-file-zip'),
93 ('application/x-dtbncx+xml', 'icon-file-xml'),
94 ('application/xhtml+xml', 'icon-file-xml'),
95 ('application/xml', 'icon-file-xml'),
96 ('application/zip', 'icon-file-zip'),
97 ('audio/adpcm', 'icon-file-music'),
98 ('audio/basic', 'icon-file-music'),
99 ('audio/midi', 'icon-file-music'),
100 ('audio/mp4', 'icon-file-music'),
101 ('audio/mpeg', 'icon-file-music'),
102 ('audio/ogg', 'icon-file-music'),
103 ('audio/vnd.dece.audio', 'icon-file-music'),
104 ('audio/vnd.digital-winds', 'icon-file-music'),
105 ('audio/x-aac', 'icon-file-music'),
106 ('chemical/x-cdx', 'default_icon'),
107 ('image/bmp', 'icon-file-image'),
108 ('image/cgm', 'icon-file-image'),
109 ('image/g3fax', 'icon-file-image'),
110 ('image/gif', 'icon-file-image'),
111 ('image/ief', 'icon-file-image'),
112 ('image/jpeg', 'icon-file-image'),
113 ('image/ktx', 'icon-file-image'),
114 ('image/png', 'icon-file-image'),
115 ('image/prs.btif', 'icon-file-image'),
116 ('image/svg+xml', 'icon-file-image'),
117 ('image/tiff', 'icon-file-image'),
118 ('image/vnd.adobe.photoshop', 'icon-file-image'),
119 ('image/vnd.dece.graphic', 'icon-file-image'),
120 ('image/vnd.dvb.subtitle', 'icon-file-image'),
121 ('image/vnd.djvu', 'icon-file-image'),
122 ('image/vnd.dwg', 'icon-file-image'),
123 ('image/vnd.dxf', 'icon-file-image'),
124 ('image/vnd.fastbidsheet', 'icon-file-image'),
125 ('image/vnd.fpx', 'icon-file-image'),
126 ('image/vnd.fst', 'icon-file-image'),
127 ('image/vnd.fujixerox.edmics-mmr', 'icon-file-image'),
128 ('image/vnd.fujixerox.edmics-rlc', 'icon-file-image'),
129 ('image/vnd.ms-modi', 'icon-file-image'),
130 ('image/vnd.net-fpx', 'icon-file-image'),
131 ('image/vnd.wap.wbmp', 'icon-file-image'),
132 ('image/vnd.xiff', 'icon-file-image'),
133 ('image/webp', 'icon-file-image'),
134 ('image/x-cmu-raster', 'icon-file-image'),
135 ('image/x-cmx', 'icon-file-image'),
136 ('image/x-freehand', 'icon-file-image'),
137 ('image/x-icon', 'icon-file-image'),
138 ('image/x-pcx', 'icon-file-image'),
139 ('image/x-pict', 'icon-file-image'),
140 ('image/x-portable-anymap', 'icon-file-image'),
141 ('image/x-portable-bitmap', 'icon-file-image'),
142 ('image/x-portable-graymap', 'icon-file-image'),
143 ('image/x-portable-pixmap', 'icon-file-image'),
144 ('image/x-rgb', 'icon-file-image'),
145 ('image/x-xbitmap', 'icon-file-image'),
146 ('image/x-xpixmap', 'icon-file-image'),
147 ('image/x-xwindowdump', 'icon-file-image'),
148 ('text/calendar', 'icon-calendar'),
149 ('text/css', 'icon-file-css'),
150 ('text/csv', 'icon-file-spreadsheet'),
151 ('text/html', 'icon-file-xml'),
152 ('text/n3', 'icon-file-xml'),
153 ('text/plain', 'icon-file-text'),
154 ('text/plain-bas', 'icon-file-text'),
155 ('text/prs.lines.tag', 'icon-file-text'),
156 ('text/richtext', 'icon-file-text'),
157 ('text/sgml', 'icon-file-xml'),
158 ('text/tab-separated-values', 'icon-file-spreadsheet'),
159 ('video/h264', 'icon-file-video'),
160 ('video/jpeg', 'icon-file-video'),
161 ('video/jpm', 'icon-file-video'),
162 ('video/mj2', 'icon-file-video'),
163 ('video/mp4', 'icon-file-video'),
164 ('video/mpeg', 'icon-file-video'),
165 ('video/ogg', 'icon-file-video'),
166 ('video/quicktime', 'icon-file-video'),
167 ('video/vnd.dece.hd', 'icon-file-video'),
168 ('video/vnd.dece.mobile', 'icon-file-video'),
169 ('video/x-f4v', 'icon-file-video'),
170 ('video/x-fli', 'icon-file-video'),
171 ('video/x-flv', 'icon-file-video'),
172 ('video/x-m4v', 'icon-file-video'),
173 ('video/x-ms-asf', 'icon-file-video'),
174 ('video/x-ms-wm', 'icon-file-video'),
175 ('video/x-ms-wmv', 'icon-file-video'),
176 ('video/x-ms-wmx', 'icon-file-video'),
177 ('video/x-ms-wvx', 'icon-file-video'),
178 ('video/x-msvideo', 'icon-file-video'),
179 ('video/x-sgi-movie', 'icon-file-video'),
180 ('x-conference/x-cooltalk', 'default_icon')
182 def test_icon_from_mimetype(mimetype, expected_icon):
183 assert icon_from_mimetype(mimetype, default_icon='default_icon') == expected_icon
186 def test_icon_from_mimetype_case_insensitive():
187 assert icon_from_mimetype('IMAGE/gif', default_icon='default_icon') == 'icon-file-image'