def test_processing_of_enabled_statements( self, test_config_directory, ): enabled_modules = EnabledModules([], Path('/'), Path('/')) enabled = sorted( map( lambda x: tuple(x.items()), enabled_modules.process_enabling_statements( enabling_statements=[ { 'name': '*::*' }, ], modules_directory=test_config_directory / 'freezed_modules', ), )) expected = sorted( map( lambda x: tuple(x.items()), [{ 'name': 'north_america::*' }, { 'name': 'south_america::*' }], )) assert enabled == expected assert enabled_modules.all_directory_modules_enabled is True assert enabled_modules.all_global_modules_enabled is False
def test_enabled_detection( self, test_config_directory, caplog, delete_jakobgm, ): enabling_statements = [ { 'name': 'global' }, { 'name': 'south_america::*' }, { 'name': 'github::jakobgm/test-module.astrality' }, { 'name': 'invalid_syntax]][[' }, ] enabled_modules = EnabledModules( enabling_statements=enabling_statements, config_directory=test_config_directory, modules_directory=test_config_directory / 'freezed_modules', ) for sources in enabled_modules.source_types.values(): assert len(sources) == 1 assert ( 'astrality.config', logging.ERROR, RegexCompare(r'Invalid module name syntax.+'), ) in caplog.record_tuples enabled_modules.compile_config_files({}) assert 'global' in enabled_modules assert 'south_america::brazil' in enabled_modules assert 'south_america::argentina' in enabled_modules assert 'github::jakobgm/test-module.astrality::botswana' \ in enabled_modules assert 'github::jakobgm/test-module.astrality::ghana' in enabled_modules assert 'not_enabled' not in enabled_modules assert 'non_existing_folder::non_existing_module' not in enabled_modules assert 'github::user/not_enabled' not in enabled_modules
def test_processing_of_enabled_statements( self, test_config_directory, ): enabled_modules = EnabledModules([], Path('/'), Path('/')) assert enabled_modules.process_enabling_statements( enabling_statements=[{ 'name': '*::*' }], modules_directory=test_config_directory / 'freezed_modules', ) == [{ 'name': 'north_america::*' }, { 'name': 'south_america::*' }] assert enabled_modules.all_directory_modules_enabled == True assert enabled_modules.all_global_modules_enabled == False
def test_detection_of_all_module_directories_within_a_directory( self, test_config_directory, ): assert tuple( EnabledModules.module_directories(within=test_config_directory / 'freezed_modules', )) == ( 'north_america', 'south_america', )
def test_enabled_detection_with_global_wildcard(self): enabling_statements = [ { 'name': '*' }, ] enabled_modules = EnabledModules( enabling_statements=enabling_statements, config_directory=Path('/'), modules_directory=Path('/'), ) assert 'global' in enabled_modules assert 'whatever' in enabled_modules assert 'south_america::brazil' not in enabled_modules assert 'south_america::argentina' not in enabled_modules assert 'github::jakobgm/color_schemes.astrality' not in enabled_modules