Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
DipSO
tsv2properties
Commits
b27d05e2
Commit
b27d05e2
authored
Apr 05, 2022
by
dimitri.szabo
Browse files
Tests for fields & vocabularies
parent
5e7dd5a9
Pipeline
#54878
failed with stage
in 59 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/test/data/test_fields.properties
0 → 100644
View file @
b27d05e2
datasetfieldtype.simpleField.title
=
Simple Field
datasetfieldtype.controlledField.title
=
Controlled Field
datasetfieldtype.simpleField.description
=
Description simpleField
datasetfieldtype.controlledField.description
=
Description controlledField
\ No newline at end of file
src/test/data/test_vocabularies.properties
0 → 100644
View file @
b27d05e2
controlledvocabulary.controlledField.id
=
Champ avec id
controlledvocabulary.controlledField.colonnes_supplementaires
=
Colonnes supplémentaires
controlledvocabulary.controlledField.ae_o_eea
=
ÅÉ Ô éèà
\ No newline at end of file
src/test/test_tsv2properties.py
View file @
b27d05e2
from
cmath
import
nan
import
os
import
pytest
import
tsv2properties
as
t2p
import
pandas
as
pd
...
...
@@ -17,25 +15,35 @@ test_vocabularies = pd.DataFrame(
'Value'
:[
'Champ avec id'
,
'Colonnes supplémentaires'
,
'ÅÉ Ô éèà'
],
'identifier'
:[
'id'
,
nan
,
nan
]
})
test_vocabularies
.
index
=
[
3
,
4
,
5
]
test_vocabularies
.
index
=
[
3
,
4
,
5
]
# harmonisation avec l'index extrait du fichier test
# Tests
def
test_tsvDivider
(
shared_datadir
):
data_frames
=
t2p
.
tsvDivider
(
shared_datadir
/
'test.tsv'
)
data_frames
=
t2p
.
tsvDivider
(
path_to_tsv
=
shared_datadir
/
'test.tsv'
)
fields
=
data_frames
[
0
]
vocabularies
=
data_frames
[
1
]
assert
fields
.
equals
(
test_fields
)
assert
vocabularies
.
equals
(
test_vocabularies
)
def
test_extractDatasetFields
():
def
test_extractDatasetFields
(
shared_datadir
):
fields_properties_path
=
shared_datadir
/
'output_fields.properties'
t2p
.
extractDatasetFields
(
dataset_fields
=
test_fields
,
output_file_path
=
fields_properties_path
)
with
open
(
shared_datadir
/
'test_fields.properties'
)
as
test_fields_properties
:
with
open
(
fields_properties_path
,
'r'
)
as
properties
:
assert
properties
.
read
()
==
test_fields_properties
.
read
()
def
test_convertControlledVocabularies
(
shared_datadir
):
vocabularies_properties_path
=
shared_datadir
/
"output_vocabularies.properties"
t2p
.
convertControlledVocabularies
(
controlled_vocabularies
=
test_vocabularies
,
output_file_path
=
vocabularies_properties_path
)
with
open
(
shared_datadir
/
"test_vocabularies.properties"
)
as
test_vocabularies_properties
:
with
open
(
vocabularies_properties_path
,
'r'
)
as
properties
:
assert
properties
.
read
()
==
test_vocabularies_properties
.
read
()
def
test_singleTsvToProperties
(
shared_datadir
):
t2p
.
singleTsvToProperties
(
path_to_tsv
=
shared_datadir
/
'test.tsv'
,
path_to_properties
=
shared_datadir
/
'output_test.properties'
)
assert
1
!=
1
def
test_convertControlledVocabularies
():
assert
1
!=
1
def
test_singleTsvToProperties
():
assert
1
!=
1
def
test_tsvsToProperties
():
def
test_tsvsToProperties
(
shared_datadir
):
t2p
.
tsvsToProperties
(
tsv_dir
=
shared_datadir
,
properties_dir
=
shared_datadir
)
assert
1
!=
1
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