From 41a30f1b07d94d01314db5ba063316855c2047a5 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Sat, 27 Jul 2019 00:36:40 +0300 Subject: [PATCH] Add initial tests For now only test fixes because they return changed data. I'm not sure how to test the checks, because they don't return data and I can't modify them to return boolean values without breaking the app. --- tests/__init__.py | 0 tests/test_fix.py | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_fix.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_fix.py b/tests/test_fix.py new file mode 100644 index 0000000..45ac9e4 --- /dev/null +++ b/tests/test_fix.py @@ -0,0 +1,23 @@ +import csv_metadata_quality.fix as fix +import pytest + +def test_fix_leading_whitespace(): + '''Test fixing leading whitespace.''' + + value = ' Alan' + + assert fix.whitespace(value) == 'Alan' + +def test_fix_trailing_whitespace(): + '''Test fixing trailing whitespace.''' + + value = 'Alan ' + + assert fix.whitespace(value) == 'Alan' + +def test_fix_excessive_whitespace(): + '''Test fixing excessive whitespace.''' + + value = 'Alan Orth' + + assert fix.whitespace(value) == 'Alan Orth'