From fdf8fae065dcf044f44637f467769572d973a616 Mon Sep 17 00:00:00 2001 From: Dan Puttick Date: Mon, 5 Dec 2016 12:41:37 -0500 Subject: [PATCH] Created test_examples.py Decided that it makes sense to test example code seperately from module code. At some point might move these tests in with the example code, but for now am keeping them seperate and simple. --- tests/{test.py => oldtests.py} | 0 tests/test_examples.py | 83 +++++++++++++++++++ ...egration_pytest.py => test_integration.py} | 0 3 files changed, 83 insertions(+) rename tests/{test.py => oldtests.py} (100%) create mode 100644 tests/test_examples.py rename tests/{test_integration_pytest.py => test_integration.py} (100%) diff --git a/tests/test.py b/tests/oldtests.py similarity index 100% rename from tests/test.py rename to tests/oldtests.py diff --git a/tests/test_examples.py b/tests/test_examples.py new file mode 100644 index 0000000..63d8d47 --- /dev/null +++ b/tests/test_examples.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import sys + +import pytest + +from bin.specific import KittenGroomerSpec +from bin.pier9 import KittenGroomerPier9 +from bin.generic import KittenGroomer + +if sys.version_info.major == 2: + from bin.filecheck import KittenGroomerFileCheck + + +def setup_module(): + PY3 = sys.version_info.major == 3 + CURPATH = os.getcwd() + + +def test_specific_valid(self): + src = os.path.join(CURPATH, 'tests/src2') + dst = os.path.join(CURPATH, 'tests/dst') + spec = KittenGroomerSpec(src, dst, debug=True) + spec.processdir() + self.dump_logs(spec) + +def test_specific_invalid(self): + src = os.path.join(CURPATH, 'tests/src') + dst = os.path.join(CURPATH, 'tests/dst') + spec = KittenGroomerSpec(src, dst, debug=True) + spec.processdir() + self.dump_logs(spec) + +def test_pier9(self): + src = os.path.join(CURPATH, 'tests/src') + dst = os.path.join(CURPATH, 'tests/dst') + spec = KittenGroomerPier9(src, dst, debug=True) + spec.processdir() + self.dump_logs(spec) + +def test_generic(self): + src = os.path.join(CURPATH, 'tests/src2') + dst = os.path.join(CURPATH, 'tests/dst') + spec = KittenGroomer(src, dst, debug=True) + spec.processdir() + self.dump_logs(spec) + +def test_generic_2(self): + src = os.path.join(CURPATH, 'tests/src') + dst = os.path.join(CURPATH, 'tests/dst') + spec = KittenGroomer(src, dst, debug=True) + spec.processdir() + self.dump_logs(spec) + +def test_filecheck(self): + if PY3: + return + src = os.path.join(CURPATH, 'tests/src') + dst = os.path.join(CURPATH, 'tests/dst') + spec = KittenGroomerFileCheck(src, dst, debug=True) + spec.processdir() + self.dump_logs(spec) + +def test_filecheck_2(self): + if PY3: + return + src = os.path.join(self.CURPATH, 'tests/src2') + dst = os.path.join(self.CURPATH, 'tests/dst') + spec = KittenGroomerFileCheck(src, dst, debug=True) + spec.processdir() + self.dump_logs(spec) + +## Helper functions + +def dump_logs(self, kg): + print(open(kg.log_processing, 'rb').read()) + if kg.debug: + if os.path.exists(kg.log_debug_err): + print(open(kg.log_debug_err, 'rb').read()) + if os.path.exists(kg.log_debug_out): + print(open(kg.log_debug_out, 'rb').read()) diff --git a/tests/test_integration_pytest.py b/tests/test_integration.py similarity index 100% rename from tests/test_integration_pytest.py rename to tests/test_integration.py