(case_type, module)
return matches_regex and prevent_usercase_type
>>> from corehq.apps.app_manager.models import Module, AdvancedModule
    >>> is_valid_case_type('foo', Module())
    True
    >>> is_valid_case_type('foo-bar', Module())
    True
    >>> is_valid_case_type('foo bar', Module())
    False
    >>> is_valid_case_type('', Module())
    False
    >>> is_valid_case_type(None, Module())
    False
    >>> is_valid_case_type('commcare-user', Module())
    False
    >>> is_valid_case_type('commcare-user', AdvancedModule())
    True
>>> from corehq.apps.app_manager.models import Module, AdvancedModule
    >>> is_valid_case_type('foo', Module())
    True
    >>> is_valid_case_type('foo-bar', Module())
    True
    >>> is_valid_case_type('foo bar', Module())
    False
    >>> is_valid_case_type('', Module())
    False
    >>> is_valid_case_type(None, Module())
    False
    >>> is_valid_case_type('commcare-user', Module())
    False
    >>> is_valid_case_type('commcare-user', AdvancedModule())
    True
>>> from corehq . apps . app_manager . models import Module AdvancedModule >>> is_valid_case_type ( foo Module () ) True >>> is_valid_case_type ( foo - bar Module () ) True >>> is_valid_case_type ( foo bar Module () ) False >>> is_valid_case_type ( Module () ) False >>> is_valid_case_type ( None Module () ) False >>> is_valid_case_type ( commcare - user Module () ) False >>> is_valid_case_type ( commcare - user AdvancedModule () ) True
def is_valid_case_type(case_type, module):
    """
    >>> from corehq.apps.app_manager.models import Module, AdvancedModule
    >>> is_valid_case_type('foo', Module())
    True
    >>> is_valid_case_type('foo-bar', Module())
    True
    >>> is_valid_case_type('foo bar', Module())
    False
    >>> is_valid_case_type('', Module())
    False
    >>> is_valid_case_type(None, Module())
    False
    >>> is_valid_case_type('commcare-user', Module())
    False
    >>> is_valid_case_type('commcare-user', AdvancedModule())
    True
    """
    from corehq.apps.app_manager.models import AdvancedModule
    matches_regex = bool(_case_type_regex.match(case_type or ''))
    prevent_usercase_type = (case_type != USERCASE_TYPE or isinstance(module, AdvancedModule))
    return matches_regex and prevent_usercase_type
def is_valid_case_type ( case_type , module ) : from corehq . apps . app_manager . models import AdvancedModule matches_regex = bool ( _case_type_regex . match ( case_type or '' ) ) prevent_usercase_type = ( case_type != USERCASE_TYPE or isinstance ( module , AdvancedModule ) ) return matches_regex and prevent_usercase_type