Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fdw-forks
django-database-files
Commits
8d21c83a
Commit
8d21c83a
authored
Aug 20, 2012
by
chris
Browse files
Added a unittest for hashing functions.
parent
090ade50
Changes
1
Hide whitespace changes
Inline
Side-by-side
database_files/tests/tests.py
View file @
8d21c83a
...
...
@@ -7,6 +7,7 @@ from django.core.files.storage import default_storage
from
database_files.models
import
File
from
database_files.tests.models
import
Thing
from
database_files
import
utils
DIR
=
os
.
path
.
abspath
(
os
.
path
.
split
(
__file__
)[
0
])
...
...
@@ -72,6 +73,18 @@ class DatabaseFilesTestCase(TestCase):
self
.
assertEqual
(
default_storage
.
exists
(
'i/special/test.txt'
),
False
)
self
.
assertEqual
(
os
.
path
.
isfile
(
fqfn
),
False
)
def
test_hash
(
self
):
media_dir
=
os
.
path
.
join
(
DIR
,
'media/i/special'
)
if
not
os
.
path
.
isdir
(
media_dir
):
os
.
makedirs
(
media_dir
)
fqfn
=
os
.
path
.
join
(
media_dir
,
'test.txt'
)
open
(
fqfn
,
'wb'
).
write
(
'hello
\n
many things are here
\n
and then this'
)
f_hash
=
utils
.
get_file_hash
(
fqfn
)
t_hash
=
utils
.
get_text_hash
(
open
(
fqfn
,
'rb'
).
read
())
print
f_hash
print
t_hash
self
.
assertEqual
(
f_hash
,
t_hash
)
class
DatabaseFilesViewTestCase
(
TestCase
):
fixtures
=
[
'test_data.json'
]
...
...
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