Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
caosdb
Software
caosdb-advanced-user-tools
Commits
92d60ae8
Commit
92d60ae8
authored
3 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
TST: Add unittest for .xls file
parent
bd15476c
No related branches found
No related tags found
1 merge request
!2
FIX: Use openpyxl instead of xlrd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unittests/test_table_importer.py
+17
-1
17 additions, 1 deletion
unittests/test_table_importer.py
with
17 additions
and
1 deletion
unittests/test_table_importer.py
+
17
−
1
View file @
92d60ae8
...
@@ -77,7 +77,8 @@ class ConverterTest(unittest.TestCase):
...
@@ -77,7 +77,8 @@ class ConverterTest(unittest.TestCase):
# TODO datatypes are different; fix it
# TODO datatypes are different; fix it
assert
df
.
d
.
iloc
[
0
]
==
datetime
.
datetime
(
1980
,
12
,
31
,
13
,
24
,
23
)
assert
df
.
d
.
iloc
[
0
]
==
datetime
.
datetime
(
1980
,
12
,
31
,
13
,
24
,
23
)
def
test_date
(
self
):
def
test_date_xlsx
(
self
):
"""
Test with .xlsx in order to check openpyxl engine.
"""
test_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
date.xlsx
"
)
test_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
date.xlsx
"
)
self
.
importer
=
XLSImporter
(
converters
=
{
'
a
'
:
date_converter
,
self
.
importer
=
XLSImporter
(
converters
=
{
'
a
'
:
date_converter
,
'
b
'
:
date_converter
,
'
b
'
:
date_converter
,
...
@@ -91,6 +92,21 @@ class ConverterTest(unittest.TestCase):
...
@@ -91,6 +92,21 @@ class ConverterTest(unittest.TestCase):
assert
df
.
shape
[
0
]
==
2
assert
df
.
shape
[
0
]
==
2
assert
df
.
a
.
iloc
[
0
]
==
df
.
b
.
iloc
[
0
]
==
df
.
c
.
iloc
[
0
]
assert
df
.
a
.
iloc
[
0
]
==
df
.
b
.
iloc
[
0
]
==
df
.
c
.
iloc
[
0
]
def
test_date_xls
(
self
):
"""
Test with .xlsx in order to check xlrd engine.
"""
test_file
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
date.xls
"
)
self
.
importer
=
XLSImporter
(
converters
=
{
'
a
'
:
date_converter
,
'
b
'
:
date_converter
,
'
c
'
:
partial
(
date_converter
,
fmt
=
"
%d.%m.%y
"
)
},
obligatory_columns
=
[
'
a
'
])
xls_file
=
pd
.
io
.
excel
.
ExcelFile
(
test_file
)
df
=
xls_file
.
parse
()
df
=
self
.
importer
.
read_xls
(
test_file
)
assert
df
.
shape
[
0
]
==
2
assert
df
.
a
.
iloc
[
0
]
==
df
.
b
.
iloc
[
0
]
==
df
.
c
.
iloc
[
0
]
def
test_inc_date
(
self
):
def
test_inc_date
(
self
):
incomplete_date_converter
(
"
2020
"
,
fmts
=
{
"
%Y
"
:
"
%Y
"
})
==
"
2020
"
incomplete_date_converter
(
"
2020
"
,
fmts
=
{
"
%Y
"
:
"
%Y
"
})
==
"
2020
"
incomplete_date_converter
(
"
02/2020
"
,
incomplete_date_converter
(
"
02/2020
"
,
...
...
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