-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding expiremental zc.recipe.egg mocking
- Loading branch information
1 parent
ce570bb
commit 37cae39
Showing
13 changed files
with
146 additions
and
6 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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import os | ||
from .exceptions import CacheException | ||
|
||
DEFAULT_CACHE_DIRECTORY = ".cache" | ||
|
||
|
||
class Cache(object): | ||
""" TODO: create a way to cache downloaded data for uranium """ | ||
|
||
def __init__(self, path): | ||
self._path = path | ||
|
||
def ensure_directory(self): | ||
if os.path.isfile(self._path): | ||
raise CacheException("{0} needs to be a directory.".format( | ||
self._path | ||
)) | ||
|
||
if not os.path.exists(self._path): | ||
os.makedirs(self._path) |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class UraniumException(Exception): | ||
pass | ||
|
||
|
||
class CacheException(UraniumException): | ||
""" exception with the cache object """ | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
import shutil | ||
import tempfile | ||
from nose.tools import ok_, raises | ||
from uranium.cache import Cache | ||
from uranium.exceptions import CacheException | ||
|
||
|
||
class _TestCache(object): | ||
|
||
def setUp(self): | ||
self.temp_dir = tempfile.mkdtemp() | ||
|
||
def tearDown(self): | ||
shutil.rmtree(self.temp_dir) | ||
|
||
def test_ensure_directory(self): | ||
cache_dir = os.path.join(self.temp_dir, '.cache') | ||
cache = Cache(cache_dir) | ||
cache.ensure_directory() | ||
ok_(os.path.isdir(cache_dir)) | ||
|
||
def test_ensure_directory_already_exists(self): | ||
cache_dir = os.path.join(self.temp_dir, '.cache') | ||
os.makedirs(cache_dir) | ||
cache = Cache(cache_dir) | ||
cache.ensure_directory() | ||
ok_(os.path.isdir(cache_dir)) | ||
|
||
@raises(CacheException) | ||
def test_ensure_directory_with_file(self): | ||
""" | ||
if a file exists where the cache directory | ||
should be, raise an exception. | ||
""" | ||
cache_dir = os.path.join(self.temp_dir, '.cache') | ||
open(cache_dir, 'w+').close() | ||
cache = Cache(cache_dir) | ||
cache.ensure_directory() |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
tests for the warmup script | ||
""" | ||
import os | ||
import subprocess | ||
from uranium.tests.utils import FullUraniumBaseTest | ||
from nose.tools import eq_ | ||
|
||
BASE = os.path.dirname(__file__) | ||
URANIUM_ROOT_PATH = os.path.join(BASE, os.pardir, os.pardir, os.pardir) | ||
|
||
|
||
class TestDownloadPlugin(FullUraniumBaseTest): | ||
|
||
config = { | ||
'phases': { | ||
'after-eggs': ['node'] | ||
}, | ||
'parts': { | ||
'node': { | ||
'recipe': 'gp.recipe.node', | ||
'npms': """ | ||
wd | ||
appium@1.3.5 | ||
""".strip(), | ||
'scripts': 'appium', | ||
} | ||
} | ||
} | ||
|
||
def test_plugin_is_downloaded(self): | ||
""" | ||
ensure that a plugin is downloaded when it must be utilized. | ||
""" | ||
code = subprocess.check_call(['./bin/python', '-c', | ||
'import gp.recipe.node'], | ||
cwd=self.root) | ||
eq_(code, 0) |
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,7 +1,6 @@ | ||
import os | ||
import traceback | ||
|
||
|
||
def log_exception(logger, level): | ||
""" | ||
log an exception at a specific level | ||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
__import__('pkg_resources').declare_namespace(__name__) |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Scripts(object): | ||
""" | ||
a mock object for scripts, as a compatibliity | ||
measure. | ||
""" | ||
|
||
def __init__(self, buildout, name, options): | ||
pass | ||
|
||
def install(self): | ||
pass | ||
|
||
def update(self): | ||
pass |