Exemple #1
0
 def setup(self):
     mod = load('explicit_root')
     mod.ns.configure({'key': 'builtin', 'otherkey': 'yup'})
     mod.ns.name = 'builtin_name'
     self.unchanged = Collection.from_module(mod)
     self.changed = Collection.from_module(
         mod, name='override_name', config={'key': 'override'})
Exemple #2
0
 def setup(self):
     mod = load('explicit_root')
     mod.ns.configure({'key': 'builtin', 'otherkey': 'yup'})
     mod.ns.name = 'builtin_name'
     self.unchanged = Collection.from_module(mod)
     self.changed = Collection.from_module(
         mod,
         name='override_name',
         config={'key': 'override'}
     )
Exemple #3
0
 def returns_unique_Collection_objects_for_same_input_module(self):
     # Ignoring self.c for now, just in case it changes later.
     # First, a module with no root NS
     mod = load('integration')
     c1 = Collection.from_module(mod)
     c2 = Collection.from_module(mod)
     assert c1 is not c2
     # Now one *with* a root NS (which was previously buggy)
     mod2 = load('explicit_root')
     c3 = Collection.from_module(mod2)
     c4 = Collection.from_module(mod2)
     assert c3 is not c4
Exemple #4
0
 def returns_unique_Collection_objects_for_same_input_module(self):
     # Ignoring self.c for now, just in case it changes later.
     # First, a module with no root NS
     mod = load('integration')
     c1 = Collection.from_module(mod)
     c2 = Collection.from_module(mod)
     assert c1 is not c2
     # Now one *with* a root NS (which was previously buggy)
     mod2 = load('explicit_root')
     c3 = Collection.from_module(mod2)
     c4 = Collection.from_module(mod2)
     assert c3 is not c4
Exemple #5
0
 def honors_subcollection_default_tasks_on_subcollection_name(self):
     sub = Collection.from_module(load("decorators"))
     self.c.add_collection(sub)
     # Sanity
     assert self.c["decorators.biz"] is sub["biz"]
     # Real test
     assert self.c["decorators"] is self.c["decorators.biz"]
Exemple #6
0
 def honors_subcollection_default_tasks_on_subcollection_name(self):
     sub = Collection.from_module(load('decorator'))
     self.c.add_collection(sub)
     # Sanity
     assert self.c['decorator.biz'] is sub['biz']
     # Real test
     assert self.c['decorator'] is self.c['decorator.biz']
Exemple #7
0
 def submodule_names_are_stripped_to_last_chunk(self):
     with support_path():
         from package import module
     c = Collection.from_module(module)
     assert module.__name__ == "package.module"
     assert c.name == "module"
     assert "mytask" in c  # Sanity
Exemple #8
0
        def name_docstring_default_and_tasks(self):
            expected = dict(
                name="deploy",
                help="How to deploy our code and configs.",
                tasks=[
                    dict(
                        name="db",
                        help="Deploy to our database servers.",
                        aliases=["db-servers"],
                    ),
                    dict(
                        name="everywhere",
                        help="Deploy to all targets.",
                        aliases=[],
                    ),
                    dict(
                        name="web",
                        help="Update and bounce the webservers.",
                        aliases=[],
                    ),
                ],
                default="everywhere",
                collections=[],
            )
            with support_path():
                from tree import deploy

                coll = Collection.from_module(deploy)
            assert expected == coll.serialized()
Exemple #9
0
 def submodule_names_are_stripped_to_last_chunk(self):
     with support_path():
         from package import module
     c = Collection.from_module(module)
     eq_(module.__name__, 'package.module')
     eq_(c.name, 'module')
     assert 'mytask' in c # Sanity
Exemple #10
0
 def name_docstring_default_and_tasks(self):
     expected = dict(
         name="deploy",
         help="How to deploy our code and configs.",
         tasks=[
             dict(
                 name="db",
                 help="Deploy to our database servers.",
                 aliases=["db-servers"],
             ),
             dict(
                 name="everywhere",
                 help="Deploy to all targets.",
                 aliases=[],
             ),
             dict(
                 name="web",
                 help="Update and bounce the webservers.",
                 aliases=[],
             ),
         ],
         default="everywhere",
         collections=[],
     )
     with support_path():
         from tree import deploy
         coll = Collection.from_module(deploy)
     assert expected == coll.serialized()
Exemple #11
0
 def submodule_names_are_stripped_to_last_chunk(self):
     with support_path():
         from package import module
     c = Collection.from_module(module)
     assert module.__name__ == 'package.module'
     assert c.name == 'module'
     assert 'mytask' in c # Sanity
Exemple #12
0
 def honors_subcollection_default_tasks_on_subcollection_name(self):
     sub = Collection.from_module(load('decorators'))
     self.c.add_collection(sub)
     # Sanity
     assert self.c['decorators.biz'] is sub['biz']
     # Real test
     assert self.c['decorators'] is self.c['decorators.biz']
Exemple #13
0
        def name_docstring_default_tasks_and_collections(self):
            docs = dict(
                name="docs",
                help="Tasks for managing Sphinx docs.",
                tasks=[
                    dict(name="all", help="Build all doc formats.",
                         aliases=[]),
                    dict(name="html",
                         help="Build HTML output only.",
                         aliases=[]),
                    dict(name="pdf", help="Build PDF output only.",
                         aliases=[]),
                ],
                default="all",
                collections=[],
            )
            python = dict(
                name="python",
                help="PyPI/etc distribution artifacts.",
                tasks=[
                    dict(
                        name="all",
                        help="Build all Python packages.",
                        aliases=[],
                    ),
                    dict(
                        name="sdist",
                        help="Build classic style tar.gz.",
                        aliases=[],
                    ),
                    dict(name="wheel", help="Build a wheel.", aliases=[]),
                ],
                default="all",
                collections=[],
            )
            expected = dict(
                name="build",
                help="Tasks for compiling static code and assets.",
                tasks=[
                    dict(
                        name="all",
                        help="Build all necessary artifacts.",
                        aliases=["everything"],
                    ),
                    dict(
                        name="c-ext",
                        help="Build our internal C extension.",
                        aliases=["ext"],
                    ),
                    dict(name="zap", help="A silly way to clean.", aliases=[]),
                ],
                default="all",
                collections=[docs, python],
            )
            with support_path():
                from tree import build

                coll = Collection.from_module(build)
            assert expected == coll.serialized()
Exemple #14
0
 def invalid_path(self):
     # This is really just testing Lexicon/dict behavior but w/e, good
     # to be explicit, esp if we ever want this to become Exit or
     # another custom exception. (For now most/all callers manually
     # catch KeyError and raise Exit just to keep most Exit use high up
     # in the stack...)
     with raises(KeyError):
         collection = Collection.from_module(load("tree"))
         collection.subcollection_from_path("lol.whatever.man")
Exemple #15
0
 def invalid_path(self):
     # This is really just testing Lexicon/dict behavior but w/e, good
     # to be explicit, esp if we ever want this to become Exit or
     # another custom exception. (For now most/all callers manually
     # catch KeyError and raise Exit just to keep most Exit use high up
     # in the stack...)
     with raises(KeyError):
         collection = Collection.from_module(load('tree'))
         collection.subcollection_from_path('lol.whatever.man')
Exemple #16
0
 def setup(self):
     mod = load("explicit_root")
     mod.ns.configure(
         {
             "key": "builtin",
             "otherkey": "yup",
             "subconfig": {"mykey": "myvalue"},
         }
     )
     mod.ns.name = "builtin_name"
     self.unchanged = Collection.from_module(mod)
     self.changed = Collection.from_module(
         mod,
         name="override_name",
         config={
             "key": "override",
             "subconfig": {"myotherkey": "myothervalue"},
         },
     )
Exemple #17
0
def is_valid_package(package_name):
    """
    Checks if a package at site directory has tasks.
    """
    try:
        apackage = import_module('%s.tasks'%package_name)
    except ImportError:
        return False
    tasks = Collection.from_module(apackage).task_names
    if tasks == {}:
        return False
    return True
Exemple #18
0
def is_valid_package(package_name):
    """
    Checks if a package at site directory has tasks.
    """
    try:
        apackage = import_module('%s.tasks' % package_name)
    except ImportError:
        return False
    tasks = Collection.from_module(apackage).task_names
    if tasks == {}:
        return False
    return True
Exemple #19
0
 def setup(self):
     mod = load("explicit_root")
     mod.ns.configure({
         "key": "builtin",
         "otherkey": "yup",
         "subconfig": {
             "mykey": "myvalue"
         },
     })
     mod.ns.name = "builtin_name"
     self.unchanged = Collection.from_module(mod)
     self.changed = Collection.from_module(
         mod,
         name="override_name",
         config={
             "key": "override",
             "subconfig": {
                 "myotherkey": "myothervalue"
             },
         },
     )
Exemple #20
0
def run_easypy_task(argv):
    """
    Run task in easypy.
    """
    from easypy import tasks
    tasks = Collection.from_module(tasks).task_names
    if len(argv) == 1:
        # the request is in the format $ py
        # display available tasks in easypy
        display_easypy_tasks()
    else:
        # the request is in the format $ py <task>
        task = argv[1]
        if not task in tasks.keys():
            raise TaskNotAvailable(task)
        cli.dispatch(prepare_args(argv))
Exemple #21
0
def run_easypy_task(argv):
    """
    Run task in easypy.
    """
    from easypy import tasks
    tasks = Collection.from_module(tasks).task_names
    if len(argv) == 1:
        # the request is in the format $ py
        # display available tasks in easypy
        display_easypy_tasks()
    else:
        # the request is in the format $ py <task>
        task = argv[1]
        if not task in tasks.keys():
            raise TaskNotAvailable(task)
        cli.dispatch(prepare_args(argv))
Exemple #22
0
 def transforms_are_applied_to_explicit_module_namespaces(self):
     # Symptom when bug present: Collection.to_contexts() dies
     # because it iterates over .task_names (transformed) and then
     # tries to use results to access __getitem__ (no auto
     # transform...because in all other situations, task structure
     # keys are already transformed; but this wasn't the case for
     # from_module() with explicit 'ns' objects!)
     namespace = self._nested_underscores()
     class FakeModule(object):
         __name__ = 'my_module'
         ns = namespace
     coll = Collection.from_module(
         FakeModule(), auto_dash_names=False
     )
     # NOTE: underscores, not dashes
     expected = {'my_task', 'inner_coll.inner_task'}
     assert {x.name for x in coll.to_contexts()} == expected
Exemple #23
0
            def transforms_are_applied_to_explicit_module_namespaces(self):
                # Symptom when bug present: Collection.to_contexts() dies
                # because it iterates over .task_names (transformed) and then
                # tries to use results to access __getitem__ (no auto
                # transform...because in all other situations, task structure
                # keys are already transformed; but this wasn't the case for
                # from_module() with explicit 'ns' objects!)
                namespace = self._nested_underscores()

                class FakeModule(object):
                    __name__ = 'my_module'
                    ns = namespace

                coll = Collection.from_module(FakeModule(),
                                              auto_dash_names=False)
                # NOTE: underscores, not dashes
                expected = set(['my_task', 'inner_coll.inner_task'])
                assert set(x.name for x in coll.to_contexts()) == expected
Exemple #24
0
 def nested_path(self):
     collection = Collection.from_module(load('tree'))
     docs = collection.collections['build'].collections['docs']
     assert collection.subcollection_from_path('build.docs') is docs
Exemple #25
0
 def top_level_path(self):
     collection = Collection.from_module(load('tree'))
     build = collection.collections['build']
     assert collection.subcollection_from_path('build') is build
Exemple #26
0
 def setup(self):
     self.c = Collection.from_module(load('explicit_root'))
Exemple #27
0
 def top_level_path(self):
     collection = Collection.from_module(load('tree'))
     build = collection.collections['build']
     assert collection.subcollection_from_path('build') is build
Exemple #28
0
 def setup(self):
     self.c = Collection.from_module(load('integration'))
Exemple #29
0
 def nested_path(self):
     collection = Collection.from_module(load('tree'))
     docs = collection.collections['build'].collections['docs']
     assert collection.subcollection_from_path('build.docs') is docs
Exemple #30
0
 def allows_tasks_with_explicit_names_to_override_bound_name(self):
     coll = Collection.from_module(load('subcollection_task_name'))
     assert 'explicit-name' in coll.tasks # not 'implicit_name'
Exemple #31
0
 def top_level_path(self):
     collection = Collection.from_module(load("tree"))
     build = collection.collections["build"]
     assert collection.subcollection_from_path("build") is build
Exemple #32
0
 def nested_path(self):
     collection = Collection.from_module(load("tree"))
     docs = collection.collections["build"].collections["docs"]
     assert collection.subcollection_from_path("build.docs") is docs
Exemple #33
0
 def honors_explicit_collections(self):
     coll = Collection.from_module(load('explicit_root'))
     assert 'top-level' in coll.tasks
     assert 'sub-level' in coll.collections
     # The real key test
     assert 'sub-task' not in coll.tasks
Exemple #34
0
 def setup(self):
     self.c = Collection.from_module(load('integration'))
Exemple #35
0
 def honors_explicit_collections(self):
     coll = Collection.from_module(load('explicit_root'))
     assert 'top_level' in coll.tasks
     assert 'sub' in coll.collections
     # The real key test
     assert 'sub_task' not in coll.tasks
Exemple #36
0
 def allows_tasks_with_explicit_names_to_override_bound_name(self):
     coll = Collection.from_module(load('subcollection_task_name'))
     assert 'explicit-name' in coll.tasks  # not 'implicit_name'
Exemple #37
0
 def nested_path(self):
     collection = Collection.from_module(load("tree"))
     docs = collection.collections["build"].collections["docs"]
     assert collection.subcollection_from_path("build.docs") is docs
Exemple #38
0
 def top_level_path(self):
     collection = Collection.from_module(load("tree"))
     build = collection.collections["build"]
     assert collection.subcollection_from_path("build") is build
Exemple #39
0
 def name_docstring_default_tasks_and_collections(self):
     docs = dict(
         name="docs",
         help="Tasks for managing Sphinx docs.",
         tasks=[
             dict(
                 name="all",
                 help="Build all doc formats.",
                 aliases=[],
             ),
             dict(
                 name="html",
                 help="Build HTML output only.",
                 aliases=[],
             ),
             dict(
                 name="pdf",
                 help="Build PDF output only.",
                 aliases=[],
             ),
         ],
         default="all",
         collections=[],
     )
     python = dict(
         name="python",
         help="PyPI/etc distribution artifacts.",
         tasks=[
             dict(
                 name="all",
                 help="Build all Python packages.",
                 aliases=[],
             ),
             dict(
                 name="sdist",
                 help="Build classic style tar.gz.",
                 aliases=[],
             ),
             dict(
                 name="wheel",
                 help="Build a wheel.",
                 aliases=[],
             ),
         ],
         default="all",
         collections=[],
     )
     expected = dict(
         name="build",
         help="Tasks for compiling static code and assets.",
         tasks=[
             dict(
                 name="all",
                 help="Build all necessary artifacts.",
                 aliases=["everything"],
             ),
             dict(
                 name="c-ext",
                 help="Build our internal C extension.",
                 aliases=["ext"],
             ),
             dict(
                 name="zap",
                 help="A silly way to clean.",
                 aliases=[],
             ),
         ],
         default="all",
         collections=[docs, python],
     )
     with support_path():
         from tree import build
         coll = Collection.from_module(build)
     assert expected == coll.serialized()
Exemple #40
0
 def honors_explicit_collections(self):
     coll = Collection.from_module(load("explicit_root"))
     assert "top-level" in coll.tasks
     assert "sub-level" in coll.collections
     # The real key test
     assert "sub-task" not in coll.tasks
Exemple #41
0
 def honors_explicit_collections(self):
     coll = Collection.from_module(load("explicit_root"))
     assert "top-level" in coll.tasks
     assert "sub-level" in coll.collections
     # The real key test
     assert "sub-task" not in coll.tasks
Exemple #42
0
 def setup(self):
     self.c = Collection.from_module(load('explicit_root'))