FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
extractcode/tests/test_extractcode_api.py at main · aboutcode-org/extractcode · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
aboutcode-org
/
extractcode
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
23
Star
39
Code
Issues
43
Pull requests
12
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
extractcode
/
tests
/
test_extractcode_api.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
54 lines (46 loc) · 1.77 KB
Breadcrumbs
extractcode
/
tests
/
test_extractcode_api.py
Copy path
File metadata and controls
54 lines (46 loc) · 1.77 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: utf-8 -*-
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# ScanCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/extractcode for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
import
os
from
commoncode
import
fileutils
import
extractcode
from
extractcode
import
extract
from
extractcode
import
api
from
extractcode_assert_utils
import
check_files
from
extractcode_assert_utils
import
BaseArchiveTestCase
project_root
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
class
TestExtractApi
(
BaseArchiveTestCase
):
test_data_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"data"
)
def
test_extract_archive
(
self
):
test_dir
=
self
.
get_test_loc
(
"api/doc.docx"
,
copy
=
True
)
base
=
fileutils
.
parent_directory
(
test_dir
)
expected
=
[
"c/a/a.txt"
,
"c/b/a.txt"
,
"c/c/a.txt"
,
]
cleaned_test_file
=
test_dir
.
replace
(
base
,
""
)
expected_event
=
[
extract
.
ExtractEvent
(
source
=
"doc.docx"
,
target
=
"doc.docx-extract"
,
done
=
False
,
warnings
=
[],
errors
=
[]
),
extract
.
ExtractEvent
(
source
=
"doc.docx"
,
target
=
"doc.docx-extract"
,
done
=
True
,
warnings
=
[],
errors
=
[]
),
]
target
=
extractcode
.
get_extraction_path
(
test_dir
)
result
=
list
(
api
.
extract_archive
(
test_dir
,
target
))
result
=
[
r
.
_replace
(
source
=
cleaned_test_file
,
target
=
extractcode
.
get_extraction_path
(
cleaned_test_file
)
)
for
r
in
result
]
assert
expected_event
==
result
check_files
(
target
,
expected
)
Back
|
FazBrowse Home
|
New Git URL