Skip to content

Commit

Permalink
full tests can now be run.
Browse files Browse the repository at this point in the history
  • Loading branch information
toumorokoshi committed Jan 29, 2015
1 parent 7b8c44f commit 257b931
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 16 deletions.
4 changes: 1 addition & 3 deletions scripts/uranium
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@ def _install_uranium(virtualenv_dir, uranium_dir=None, version=None):
uranium_name = 'uranium=={0}'.format(version)

with open(log_file, 'w+') as fh:
#status = subprocess.call([pip_executable, 'install', uranium_name,
# '--upgrade'], stdout=fh, stderr=fh)
status = subprocess.call([pip_executable, 'install', uranium_name,
'--upgrade'])
'--upgrade'], stdout=fh, stderr=fh)
if status:
LOGGER.error("Unable to install uranium. please look at {0} for more info".format(
log_file
Expand Down
34 changes: 34 additions & 0 deletions uranium/tests/test_full/test_download_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
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': ['unit']
},
'parts': {
'unit': {
'recipe': 'yt.recipe.shell',
'script': '',
'name': 'unit'
}
}
}

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 yt.recipe'],
cwd=self.root)
eq_(code, 0)
23 changes: 11 additions & 12 deletions uranium/tests/test_full/test_egg_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@
"""
import os
import subprocess
from uranium.tests.utils import WarmupBaseTest
from nose.tools import ok_
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 TestEggResolution(WarmupBaseTest):
class TestEggResolution(FullUraniumBaseTest):

config = {
'eggs': {
'uranium': '== 0.0.10'
'requests': '==2.3.0'
},
'develop-eggs': [
URANIUM_ROOT_PATH
],
'versions': {
'uranium': '== 0.0.9'
'uranium': '==2.5.1'
}
}

def test_develop_egg_resolution(self):
def test_egg_resolution(self):
"""
ensure that develop eggs take precedence over
regular specs or version specs
ensure that egg version take precedence version specs
"""
ok_(not subprocess.call([self.warmup_file_path], cwd=self.root))
output = subprocess.check_output(['./bin/python', '-c', 'import requests; print(requests.__version__)'],
cwd=self.root)
output = output.decode('ascii').strip()
eq_(output, '2.3.0')
33 changes: 32 additions & 1 deletion uranium/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import shutil
import subprocess
import tempfile
import yaml
from nose.plugins.attrib import attr
Expand All @@ -9,6 +10,7 @@

BASE = os.path.dirname(__file__)
WARMUP_SCRIPT_PATH = os.path.join(BASE, os.pardir, os.pardir, 'scripts', 'uranium')
URANIUM_BASE_PATH = os.path.join(BASE, os.pardir, os.pardir)


def get_valid_config():
Expand Down Expand Up @@ -42,8 +44,37 @@ def setUp(self):
with open(self.uranium_file_path, 'w+') as fh:
fh.write(yaml.dump(self.config))

self.warmup_file_path = os.path.join(self.root, 'warmup')
self.warmup_file_path = os.path.join(self.root, 'uranium')
shutil.copy(WARMUP_SCRIPT_PATH, self.warmup_file_path)

def tearDown(self):
shutil.rmtree(self.root)


@attr(full=True)
class FullUraniumBaseTest(object):
"""
use this class when you need to test a uranium sandbox end-to-end.
this will generate a uranium sandbox with the configuration provided.
"""

config = {
}

@classmethod
def setupClass(cls):
cls.root = tempfile.mkdtemp()
cls.warmup_file_path = os.path.join(cls.root, 'uranium')

cls.uranium_file_path = os.path.join(cls.root, DEFAULT_URANIUM_FILE)
with open(cls.uranium_file_path, 'w+') as fh:
fh.write(yaml.dump(cls.config))

shutil.copy(WARMUP_SCRIPT_PATH, cls.warmup_file_path)

subprocess.call([cls.warmup_file_path, '--uranium-dir', URANIUM_BASE_PATH],
cwd=cls.root)

@classmethod
def teardownClass(cls):
shutil.rmtree(cls.root)

0 comments on commit 257b931

Please sign in to comment.