From 7dcfc6c1282793ff3fe673878511e8f07fa9821d Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Sun, 8 Oct 2017 14:38:29 +0200 Subject: [PATCH] Added unit test. --- .travis.yml | 15 +++++++++++++++ tests.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .travis.yml create mode 100644 tests.py diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..83b4593 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +sudo: false +language: python +cache: pip +python: + - "2.7" + - "3.4" + +before_install: + - pip install codecov + +script: + - coverage run tests.py + +after_success: + - codecov diff --git a/tests.py b/tests.py new file mode 100644 index 0000000..b7d9845 --- /dev/null +++ b/tests.py @@ -0,0 +1,33 @@ +"""Installer unit tests.""" + +import os +import shutil +import tempfile +import unittest + +import run + + +class ConfigFileTestCase(unittest.TestCase): + """Test configuration file generation.""" + + def setUp(self): + """Create temp dir.""" + self.workdir = tempfile.mkdtemp() + self.cfgfile = os.path.join(self.workdir, "installer.cfg") + + def tearDown(self): + """Delete temp dir.""" + shutil.rmtree(self.workdir) + + def test_configfile_generation(self): + """Check simple case.""" + run.main([ + "--stop-after-configfile-check", + "--configfile", self.cfgfile, + "example.test"]) + self.assertTrue(os.path.exists(self.cfgfile)) + + +if __name__ == "__main__": + unittest.main()