2014-01-09 16:30:36 +01:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from . import unittest
|
|
|
|
from fig.cli.main import TopLevelCommand
|
|
|
|
|
|
|
|
class CLITestCase(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.command = TopLevelCommand()
|
|
|
|
self.command.base_dir = 'tests/fixtures/simple-figfile'
|
|
|
|
|
2014-01-20 17:47:58 +01:00
|
|
|
def tearDown(self):
|
|
|
|
self.command.project.kill()
|
|
|
|
self.command.project.remove_stopped()
|
|
|
|
|
2014-01-09 16:30:36 +01:00
|
|
|
def test_help(self):
|
|
|
|
self.assertRaises(SystemExit, lambda: self.command.dispatch(['-h'], None))
|
2014-01-09 16:31:37 +01:00
|
|
|
|
|
|
|
def test_ps(self):
|
|
|
|
self.command.dispatch(['ps'], None)
|
2014-01-16 18:58:53 +01:00
|
|
|
|
|
|
|
def test_scale(self):
|
|
|
|
project = self.command.project
|
|
|
|
|
|
|
|
self.command.scale({'SERVICE=NUM': ['simple=1']})
|
|
|
|
self.assertEqual(len(project.get_service('simple').containers()), 1)
|
|
|
|
|
|
|
|
self.command.scale({'SERVICE=NUM': ['simple=3', 'another=2']})
|
|
|
|
self.assertEqual(len(project.get_service('simple').containers()), 3)
|
|
|
|
self.assertEqual(len(project.get_service('another').containers()), 2)
|
|
|
|
|
|
|
|
self.command.scale({'SERVICE=NUM': ['simple=1', 'another=1']})
|
|
|
|
self.assertEqual(len(project.get_service('simple').containers()), 1)
|
|
|
|
self.assertEqual(len(project.get_service('another').containers()), 1)
|
|
|
|
|
|
|
|
self.command.scale({'SERVICE=NUM': ['simple=1', 'another=1']})
|
|
|
|
self.assertEqual(len(project.get_service('simple').containers()), 1)
|
|
|
|
self.assertEqual(len(project.get_service('another').containers()), 1)
|
|
|
|
|
|
|
|
self.command.scale({'SERVICE=NUM': ['simple=0', 'another=0']})
|
|
|
|
self.assertEqual(len(project.get_service('simple').containers()), 0)
|
|
|
|
self.assertEqual(len(project.get_service('another').containers()), 0)
|
|
|
|
|