Skip to content

Commit

Permalink
Merge 1647b8a into 72f3db5
Browse files Browse the repository at this point in the history
  • Loading branch information
phantomas1234 committed Mar 3, 2016
2 parents 72f3db5 + 1647b8a commit 515a852
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
13 changes: 9 additions & 4 deletions tests/test_parallel.py
Expand Up @@ -41,6 +41,11 @@ def interactive(f):
TRAVIS = os.getenv('TRAVIS', False)
SKIP_PARALLEL = TRAVIS

if os.getenv('WERCKER_REDIS_URL', False):
REDIS_HOST = 'localhost'
else:
REDIS_HOST = os.getenv('WERCKER_REDIS_URL').split('//')[1].split(':')[0]

@interactive
def to_the_power_of_2_interactive(arg):
return arg ** 2
Expand Down Expand Up @@ -94,11 +99,11 @@ def test_length(self):

class TestRedisQueue(unittest.TestCase):
def test_queue_size(self):
queue = RedisQueue("test-queue-size-1", maxsize=1)
queue = RedisQueue("test-queue-size-1", maxsize=1, host=REDIS_HOST)
queue.put(1)
self.assertRaises(six.moves.queue.Full, queue.put, 1)

queue = RedisQueue("test-queue-size-2", maxsize=2)
queue = RedisQueue("test-queue-size-2", maxsize=2, host=REDIS_HOST)
queue.put(1)
queue.put(1)
self.assertRaises(six.moves.queue.Full, queue.put, 1)
Expand All @@ -107,7 +112,7 @@ def test_queue_size(self):
self.assertRaises(six.moves.queue.Empty, queue.get_nowait)

def test_queue_objects(self):
queue = RedisQueue("test-queue", maxsize=100)
queue = RedisQueue("test-queue", maxsize=100, host=REDIS_HOST)
# put int
queue.put(1)
v = queue.get_nowait()
Expand Down Expand Up @@ -140,7 +145,7 @@ def test_queue_objects(self):
self.assertIsInstance(v, dict)

def test_queue_len(self):
queue = RedisQueue("test-queue-len", maxsize=100)
queue = RedisQueue("test-queue-len", maxsize=100, host=REDIS_HOST)
self.assertEqual(queue.length, 0)
queue.put(1)
self.assertEqual(queue.length, 1)
Expand Down
15 changes: 11 additions & 4 deletions tests/test_strain_design_heuristics.py
Expand Up @@ -50,6 +50,11 @@

TRAVIS = os.getenv('TRAVIS', False)

if os.getenv('WERCKER_REDIS_URL', False):
REDIS_HOST = 'localhost'
else:
REDIS_HOST = os.getenv('WERCKER_REDIS_URL').split('//')[1].split(':')[0]

SEED = 1234

CURRENT_PATH = os.path.dirname(__file__)
Expand Down Expand Up @@ -592,21 +597,23 @@ def setUp(self):
self.population = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
self.random = Random(SEED)

unittest.skipIf(os.getenv('WERCKER', False), 'Currently not working on wercker as redis is not running on localhost')
def test_migrator_constructor(self):
migrator = MultiprocessingMigrator(max_migrants=1)
migrator = MultiprocessingMigrator(max_migrants=1, host=REDIS_HOST)
self.assertIsInstance(migrator.migrants, RedisQueue)
self.assertEqual(migrator.max_migrants, 1)

migrator = MultiprocessingMigrator(max_migrants=2)
migrator = MultiprocessingMigrator(max_migrants=2, host=REDIS_HOST)
self.assertIsInstance(migrator.migrants, RedisQueue)
self.assertEqual(migrator.max_migrants, 2)

migrator = MultiprocessingMigrator(max_migrants=3)
migrator = MultiprocessingMigrator(max_migrants=3, host=REDIS_HOST)
self.assertIsInstance(migrator.migrants, RedisQueue)
self.assertEqual(migrator.max_migrants, 3)

unittest.skipIf(os.getenv('WERCKER', False), 'Currently not working on wercker as redis is not running on localhost')
def test_migrate_individuals_without_evaluation(self):
migrator = MultiprocessingMigrator(max_migrants=1)
migrator = MultiprocessingMigrator(max_migrants=1, host=REDIS_HOST)
self.assertIsInstance(migrator.migrants, RedisQueue)
self.assertEqual(migrator.max_migrants, 1)

Expand Down
23 changes: 23 additions & 0 deletions wercker.yml
@@ -0,0 +1,23 @@
box:
id: biosustain/cameo-wercker-box
username: $USERNAME
password: $PASSWORD
tag: latest

services:
- redis
build:

steps:

- script:
name: run tests for Python 3.4
code: |
source activate cameo3.4
nosetests
- script:
name: run tests for Python 2.7
code: |
source activate cameo2.7
nosetests

0 comments on commit 515a852

Please sign in to comment.