Skip to content

Commit

Permalink
skip ec2 buildslave tests if moto not found
Browse files Browse the repository at this point in the history
  • Loading branch information
kouk committed Feb 26, 2014
1 parent aad90eb commit 0c60b08
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions master/buildbot/test/unit/test_buildslave_ec2.py
Expand Up @@ -15,18 +15,24 @@
# Portions Copyright 2014 Longaccess private company

try:
import moto
import boto
from moto import mock_ec2
except ImportError:
raise ImportError("EC2LatentSlave tests require the 'moto' module; "
"try 'pip install moto'")
mock_ec2 = lambda x: x
boto = None
else:
import boto
from buildbot.buildslave import ec2
from twisted.trial import unittest


class TestEC2LatentBuildSlave(unittest.TestCase):
ec2_connection = None

def setUp(self):
super(TestEC2LatentBuildSlave, self).setUp()
if boto is None:
raise unittest.SkipTest("moto not found")

def botoSetup(self):
c = boto.connect_ec2()
c.create_key_pair('latent_buildbot_slave')
Expand All @@ -36,7 +42,7 @@ def botoSetup(self):
c.terminate_instances([instance.id])
return c

@moto.mock_ec2
@mock_ec2
def test_constructor_minimal(self):
c = self.botoSetup()
amis = c.get_all_images()
Expand All @@ -50,7 +56,7 @@ def test_constructor_minimal(self):
self.assertEqual(bs.instance_type, 'm1.large')
self.assertEqual(bs.ami, amis[0].id)

@moto.mock_ec2
@mock_ec2
def test_constructor_tags(self):
c = self.botoSetup()
amis = c.get_all_images()
Expand All @@ -63,7 +69,7 @@ def test_constructor_tags(self):
)
self.assertEqual(bs.tags, tags)

@moto.mock_ec2
@mock_ec2
def test_start_instance(self):
c = self.botoSetup()
amis = c.get_all_images()
Expand All @@ -82,7 +88,7 @@ def test_start_instance(self):
self.assertEqual(instances[0].id, instance_id)
self.assertEqual(instances[0].tags, {})

@moto.mock_ec2
@mock_ec2
def test_start_instance_tags(self):
c = self.botoSetup()
amis = c.get_all_images()
Expand Down

0 comments on commit 0c60b08

Please sign in to comment.