Skip to content

Commit

Permalink
tests back operational with github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperBerton committed Nov 17, 2023
1 parent 612b47e commit 9093ab3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 88 deletions.
69 changes: 0 additions & 69 deletions UnitTests/Subset/SubsetTemplateCreatorTests.py

This file was deleted.

57 changes: 39 additions & 18 deletions UnitTests/Subset/SubsetTemplateCreator_test.py
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
4 changes: 3 additions & 1 deletion UnitTests/run_all_tests.py
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())
Expand Down

0 comments on commit 9093ab3

Please sign in to comment.