Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
e1f9b423
Commit
e1f9b423
authored
Oct 31, 2003
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for the OFS.content_types changes to support the "mime-types"
configuration setting
parent
fbe26e69
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
0 deletions
+86
-0
lib/python/OFS/tests/mime.types-1
lib/python/OFS/tests/mime.types-1
+5
-0
lib/python/OFS/tests/mime.types-2
lib/python/OFS/tests/mime.types-2
+5
-0
lib/python/OFS/tests/testContentTypes.py
lib/python/OFS/tests/testContentTypes.py
+75
-0
setup.py
setup.py
+1
-0
No files found.
lib/python/OFS/tests/mime.types-1
0 → 100644
View file @
e1f9b423
# This is a sample mime.types file.
# It contains a single bogus MIME type and extention for testing
# purposes. It is not loaded during normal Zope operation.
text/x-vnd.zope.test-mime-type-1 ztmt-1
lib/python/OFS/tests/mime.types-2
0 → 100644
View file @
e1f9b423
# This is a sample mime.types file.
# It contains a single bogus MIME type and extention for testing
# purposes. It is not loaded during normal Zope operation.
text/x-vnd.zope.test-mime-type-2 ztmt-2
lib/python/OFS/tests/testContentTypes.py
0 → 100644
View file @
e1f9b423
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Tests of the content_types extension mechanism.
$Id: testContentTypes.py,v 1.1 2003/10/31 16:40:09 fdrake Exp $
"""
import
mimetypes
import
os.path
import
sys
import
unittest
from
OFS
import
content_types
try
:
__file__
except
NameError
:
__file__
=
os
.
path
.
realpath
(
sys
.
argv
[
0
])
here
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
MIME_TYPES_1
=
os
.
path
.
join
(
here
,
"mime.types-1"
)
MIME_TYPES_2
=
MIME_TYPES_1
[:
-
1
]
+
"2"
class
ContentTypesTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
_old_state
=
mimetypes
.
__dict__
.
copy
()
def
tearDown
(
self
):
mimetypes
.
__dict__
.
update
(
self
.
_old_state
)
def
check_types_count
(
self
,
delta
):
self
.
assertEqual
(
len
(
mimetypes
.
types_map
),
len
(
self
.
_old_state
[
"types_map"
])
+
delta
)
def
test_add_one_file
(
self
):
ntypes
=
len
(
mimetypes
.
types_map
)
content_types
.
add_files
([
MIME_TYPES_1
])
ctype
,
encoding
=
content_types
.
guess_content_type
(
"foo.ztmt-1"
)
self
.
assert_
(
encoding
is
None
)
self
.
assertEqual
(
ctype
,
"text/x-vnd.zope.test-mime-type-1"
)
ctype
,
encoding
=
content_types
.
guess_content_type
(
"foo.ztmt-1.gz"
)
self
.
assertEqual
(
encoding
,
"gzip"
)
self
.
assertEqual
(
ctype
,
"text/x-vnd.zope.test-mime-type-1"
)
self
.
check_types_count
(
1
)
def
test_add_two_files
(
self
):
ntypes
=
len
(
mimetypes
.
types_map
)
content_types
.
add_files
([
MIME_TYPES_1
,
MIME_TYPES_2
])
ctype
,
encoding
=
content_types
.
guess_content_type
(
"foo.ztmt-1"
)
self
.
assert_
(
encoding
is
None
)
self
.
assertEqual
(
ctype
,
"text/x-vnd.zope.test-mime-type-1"
)
ctype
,
encoding
=
content_types
.
guess_content_type
(
"foo.ztmt-2"
)
self
.
assert_
(
encoding
is
None
)
self
.
assertEqual
(
ctype
,
"text/x-vnd.zope.test-mime-type-2"
)
self
.
check_types_count
(
2
)
def
test_suite
():
return
unittest
.
makeSuite
(
ContentTypesTestCase
)
if
__name__
==
'__main__'
:
unittest
.
main
()
setup.py
View file @
e1f9b423
...
...
@@ -394,6 +394,7 @@ setup(
packages
=
[
'OFS'
,
'OFS.tests'
],
data_files
=
[[
'OFS'
,
[
'OFS/mime.types'
]],
[
'OFS/tests'
,
[
'OFS/tests/mime.types-?'
]],
[
'OFS/dtml'
,
[
'OFS/dtml/*'
]],
[
'OFS/standard'
,
[
'OFS/standard/*'
]],
[
'OFS/www'
,
[
'OFS/www/*'
]]],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment