def test_should_dump_content_negotiation(self) -> None: content_negotiation = True with _build_minimal_configuration() as configuration: configuration.content_negotiation = content_negotiation configuration_dict = _to_dict(configuration) self.assertEquals(content_negotiation, configuration_dict['content_negotiation'])
def test_should_dump_assets_directory_path(self) -> None: with TemporaryDirectory() as assets_directory_path: with _build_minimal_configuration() as configuration: configuration.assets_directory_path = assets_directory_path configuration_dict = _to_dict(configuration) self.assertEquals(assets_directory_path, configuration_dict['assets'])
def test_should_dump_theme_background_id(self) -> None: background_image_id = 'my-favorite-picture' with _build_minimal_configuration() as configuration: configuration.theme.background_image_id = background_image_id configuration_dict = _to_dict(configuration) self.assertEquals( background_image_id, configuration_dict['theme']['background_image_id'])
def test_should_dump_locale_locale(self) -> None: locale = 'nl-NL' locale_configuration = LocaleConfiguration(locale) with _build_minimal_configuration() as configuration: configuration.locales.replace([locale_configuration]) configuration_dict = _to_dict(configuration) self.assertListEqual([ { 'locale': locale, }, ], configuration_dict['locales'])
def test_should_dump_one_extension_without_configuration(self) -> None: with _build_minimal_configuration() as configuration: configuration.extensions.add( ExtensionConfiguration(NonConfigurableExtension)) configuration_dict = _to_dict(configuration) expected = { NonConfigurableExtension.name(): { 'enabled': True, 'configuration': {}, }, } self.assertEquals(expected, configuration_dict['extensions'])
def test_should_dump_minimal(self) -> None: with _build_minimal_configuration() as configuration: configuration_dict = _to_dict(configuration) self.assertEquals(configuration_dict['output'], str(configuration.output_directory_path)) self.assertEquals(configuration_dict['base_url'], configuration.base_url) self.assertEquals('Betty', configuration.title) self.assertIsNone(configuration.author) self.assertEquals(False, configuration.debug) self.assertEquals('', configuration.root_path) self.assertFalse(configuration.clean_urls) self.assertFalse(configuration.content_negotiation)
def test_should_dump_one_extension_with_configuration(self) -> None: with _build_minimal_configuration() as configuration: configuration.extensions.add( ExtensionConfiguration( ConfigurableExtension, True, ConfigurableExtensionConfiguration( check=1337, default='I will always be there for you.', ))) configuration_dict = _to_dict(configuration) expected = { ConfigurableExtension.name(): { 'enabled': True, 'configuration': { 'check': 1337, 'default': 'I will always be there for you.', }, }, } self.assertEquals(expected, configuration_dict['extensions'])
def test_should_dump_debug(self, debug: bool) -> None: with _build_minimal_configuration() as configuration: configuration.debug = debug configuration_dict = _to_dict(configuration) self.assertEquals(debug, configuration_dict['debug'])
def test_should_dump_clean_urls(self) -> None: clean_urls = True with _build_minimal_configuration() as configuration: configuration.clean_urls = clean_urls configuration_dict = _to_dict(configuration) self.assertEquals(clean_urls, configuration_dict['clean_urls'])
def test_should_dump_root_path(self) -> None: root_path = 'betty' with _build_minimal_configuration() as configuration: configuration.root_path = root_path configuration_dict = _to_dict(configuration) self.assertEquals(root_path, configuration_dict['root_path'])
def test_should_dump_author(self) -> None: author = 'Bart' with _build_minimal_configuration() as configuration: configuration.author = author configuration_dict = _to_dict(configuration) self.assertEquals(author, configuration_dict['author'])
def test_should_dump_title(self) -> None: title = 'My first Betty site' with _build_minimal_configuration() as configuration: configuration.title = title configuration_dict = _to_dict(configuration) self.assertEquals(title, configuration_dict['title'])