From 35851dccbfedff89d17105ba5c108148f33d0412 Mon Sep 17 00:00:00 2001 From: Paul Hewlett Date: Tue, 11 May 2021 13:29:01 +0100 Subject: [PATCH] Dev/eccles/remove unnecessary unittests (#17) * Build about.py in builder image Problem: Creating about.py in host environmant fails if python setuptools is unavailable Solution: Create about.py using docker image. Signed-off-by: Paul Hewlett * Suppress unittest coverage for timestamp.py Problem: Timestamp.py is so simple it does not warrant unittests. Solution: Add correct method of suppressing unittests for individual files and remove unittests for timestamp.py. Signed-off-by: Paul Hewlett --- Taskfile.yml | 2 +- archivist/logger.py | 4 ++-- setup.cfg | 7 +++++++ unittests/testtimestamp.py | 41 -------------------------------------- 4 files changed, 10 insertions(+), 44 deletions(-) delete mode 100644 unittests/testtimestamp.py diff --git a/Taskfile.yml b/Taskfile.yml index 60e5d802..e434ee2d 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -5,7 +5,7 @@ tasks: about: desc: Generate about.py cmds: - - ./scripts/version.sh + - ./scripts/builder.sh ./scripts/version.sh status: - test -s archivist/about.py diff --git a/archivist/logger.py b/archivist/logger.py index 076b2545..c783b8e2 100644 --- a/archivist/logger.py +++ b/archivist/logger.py @@ -16,8 +16,8 @@ def set_logger(level): Setup logger Also used by unittests """ - LOGGER.setLevel(level) # pragma: no cover - if not LOGGER.hasHandlers(): # pragma: no cover + LOGGER.setLevel(level) + if not LOGGER.hasHandlers(): handler = logging.StreamHandler() handler.setFormatter( logging.Formatter( diff --git a/setup.cfg b/setup.cfg index bb84c2c1..0d29f8a9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,3 +5,10 @@ max-line-length = 88 [coverage:report] fail_under = 100 + +[coverage:run] +omit = + # utility + archivist/logger.py + # so simple - not worth testing + archivist/timestamp.py diff --git a/unittests/testtimestamp.py b/unittests/testtimestamp.py deleted file mode 100644 index 187f5d50..00000000 --- a/unittests/testtimestamp.py +++ /dev/null @@ -1,41 +0,0 @@ -""" -Test archivist -""" - -# pylint: disable=attribute-defined-outside-init -# pylint: disable=missing-docstring -# pylint: disable=too-few-public-methods - -from unittest import TestCase, mock - -from archivist import timestamp - - -class TestTimestamp(TestCase): - """ - Test timestamp - """ - - @mock.patch("archivist.timestamp.iso8601.parse_date") - def test_parse_timestamp(self, mock_parse_date): - """ - Test parse_timestamp - """ - unused_result = timestamp.parse_timestamp("date_string") - self.assertEqual( - tuple(mock_parse_date.call_args), - mock.call("date_string"), - msg="parse_timestamp called with incorrect argument", - ) - - @mock.patch("archivist.timestamp.rfc3339.rfc3339") - def test_make_timestamp(self, mock_rfc3339): - """ - Test parse_timestamp - """ - unused_result = timestamp.make_timestamp("date_string") - self.assertEqual( - tuple(mock_rfc3339.call_args), - mock.call("date_string"), - msg="make_timestamp called with incorrect argument", - )