Skip to content

Commit

Permalink
fix: categories type and related test
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Dec 5, 2023
1 parent 267d4a4 commit de0397c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion mkdocs_rss_plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class RssPluginConfig(Config):

abstract_chars_count = config_options.Type(int, default=160)
abstract_delimiter = config_options.Type(str, default="<!-- more -->")
categories = config_options.ListOfItems(config_options.Type(str), default=[])
categories = config_options.Optional(
config_options.ListOfItems(config_options.Type(str))
)
comments_path = config_options.Optional(config_options.Type(str))
date_from_meta = config_options.Optional(config_options.Type(dict))
enabled = config_options.Type(bool, default=True)
Expand Down
11 changes: 9 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
import unittest
from pathlib import Path

# 3rd party
from mkdocs.config.base import Config

from mkdocs_rss_plugin.config import RssPluginConfig

# plugin target
from mkdocs_rss_plugin.plugin import GitRssPlugin

Expand Down Expand Up @@ -65,15 +68,17 @@ def test_plugin_config_defaults(self):
"feed_ttl": 1440,
"image": None,
"length": 20,
"pretty_print": False,
"match_path": ".*",
"pretty_print": False,
"url_parameters": None,
"use_git": True,
}

# load
plugin = GitRssPlugin()
errors, warnings = plugin.load_config({})
self.assertIsInstance(plugin.config, RssPluginConfig)
self.assertIsInstance(plugin.config, Config)
self.assertEqual(plugin.config, expected)
self.assertEqual(errors, [])
self.assertEqual(warnings, [])
Expand All @@ -90,8 +95,8 @@ def test_plugin_config_image(self):
"feed_ttl": 1440,
"image": self.feed_image,
"length": 20,
"pretty_print": False,
"match_path": ".*",
"pretty_print": False,
"url_parameters": None,
"use_git": True,
}
Expand All @@ -102,6 +107,8 @@ def test_plugin_config_image(self):
# load
plugin = GitRssPlugin()
errors, warnings = plugin.load_config(custom_cfg)
self.assertIsInstance(plugin.config, RssPluginConfig)
self.assertIsInstance(plugin.config, Config)
self.assertEqual(plugin.config, expected)
self.assertEqual(errors, [])
self.assertEqual(warnings, [])
Expand Down

0 comments on commit de0397c

Please sign in to comment.