-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix file path munging and add another test
Re #273
- Loading branch information
1 parent
cd25547
commit d7470d2
Showing
2 changed files
with
39 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
from __future__ import with_statement | ||
|
||
from fabric.api import hide, get, show | ||
from fabric.contrib.files import upload_template | ||
|
||
from utils import FabricTest | ||
from utils import FabricTest, eq_contents | ||
from server import server | ||
|
||
|
||
class TestContrib(FabricTest): | ||
@server() | ||
# Make sure it knows / is a directory. | ||
# This is in lieu of starting down the "actual honest to god fake operating | ||
# system" road...:( | ||
@server(responses={'test -d /': ""}) | ||
def test_upload_template_uses_correct_remote_filename(self): | ||
""" | ||
upload_template() shouldn't munge final remote filename | ||
""" | ||
template = self.mkfile('template.txt', 'text') | ||
upload_template(template, '/') | ||
assert self.exists_remotely('/template.txt') | ||
with hide('everything'): | ||
upload_template(template, '/') | ||
assert self.exists_remotely('/template.txt') | ||
|
||
@server() | ||
def test_upload_template_handles_file_destination(self): | ||
""" | ||
upload_template() should work OK with file and directory destinations | ||
""" | ||
template = self.mkfile('template.txt', '%(varname)s') | ||
local = self.path('result.txt') | ||
remote = '/configfile.txt' | ||
var = 'foobar' | ||
with hide('everything'): | ||
upload_template(template, remote, {'varname': var}) | ||
get(remote, local) | ||
eq_contents(local, var) |