Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mat2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Romain
mat2
Commits
fc924239
Commit
fc924239
authored
5 years ago
by
Julien (jvoisin) Voisin
Browse files
Options
Downloads
Patches
Plain Diff
Add a test for nsid cleaning
parent
0170f0e3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+3
-0
3 additions, 0 deletions
README.md
tests/data/dirty_with_nsid.docx
+0
-0
0 additions, 0 deletions
tests/data/dirty_with_nsid.docx
tests/test_deep_cleaning.py
+31
-0
31 additions, 0 deletions
tests/test_deep_cleaning.py
with
34 additions
and
0 deletions
README.md
+
3
−
0
View file @
fc924239
...
...
@@ -140,6 +140,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
Copyright 2018 Julien (jvoisin) Voisin
<julien.voisin+mat2@dustri.org>
Copyright 2016 Marie Rose for MAT2's logo
The
`tests/data/dirty_with_nsid.docx`
file is licensed under GPLv3,
and was borrowed from the Calibre project: https://calibre-ebook.com/downloads/demos/demo.docx
# Thanks
MAT2 wouldn't exist without:
...
...
This diff is collapsed.
Click to expand it.
tests/data/dirty_with_nsid.docx
0 → 100644
+
0
−
0
View file @
fc924239
File added
This diff is collapsed.
Click to expand it.
tests/test_deep_cleaning.py
+
31
−
0
View file @
fc924239
...
...
@@ -137,3 +137,34 @@ class TestRsidRemoval(unittest.TestCase):
os
.
remove
(
'
./tests/data/clean.docx
'
)
os
.
remove
(
'
./tests/data/clean.cleaned.docx
'
)
class
TestNsidRemoval
(
unittest
.
TestCase
):
def
test_office
(
self
):
shutil
.
copy
(
'
./tests/data/dirty_with_nsid.docx
'
,
'
./tests/data/clean.docx
'
)
p
=
office
.
MSOfficeParser
(
'
./tests/data/clean.docx
'
)
meta
=
p
.
get_meta
()
self
.
assertIsNotNone
(
meta
)
how_many_rsid
=
False
with
zipfile
.
ZipFile
(
'
./tests/data/clean.docx
'
)
as
zin
:
for
item
in
zin
.
infolist
():
if
not
item
.
filename
.
endswith
(
'
.xml
'
):
continue
num
=
zin
.
read
(
item
).
decode
(
'
utf-8
'
).
lower
().
count
(
'
w:rsid
'
)
how_many_rsid
+=
num
self
.
assertEqual
(
how_many_rsid
,
1190
)
ret
=
p
.
remove_all
()
self
.
assertTrue
(
ret
)
with
zipfile
.
ZipFile
(
'
./tests/data/clean.cleaned.docx
'
)
as
zin
:
for
item
in
zin
.
infolist
():
if
not
item
.
filename
.
endswith
(
'
.xml
'
):
continue
num
=
zin
.
read
(
item
).
decode
(
'
utf-8
'
).
lower
().
count
(
'
w:nsid
'
)
self
.
assertEqual
(
num
,
0
)
os
.
remove
(
'
./tests/data/clean.docx
'
)
os
.
remove
(
'
./tests/data/clean.cleaned.docx
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment