Commit b27d05e2 authored by dimitri.szabo's avatar dimitri.szabo
Browse files

Tests for fields & vocabularies

parent 5e7dd5a9
Pipeline #54878 failed with stage
in 59 seconds
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
controlledvocabulary.controlledField.id=Champ avec id
controlledvocabulary.controlledField.colonnes_supplementaires=Colonnes supplémentaires
controlledvocabulary.controlledField.ae_o_eea=ÅÉ Ô éèà
\ No newline at end of file
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment