-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests back operational with github actions
- Loading branch information
1 parent
612b47e
commit 9093ab3
Showing
3 changed files
with
42 additions
and
88 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,68 @@ | ||
import os | ||
import unittest | ||
import shutil | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from otlmow_template.SubsetTemplateCreator import SubsetTemplateCreator | ||
|
||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
ROOT_DIR = Path(__file__).parent | ||
|
||
|
||
def test_basic_functionality(subtests): | ||
# Toegangsprocedure en Agent zijn niet meer in de subset aanwezig | ||
def test_func1(subtests): | ||
subset_tool = SubsetTemplateCreator() | ||
subset_location = Path(ROOT_DIR) / 'OTL_AllCasesTestClass.db' | ||
xls_location = Path(ROOT_DIR) / 'template_file_text.xlsx' | ||
csv_location = Path(ROOT_DIR) / 'template_file_text.csv' | ||
subset_location = ROOT_DIR / 'Flitspaal_noAgent3.0.db' | ||
xls_location = Path(ROOT_DIR) / 'testFileStorage' / 'template_file_text.xlsx' | ||
csv_location = Path(ROOT_DIR) / 'testFileStorage' / 'template_file_text.csv' | ||
|
||
with subtests.test(msg='xlsx'): | ||
with subtests.test(msg='xls'): | ||
subset_tool.generate_template_from_subset(path_to_subset=subset_location, | ||
path_to_template_file_and_extension=xls_location, | ||
class_directory='UnitTests.TestClasses.Classes') | ||
) | ||
assert Path(ROOT_DIR / 'testFileStorage' / 'template_file_text.xlsx').exists() | ||
|
||
with subtests.test(msg='csv, split per type'): | ||
subset_tool.generate_template_from_subset(path_to_subset=subset_location, | ||
path_to_template_file_and_extension=csv_location, | ||
class_directory='UnitTests.TestClasses.Classes', | ||
split_per_type=True) | ||
|
||
with subtests.test(msg='csv, not split per type'): | ||
subset_tool.generate_template_from_subset(path_to_subset=subset_location, | ||
path_to_template_file_and_extension=csv_location, | ||
class_directory='UnitTests.TestClasses.Classes', | ||
split_per_type=False) | ||
assert Path(ROOT_DIR / 'testFileStorage' / 'template_file_text.csv').exists() | ||
|
||
# TODO assert missing | ||
shutil.rmtree(Path(ROOT_DIR) / 'testFileStorage') | ||
os.makedirs(Path(ROOT_DIR) / 'testFileStorage') | ||
|
||
|
||
def test_subset_actual_subset(): | ||
subset_tool = SubsetTemplateCreator() | ||
csv_location = Path(ROOT_DIR) / 'camera_steun.csv' | ||
subset_tool.generate_template_from_subset(path_to_subset=Path(ROOT_DIR) / 'camera_steun.db', | ||
csv_location = ROOT_DIR / 'testFileStorage' / 'camera_steun.csv' | ||
subset_tool.generate_template_from_subset(path_to_subset=ROOT_DIR / 'camera_steun.db', | ||
path_to_template_file_and_extension=csv_location, | ||
split_per_type=True) | ||
# TODO assert missing | ||
csv1 = ROOT_DIR / 'testFileStorage' / 'camera_steun_onderdeel_Bevestiging.csv' | ||
csv2 = ROOT_DIR / 'testFileStorage' / 'camera_steun_onderdeel_Camera.csv' | ||
csv3 = ROOT_DIR / 'testFileStorage' / 'camera_steun_onderdeel_RechteSteun.csv' | ||
assert csv1.exists() | ||
assert csv2.exists() | ||
assert csv3.exists() | ||
shutil.rmtree(Path(ROOT_DIR) / 'testFileStorage') | ||
os.makedirs(Path(ROOT_DIR) / 'testFileStorage') | ||
|
||
|
||
def test_filter(): | ||
db_location = ROOT_DIR / 'flitspaal_noAgent3.0.db' | ||
list_of_filter_uri = ['https://wegenenverkeer.data.vlaanderen.be/ns/installatie#Flitspaal'] | ||
filtered = SubsetTemplateCreator.filters_assets_by_subset(db_location, list_of_filter_uri) | ||
assert len(filtered) == 1 | ||
assert filtered[0].name == 'Flitspaal' | ||
|
||
|
||
@unittest.skip | ||
def test_func2(): | ||
list_of_otl_objects = [] | ||
SubsetTemplateCreator.filters_assets_by_subset(Path('OTL_AllCasesTestClass.db'), list_of_otl_objects) | ||
def test_empty_filter_list_removes_all_entries(): | ||
db_location = ROOT_DIR / 'flitspaal_noAgent3.0.db' | ||
list_of_filter_uri = [] | ||
filtered = SubsetTemplateCreator.filters_assets_by_subset(db_location, list_of_filter_uri) | ||
assert len(filtered) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import os, pathlib | ||
import os | ||
import pathlib | ||
|
||
import pytest | ||
|
||
os.chdir(pathlib.Path.cwd()) | ||
|