예제 #1
0
 def test_flat_alias(self):
     f = fabfile("flat_alias.py")
     with path_prefix(f):
         docs, funcs = load_fabfile(f)
         eq_(len(funcs), 2)
         ok_("foo" in funcs)
         ok_("foo_aliased" in funcs)
예제 #2
0
 def test_flat_alias(self):
     f = fabfile("flat_alias.py")
     with path_prefix(f):
         docs, funcs = load_fabfile(f)
         eq_(len(funcs), 2)
         ok_("foo" in funcs)
         ok_("foo_aliased" in funcs)
예제 #3
0
 def test_nested_alias(self):
     f = fabfile("nested_alias.py")
     with path_prefix(f):
         docs, funcs = load_fabfile(f)
         ok_("nested" in funcs)
         eq_(len(funcs["nested"]), 2)
         ok_("foo" in funcs["nested"])
         ok_("foo_aliased" in funcs["nested"])
예제 #4
0
 def test_nested_alias(self):
     f = fabfile("nested_alias.py")
     with path_prefix(f):
         docs, funcs = load_fabfile(f)
         ok_("nested" in funcs)
         eq_(len(funcs["nested"]), 2)
         ok_("foo" in funcs["nested"])
         ok_("foo_aliased" in funcs["nested"])
예제 #5
0
 def test_class_based_tasks_are_found_with_proper_name(self):
     """
     Wrapped new-style tasks should preserve their function names
     """
     module = fabfile('decorated_fabfile_with_classbased_task.py')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         eq_(len(funcs), 1)
         ok_('foo' in funcs)
예제 #6
0
 def test_exception_exclusion(self):
     """
     Exception subclasses should not be considered as tasks
     """
     exceptions = fabfile("exceptions_fabfile.py")
     with path_prefix(exceptions):
         docs, funcs = load_fabfile(exceptions)
         ok_("some_task" in funcs)
         ok_("NotATask" not in funcs)
예제 #7
0
 def test_exception_exclusion(self):
     """
     Exception subclasses should not be considered as tasks
     """
     exceptions = fabfile("exceptions_fabfile.py")
     with path_prefix(exceptions):
         docs, funcs = load_fabfile(exceptions)
         ok_("some_task" in funcs)
         ok_("NotATask" not in funcs)
예제 #8
0
 def test_class_based_tasks_are_found_with_proper_name(self):
     """
     Wrapped new-style tasks should preserve their function names
     """
     module = fabfile('decorated_fabfile_with_classbased_task.py')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         eq_(len(funcs), 1)
         ok_('foo' in funcs)
예제 #9
0
 def test_newstyle_task_presence_skips_classic_task_modules(self):
     """
     Classic-task-only modules shouldn't add tasks if any new-style tasks exist
     """
     module = fabfile('deep')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         eq_(len(funcs), 1)
         ok_('submodule.classic_task' not in _task_names(funcs))
예제 #10
0
 def test_newstyle_task_presence_skips_classic_task_modules(self):
     """
     Classic-task-only modules shouldn't add tasks if any new-style tasks exist
     """
     module = fabfile('deep')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         eq_(len(funcs), 1)
         ok_('submodule.classic_task' not in _task_names(funcs))
예제 #11
0
 def test_recursion_steps_into_nontask_modules(self):
     """
     Recursive loading will continue through modules with no tasks
     """
     module = fabfile('deep')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         eq_(len(funcs), 1)
         ok_('submodule.subsubmodule.deeptask' in _task_names(funcs))
예제 #12
0
 def test_task_decorator_plays_well_with_others(self):
     """
     @task, when inside @hosts/@roles, should not hide the decorated task.
     """
     module = fabfile('decorator_order')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         # When broken, crawl() finds None for 'foo' instead.
         eq_(crawl('foo', funcs), funcs['foo'])
예제 #13
0
 def test_task_decorator_plays_well_with_others(self):
     """
     @task, when inside @hosts/@roles, should not hide the decorated task.
     """
     module = fabfile('decorator_order')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         # When broken, crawl() finds None for 'foo' instead.
         eq_(crawl('foo', funcs), funcs['foo'])
예제 #14
0
 def test_recursion_steps_into_nontask_modules(self):
     """
     Recursive loading will continue through modules with no tasks
     """
     module = fabfile('deep')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         eq_(len(funcs), 1)
         ok_('submodule.subsubmodule.deeptask' in _task_names(funcs))
예제 #15
0
 def test_should_load_decorated_tasks_only_if_one_is_found(self):
     """
     If any new-style tasks are found, *only* new-style tasks should load
     """
     module = fabfile('decorated_fabfile.py')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         eq_(len(funcs), 1)
         ok_('foo' in funcs)
예제 #16
0
 def test_should_load_decorated_tasks_only_if_one_is_found(self):
     """
     If any new-style tasks are found, *only* new-style tasks should load
     """
     module = fabfile('decorated_fabfile.py')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         eq_(len(funcs), 1)
         ok_('foo' in funcs)
예제 #17
0
 def test_explicit_discovery(self):
     """
     If __all__ is present, only collect the tasks it specifies
     """
     explicit = fabfile("explicit_fabfile.py")
     with path_prefix(explicit):
         docs, funcs = load_fabfile(explicit)
         eq_(len(funcs), 1)
         ok_("foo" in funcs)
         ok_("bar" not in funcs)
예제 #18
0
 def test_implicit_discovery(self):
     """
     Default to automatically collecting all tasks in a fabfile module
     """
     implicit = fabfile("implicit_fabfile.py")
     with path_prefix(implicit):
         docs, funcs = load_fabfile(implicit)
         eq_(len(funcs), 2)
         ok_("foo" in funcs)
         ok_("bar" in funcs)
예제 #19
0
 def test_implicit_discovery(self):
     """
     Default to automatically collecting all tasks in a fabfile module
     """
     implicit = fabfile("implicit_fabfile.py")
     with path_prefix(implicit):
         docs, funcs = load_fabfile(implicit)
         eq_(len(funcs), 2)
         ok_("foo" in funcs)
         ok_("bar" in funcs)
예제 #20
0
 def test_explicit_discovery(self):
     """
     If __all__ is present, only collect the tasks it specifies
     """
     explicit = fabfile("explicit_fabfile.py")
     with path_prefix(explicit):
         docs, funcs = load_fabfile(explicit)
         eq_(len(funcs), 1)
         ok_("foo" in funcs)
         ok_("bar" not in funcs)
예제 #21
0
 def test_class_based_tasks_are_found_with_variable_name(self):
     """
     A new-style tasks with undefined name attribute should use the instance
     variable name.
     """
     module = fabfile('classbased_task_fabfile.py')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         eq_(len(funcs), 1)
         ok_('foo' in funcs)
         eq_(funcs['foo'].name, 'foo')
예제 #22
0
 def test_class_based_tasks_are_found_with_variable_name(self):
     """
     A new-style tasks with undefined name attribute should use the instance
     variable name.
     """
     module = fabfile('classbased_task_fabfile.py')
     with path_prefix(module):
         docs, funcs = load_fabfile(module)
         eq_(len(funcs), 1)
         ok_('foo' in funcs)
         eq_(funcs['foo'].name, 'foo')
예제 #23
0
    def test_class_based_tasks_are_found_with_proper_name(self):
        """
        Wrapped new-style tasks should preserve their function names
        """
        module = fabfile("decorated_fabfile_with_classbased_task.py")
        from fabric.state import env

        with path_prefix(module):
            docs, funcs = load_fabfile(module)
            eq_(len(funcs), 1)
            ok_("foo" in funcs)
예제 #24
0
    def test_class_based_tasks_are_found_with_variable_name(self):
        """
        A new-style tasks with undefined name attribute should use the instance
        variable name.
        """
        module = fabfile("classbased_task_fabfile.py")
        from fabric.state import env

        with path_prefix(module):
            docs, funcs = load_fabfile(module)
            eq_(len(funcs), 1)
            ok_("foo" in funcs)
            eq_(funcs["foo"].name, "foo")
예제 #25
0
def test_default_task_loading():
    """
    crawl() should return default tasks where found, instead of module objs
    """
    docs, tasks = load_fabfile(fabfile('default_tasks'))
    ok_(isinstance(crawl('mymodule', tasks), Task))
예제 #26
0
def list_output(module, format_, expected):
    module = fabfile(module)
    with path_prefix(module):
        docstring, tasks = load_fabfile(module)
        with patched_context(fabric.state, 'commands', tasks):
            eq_output(docstring, format_, expected)
예제 #27
0
def list_output(module, format_, expected):
    module = fabfile(module)
    with path_prefix(module):
        docstring, tasks = load_fabfile(module)
        with patched_context(fabric.state, 'commands', tasks):
            eq_output(docstring, format_, expected)
예제 #28
0
def test_default_task_loading():
    """
    crawl() should return default tasks where found, instead of module objs
    """
    docs, tasks = load_fabfile(fabfile('default_tasks'))
    ok_(isinstance(crawl('mymodule', tasks), Task))