Example #1
0
 def testUse_create_doit_tasks(self):
     def original(): pass
     def creator():
         return {'actions': ['do nothing'], 'file_dep': ['foox']}
     original.create_doit_tasks = creator
     task_list = load_tasks({'x': original})
     assert 1 == len(task_list)
     assert set(['foox']) == task_list[0].file_dep
Example #2
0
    def testUse_create_doit_tasks_only_noargs_call(self):
        class Foo(object):
            def create_doit_tasks(self):
                return {'actions': ['do nothing'], 'file_dep': ['fooy']}

        task_list = load_tasks({'Foo':Foo, 'foo':Foo()})
        assert len(task_list) == 1
        assert task_list[0].file_dep == set(['fooy'])
Example #3
0
    def testUse_create_doit_tasks_only_noargs_call(self):
        class Foo(object):
            def create_doit_tasks(self):
                return {'actions': ['do nothing'], 'file_dep': ['fooy']}

        task_list = load_tasks({'Foo':Foo, 'foo':Foo()})
        assert len(task_list) == 1
        assert task_list[0].file_dep == set(['fooy'])
Example #4
0
 def testUse_create_doit_tasks(self):
     def original(): pass
     def creator():
         return {'actions': ['do nothing'], 'file_dep': ['foox']}
     original.create_doit_tasks = creator
     task_list = load_tasks({'x': original})
     assert 1 == len(task_list)
     assert set(['foox']) == task_list[0].file_dep
Example #5
0
    def testUse_create_doit_tasks_only_noargs_call(self):
        class Foo(object):
            def create_doit_tasks(self):
                return {"actions": ["do nothing"], "file_dep": ["fooy"]}

        task_list = load_tasks({"Foo": Foo, "foo": Foo()})
        assert len(task_list) == 1
        assert task_list[0].file_dep == set(["fooy"])
Example #6
0
    def testInitialLoadDelayedTask(self, dodo):
        @create_after('yyy2')
        def task_zzz3(): # pragma: no cover
            raise Exception('Cant be executed on load phase')
        dodo['task_zzz3'] = task_zzz3

        # placeholder task is created with `loader` attribute
        task_list = load_tasks(dodo, allow_delayed=True)
        z_task = [t for t in task_list if t.name=='zzz3'][0]
        assert z_task.loader.task_dep == 'yyy2'
        assert z_task.loader.creator == task_zzz3
Example #7
0
    def testUse_create_doit_tasks(self):
        def original():
            pass

        def creator():
            return {"actions": ["do nothing"], "file_dep": ["foox"]}

        original.create_doit_tasks = creator
        task_list = load_tasks({"x": original})
        assert 1 == len(task_list)
        assert set(["foox"]) == task_list[0].file_dep
Example #8
0
    def testInitialLoadDelayedTask(self, dodo):
        @doit.create_after('yyy2')
        def task_zzz3(): # pragma: no cover
            raise Exception('Cant be executed on load phase')
        dodo['task_zzz3'] = task_zzz3

        # placeholder task is created with `loader` attribute
        task_list = load_tasks(dodo, allow_delayed=True)
        z_task = [t for t in task_list if t.name=='zzz3'][0]
        assert z_task.loader.task_dep == 'yyy2'
        assert z_task.loader.creator == task_zzz3
Example #9
0
    def testInitialLoadDelayedTask_no_delayed(self, dodo):
        @create_after('yyy2')
        def task_zzz3():
            yield {'basename': 'foo', 'actions': None}
            yield {'basename': 'bar', 'actions': None}
        dodo['task_zzz3'] = task_zzz3

        # load tasks as done by the `list` command
        task_list = load_tasks(dodo, allow_delayed=False)
        tasks = {t.name:t for t in task_list}
        assert 'zzz3' not in tasks
        assert tasks['foo'].loader is None
        assert tasks['bar'].loader is None
Example #10
0
    def testInitialLoadDelayedTask_creates(self, dodo):
        @create_after('yyy2', creates=['foo', 'bar'])
        def task_zzz3():  # pragma: no cover
            '''not loaded task doc'''
            raise Exception('Cant be executed on load phase')

        dodo['task_zzz3'] = task_zzz3

        # placeholder task is created with `loader` attribute
        task_list = load_tasks(dodo, allow_delayed=True)
        tasks = {t.name: t for t in task_list}
        assert 'zzz3' not in tasks
        f_task = tasks['foo']
        assert f_task.loader.task_dep == 'yyy2'
        assert f_task.loader.creator == task_zzz3
        assert tasks['bar'].loader.task_dep == tasks['foo'].loader.task_dep
        assert tasks['foo'].doc == 'not loaded task doc'

        # make sure doit can be executed more then once in single process GH#381
        list2 = load_tasks(dodo, allow_delayed=True)
        tasks2 = {t.name: t for t in list2}
        assert tasks['bar'].loader is not tasks2['bar'].loader
Example #11
0
 def _get_task_list(self):
     namespace = importlib.import_module(self._dodo_fn[:-3])
     if inspect.ismodule(namespace):
         members = dict(inspect.getmembers(namespace))
     else:
         members = namespace
     task_list = tuple(task for task in loader.load_tasks(members)
                       if not task.has_subtask)
     for task in task_list:
         task.name = self._wrap_name(task.name)
         task.file_dep = {self._wrap_name(fn) for fn in task.file_dep}
         task.targets = tuple(self._wrap_name(fn) for fn in task.targets)
     return task_list
Example #12
0
    def testInitialLoadDelayedTask_no_delayed(self, dodo):
        @create_after('yyy2')
        def task_zzz3():
            yield {'basename': 'foo', 'actions': None}
            yield {'basename': 'bar', 'actions': None}
        dodo['task_zzz3'] = task_zzz3

        # load tasks as done by the `list` command
        task_list = load_tasks(dodo, allow_delayed=False)
        tasks = {t.name:t for t in task_list}
        assert 'zzz3' not in tasks
        assert tasks['foo'].loader is None
        assert tasks['bar'].loader is None
Example #13
0
    def testInitialLoadDelayedTask_creates(self, dodo):
        @create_after('yyy2', creates=['foo', 'bar'])
        def task_zzz3(): # pragma: no cover
            raise Exception('Cant be executed on load phase')
        dodo['task_zzz3'] = task_zzz3

        # placeholder task is created with `loader` attribute
        task_list = load_tasks(dodo, allow_delayed=True)
        tasks = {t.name:t for t in task_list}
        assert 'zzz3' not in tasks
        f_task = tasks['foo']
        assert f_task.loader.task_dep == 'yyy2'
        assert f_task.loader.creator == task_zzz3
        assert tasks['bar'].loader is tasks['foo'].loader
Example #14
0
    def testUse_object_methods(self):
        class Dodo(object):
            def foo(self): # pragma: no cover
                pass

            def task_method1(self):
                return {'actions':None}

            def task_method2(self):
                return {'actions':None}

        methods = dict(inspect.getmembers(Dodo()))
        task_list = load_tasks(methods)
        assert 2 == len(task_list)
        assert 'method1' == task_list[0].name
        assert 'method2' == task_list[1].name
Example #15
0
    def testUse_object_methods(self):
        class Dodo(object):
            def foo(self): # pragma: no cover
                pass

            def task_method1(self):
                return {'actions':None}

            def task_method2(self):
                return {'actions':None}

        methods = dict(inspect.getmembers(Dodo()))
        task_list = load_tasks(methods)
        assert 2 == len(task_list)
        assert 'method1' == task_list[0].name
        assert 'method2' == task_list[1].name
Example #16
0
    def testInitialLoadDelayedTask_creates(self, dodo):
        @create_after('yyy2', creates=['foo', 'bar'])
        def task_zzz3():  # pragma: no cover
            '''my task doc'''
            raise Exception('Cant be executed on load phase')

        dodo['task_zzz3'] = task_zzz3

        # placeholder task is created with `loader` attribute
        task_list = load_tasks(dodo, allow_delayed=True)
        tasks = {t.name: t for t in task_list}
        assert 'zzz3' not in tasks
        f_task = tasks['foo']
        assert f_task.loader.task_dep == 'yyy2'
        assert f_task.loader.creator == task_zzz3
        assert tasks['bar'].loader is tasks['foo'].loader
        assert tasks['foo'].doc == 'my task doc'
Example #17
0
 def testNormalCase(self, dodo):
     task_list = load_tasks(dodo)
     assert 2 == len(task_list)
     assert 'xxx1' == task_list[0].name
     assert 'yyy2' == task_list[1].name
Example #18
0
 def testNormalCase(self, dodo):
     task_list = load_tasks(dodo)
     assert 2 == len(task_list)
     assert 'xxx1' == task_list[0].name
     assert 'yyy2' == task_list[1].name
Example #19
0
 def testDocString(self, dodo):
     task_list = load_tasks(dodo)
     assert "task doc" == task_list[0].doc
Example #20
0
 def testDocString(self, dodo):
     task_list = load_tasks(dodo)
     assert "task doc" == task_list[0].doc