diff --git a/logo/Picture10.png b/logo/Picture10.png new file mode 100644 index 0000000000..3221c026ee Binary files /dev/null and b/logo/Picture10.png differ diff --git a/logo/Picture11.png b/logo/Picture11.png new file mode 100644 index 0000000000..acab4af962 Binary files /dev/null and b/logo/Picture11.png differ diff --git a/logo/Picture12.png b/logo/Picture12.png new file mode 100644 index 0000000000..23e53f7098 Binary files /dev/null and b/logo/Picture12.png differ diff --git a/logo/Picture13.png b/logo/Picture13.png new file mode 100644 index 0000000000..e8a5b2bf78 Binary files /dev/null and b/logo/Picture13.png differ diff --git a/logo/Picture14.png b/logo/Picture14.png new file mode 100644 index 0000000000..23e53f7098 Binary files /dev/null and b/logo/Picture14.png differ diff --git a/logo/Picture15.png b/logo/Picture15.png new file mode 100644 index 0000000000..a58a79d48f Binary files /dev/null and b/logo/Picture15.png differ diff --git a/logo/Picture16.png b/logo/Picture16.png new file mode 100644 index 0000000000..f9d150e8ad Binary files /dev/null and b/logo/Picture16.png differ diff --git a/logo/Picture5.png b/logo/Picture5.png new file mode 100644 index 0000000000..00d7b29e0d Binary files /dev/null and b/logo/Picture5.png differ diff --git a/logo/Picture6.png b/logo/Picture6.png new file mode 100644 index 0000000000..3221c026ee Binary files /dev/null and b/logo/Picture6.png differ diff --git a/logo/Picture7.png b/logo/Picture7.png new file mode 100644 index 0000000000..d84bba33a4 Binary files /dev/null and b/logo/Picture7.png differ diff --git a/logo/Picture8.png b/logo/Picture8.png new file mode 100644 index 0000000000..e8a5b2bf78 Binary files /dev/null and b/logo/Picture8.png differ diff --git a/logo/Picture9.png b/logo/Picture9.png new file mode 100644 index 0000000000..191e07bbd1 Binary files /dev/null and b/logo/Picture9.png differ diff --git a/logo/ass1_pic_1.png b/logo/ass1_pic_1.png new file mode 100644 index 0000000000..3ea71bc88d Binary files /dev/null and b/logo/ass1_pic_1.png differ diff --git a/logo/ass1_pic_2.png b/logo/ass1_pic_2.png new file mode 100644 index 0000000000..89597807eb Binary files /dev/null and b/logo/ass1_pic_2.png differ diff --git a/logo/ass1_pic_3.png b/logo/ass1_pic_3.png new file mode 100644 index 0000000000..2668d0a713 Binary files /dev/null and b/logo/ass1_pic_3.png differ diff --git a/logo/ass1_pic_4.png b/logo/ass1_pic_4.png new file mode 100644 index 0000000000..191e07bbd1 Binary files /dev/null and b/logo/ass1_pic_4.png differ diff --git a/nikola/log.py b/nikola/log.py index f998427f0a..ffa331f292 100644 --- a/nikola/log.py +++ b/nikola/log.py @@ -80,11 +80,18 @@ def wrap_in_color(self, record: logging.LogRecord) -> str: # Initial configuration class LoggingMode(enum.Enum): """Logging mode options.""" - + NORMAL = 0 STRICT = 1 QUIET = 2 +branch_coverage_configure = { + "branch_1": False, + "branch_2": False, + "branch_3": False, + "branch_4": False + } + def configure_logging(logging_mode: LoggingMode = LoggingMode.NORMAL) -> None: """Configure logging for Nikola. @@ -92,11 +99,14 @@ def configure_logging(logging_mode: LoggingMode = LoggingMode.NORMAL) -> None: This method can be called multiple times, previous configuration will be overridden. """ if DEBUG: + branch_coverage_configure["branch_1"] = True logging.root.level = logging.DEBUG else: + branch_coverage_configure["branch_2"] = True logging.root.level = logging.INFO if logging_mode == LoggingMode.QUIET: + branch_coverage_configure["branch_3"] = True logging.root.handlers = [] return @@ -110,14 +120,23 @@ def configure_logging(logging_mode: LoggingMode = LoggingMode.NORMAL) -> None: handlers = [handler] if logging_mode == LoggingMode.STRICT: + branch_coverage_configure["branch_4"] = True handlers.append(StrictModeExceptionHandler()) logging.root.handlers = handlers +def print_coverage_configure(): + for branch, hit in branch_coverage_configure.items(): + print(f"configure {branch} was {'hit' if hit else 'not hit'}") + +def reset_coverage_configure(): + for key in branch_coverage_configure: + branch_coverage_configure[key] = False configure_logging() + # For compatibility with old code written with Logbook in mind # TODO remove in v9 def patch_notice_level(logger: logging.Logger) -> logging.Logger: diff --git a/nikola/plugins/command/status.py b/nikola/plugins/command/status.py index a22f1737ae..683a311f64 100644 --- a/nikola/plugins/command/status.py +++ b/nikola/plugins/command/status.py @@ -35,9 +35,17 @@ class CommandStatus(Command): """Display site status.""" + + branch_coverage = { + "branch_1": False, + "branch_2": False, + "branch_3": False, + "branch_4": False + } + - name = "status" + name = "status" doc_purpose = "display site status" doc_description = "Show information about the posts and site deployment." doc_usage = '[-d|--list-drafts] [-m|--list-modified] [-p|--list-private] [-P|--list-published] [-s|--list-scheduled]' @@ -163,9 +171,22 @@ def human_time(self, dt): hours = dt.seconds / 60 // 60 minutes = dt.seconds / 60 - (hours * 60) if days > 0: + self.branch_coverage["branch_1"] = True return "{0:.0f} days and {1:.0f} hours".format(days, hours) elif hours > 0: + self.branch_coverage["branch_2"] = True return "{0:.0f} hours and {1:.0f} minutes".format(hours, minutes) elif minutes: + self.branch_coverage["branch_3"] = True return "{0:.0f} minutes".format(minutes) + self.branch_coverage["branch_4"] = True return False + + + def report_coverage(self): + for branch, hit in self.branch_coverage.items(): + print(f"{branch}: {'covered' if hit else 'not covered'}") + + def reset_coverage(self): + for key in self.branch_coverage: + self.branch_coverage[key] = False diff --git a/tests/test_configure_logging.py b/tests/test_configure_logging.py new file mode 100644 index 0000000000..ac63b20b17 --- /dev/null +++ b/tests/test_configure_logging.py @@ -0,0 +1,38 @@ +from nikola.log import configure_logging, print_coverage_configure, reset_coverage_configure, LoggingMode +from unittest.mock import patch + + +def test_normal_mode_debug(): + reset_coverage_configure() + with patch('nikola.log.DEBUG', True): + configure_logging(logging_mode=LoggingMode.NORMAL) + print_coverage_configure() + + +def test_normal_mode_no_debug(): + reset_coverage_configure() + configure_logging(logging_mode=LoggingMode.NORMAL) + print_coverage_configure() + + +def test_quiet_mode_debug(): + reset_coverage_configure() + with patch('nikola.log.DEBUG', True): + configure_logging(logging_mode=LoggingMode.QUIET) + print_coverage_configure() + +def test_quiet_mode_no_debug(): + reset_coverage_configure() + configure_logging(logging_mode=LoggingMode.QUIET) + print_coverage_configure() + +def test_strict_mode_debug(): + reset_coverage_configure() + with patch('nikola.log.DEBUG', True): + configure_logging(logging_mode=LoggingMode.STRICT) + print_coverage_configure() + +def test_strict_mode_no_debug(): + reset_coverage_configure() + configure_logging(logging_mode=LoggingMode.STRICT) + print_coverage_configure() \ No newline at end of file diff --git a/tests/test_configure_logs.py b/tests/test_configure_logs.py new file mode 100644 index 0000000000..d47c6ab531 --- /dev/null +++ b/tests/test_configure_logs.py @@ -0,0 +1,54 @@ +from nikola.log import configure_logging, print_coverage_configure, reset_coverage_configure, LoggingMode +from unittest.mock import patch +import pytest + +@pytest.mark.skip(reason="None") +def test_normal_mode_debug(): + #reset_coverage_configure() + with patch('nikola.log.DEBUG', True): + configure_logging(logging_mode=LoggingMode.NORMAL) + #print_coverage_configure() + +@pytest.mark.skip(reason="None") +def test_normal_mode_no_debug(): + #reset_coverage_configure() + configure_logging(logging_mode=LoggingMode.NORMAL) + #print_coverage_configure() + +@pytest.mark.skip(reason="None") +def test_quiet_mode_debug(): + #reset_coverage_configure() + with patch('nikola.log.DEBUG', True): + configure_logging(logging_mode=LoggingMode.QUIET) + #print_coverage_configure() + +@pytest.mark.skip(reason="None") +def test_quiet_mode_no_debug(): + #reset_coverage_configure() + configure_logging(logging_mode=LoggingMode.QUIET) + #print_coverage_configure() + +@pytest.mark.skip(reason="None") +def test_strict_mode_debug(): + #reset_coverage_configure() + with patch('nikola.log.DEBUG', True): + configure_logging(logging_mode=LoggingMode.STRICT) + #print_coverage_configure() + +@pytest.mark.skip(reason="None") +def test_strict_mode_no_debug(): + #reset_coverage_configure() + configure_logging(logging_mode=LoggingMode.STRICT) + #print_coverage_configure() + + +def test_combined(): + reset_coverage_configure() + test_normal_mode_debug() + test_normal_mode_no_debug() + test_quiet_mode_debug() + test_quiet_mode_no_debug() + test_strict_mode_debug() + test_strict_mode_no_debug + print_coverage_configure() + diff --git a/tests/test_human.py b/tests/test_human.py new file mode 100644 index 0000000000..0aba01726d --- /dev/null +++ b/tests/test_human.py @@ -0,0 +1,41 @@ +import pytest +from datetime import timedelta +from nikola.plugins.command.status import CommandStatus + +@pytest.fixture(scope="module") +def command_status(): + return CommandStatus() + +@pytest.mark.skip(reason="None") +def test_days_branch(command_status): + print("\n test with 2 days 3 hours:") + result = command_status.human_time(timedelta(days=2, hours=3)) + print(f"this is the result: ${result}") + +@pytest.mark.skip(reason="None") +def test_hours_branch(command_status): + print("test with 4 hours 20 minutes:") + result = command_status.human_time(timedelta(hours=4, minutes=20)) + print(f"this is the result: ${result}") + + +@pytest.mark.skip(reason="None") +def test_minutes_branch(command_status): + print("test with 15 minutes:") + result = command_status.human_time(timedelta(minutes=15)) + print(f"this is the result: ${result}") + +@pytest.mark.skip(reason="None") +def test_seconds_branch(command_status): + print("test with 0 seconds:") + result = command_status.human_time(timedelta(seconds=0)) + print(f"this is the result: ${result}") + +def test_combined(command_status): + command_status.reset_coverage() + test_days_branch(command_status) + test_hours_branch(command_status) + test_minutes_branch(command_status) + test_seconds_branch(command_status) + command_status.report_coverage() + diff --git a/tests/test_report_coverage.py b/tests/test_report_coverage.py new file mode 100644 index 0000000000..b5c59e6b4b --- /dev/null +++ b/tests/test_report_coverage.py @@ -0,0 +1,3 @@ +from nikola.plugins.command.status import CommandStatus +command_status = CommandStatus() +command_status.report_coverage() \ No newline at end of file