Open bitprophet opened 13 years ago
Morgan Goose (goosemo) posted:
Here is a first go at me testing, it's only doing exists, and it's not really testing it, but as it's using SFTP().exists() when I get #334 in this will work with the exists check I've commented out
from __future__ import with_statement import os import shutil import sys import tempfile import types from contextlib import nested from StringIO import StringIO from nose.tools import raises, eq_ from fudge import with_patched_object from fabric.state import env from fabric.operations import require, prompt, _sudo_prefix, _shell_wrap, \ _shell_escape from fabric.api import get, put, hide, show, cd, lcd, local from fabric.contrib.files import exists from fabric.sftp import SFTP from utils import * from server import (server, PORT, RESPONSES, FILES, PASSWORDS, CLIENT_PRIVKEY, USER, CLIENT_PRIVKEY_PASSPHRASE) class TestContribFiles(FabricTest): def setup(self): super(TestContribFiles, self).setup() self.tmpdir = tempfile.mkdtemp() def teardown(self): super(TestContribFiles, self).teardown() shutil.rmtree(self.tmpdir) def path(self, *path_parts): return os.path.join(self.tmpdir, *path_parts) def exists_remotely(self, path): return SFTP(env.host_string).exists(path) def exists_locally(self, path): return os.path.exists(path) @server() def test_file_exists(self): """ exists() with a single non-globbed filename """ remote = '/file.txt' with hide('everything'): #assert exists(remote) assert SFTP(env.host_string).exists(remote)
on 2011-04-05 at 05:31pm EDT
Description
I feel that this is the simplest contrib to get into and start writing some tests for. While not required, since they aren't core, it'd be nice to have some, since more people are relying on them.
Originally submitted by Morgan Goose (goosemo) on 2011-04-05 at 05:29pm EDT
Relations