Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/djtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
is uploaded to the Beatcloud.
"""

import warnings

warnings.filterwarnings("ignore", message="Couldn't find ffmpeg or avconv")
warnings.filterwarnings("ignore", message="Couldn't find ffprobe or avprobe")

# pylint: disable=wrong-import-position
from .configs import build_config
from .collection import (
COLLECTION_OPERATIONS,
Expand Down Expand Up @@ -73,6 +79,7 @@ def main():
logger, log_file = initialize_logger()
config = build_config()
logger.setLevel(config.log_level.value)
logger.info(repr(config))

# Run "collection", "spotify", "sync", and "utils" package operations if
# any of the flags to do so are present in the config.
Expand Down
11 changes: 0 additions & 11 deletions src/djtools/configs/config_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,14 @@
BaseModel that defines a __repr__ method to be used by all the config objects
used in this library."""

import logging
from typing import Any

from pydantic import BaseModel


logger = logging.getLogger(__name__)


class BaseConfigFormatter(BaseModel, extra="forbid"):
"""Pydantic BaseModel with a __repr__ method for pretty printing."""

def __init__(self, *args, **kwargs):
"""Constructor."""
super().__init__(*args, **kwargs)

if self.__class__.__name__ == "BaseConfig":
logger.info(repr(self))

def _format_value(self, value: Any, indent_level: int) -> str:
spaces = "\t" * indent_level

Expand Down
17 changes: 0 additions & 17 deletions tests/configs/test_base_config_formatter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Testing for the config_formatter module."""

from unittest import mock

from pydantic import ValidationError

from djtools.configs.config_formatter import BaseConfigFormatter
Expand All @@ -21,21 +19,6 @@ class SampleConfig(BaseConfigFormatter):
assert repr(config) == expected_repr


def test_base_config_formatter_logging():
"""Define a class named "BaseConfig" to trigger the logging behavior."""
with mock.patch("djtools.configs.config_formatter.logger") as mock_logger:

class BaseConfig(BaseConfigFormatter):
"""Dummy class."""

field: str

_ = BaseConfig(field="test")
mock_logger.info.assert_called_once_with(
"BaseConfig(\n\tfield='test'\n)"
)


def test_base_config_formatter_nested():
"""Define nested configurations."""

Expand Down