Skip to content

Commit

Permalink
Add a test class for fabfile finding
Browse files Browse the repository at this point in the history
This newly-added class is mainly for Fabric's fabfile discovery
mechanism testing.

While it may be expanded in the future, initially it only contains
three package-discovery related tests.
  • Loading branch information
oldsharp authored and bitprophet committed Apr 24, 2017
1 parent 7dd8c0c commit 47afc39
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import copy
from functools import partial
from operator import isMappingType
import os.path
import sys

from fudge import Fake, patched_context
from nose.tools import ok_, eq_

from fabric.decorators import hosts, roles, task
from fabric.context_managers import settings
from fabric.main import (parse_arguments, _escape_split,
from fabric.main import (parse_arguments, _escape_split, find_fabfile,
load_fabfile as _load_fabfile, list_commands, _task_names,
COMMANDS_HEADER, NESTED_REMINDER)
import fabric.state
Expand Down Expand Up @@ -359,6 +360,33 @@ def command():
eq_hosts(command, ['a', 'b'], env={'roledefs': lazy_role})


#
# Fabfile finding
#

class TestFindFabfile(FabricTest):
"""Test Fabric's fabfile discovery mechanism."""
def test_find_fabfile_can_discovery_package(self):
"""Fabric should be capable of loading a normal package."""
path = self.mkfile("__init__.py", "")
name = os.path.dirname(path)
assert find_fabfile([name,]) is not None

def test_find_fabfile_can_discovery_package_with_pyc_only(self):
"""
Fabric should be capable of loading a package with __init__.pyc only.
"""
path = self.mkfile("__init__.pyc", "")
name = os.path.dirname(path)
assert find_fabfile([name,]) is not None

def test_find_fabfile_should_refuse_fake_package(self):
"""Fabric should refuse to load a non-package directory."""
path = self.mkfile("foo.py", "")
name = os.path.dirname(path)
assert find_fabfile([name,]) is None


#
# Fabfile loading
#
Expand Down

0 comments on commit 47afc39

Please sign in to comment.