from __future__ import unicode_literals from __future__ import absolute_import from .. import unittest from fig import Service from fig.service import ConfigError class ServiceTest(unittest.TestCase): def test_name_validations(self): self.assertRaises(ConfigError, lambda: Service(name='')) self.assertRaises(ConfigError, lambda: Service(name=' ')) self.assertRaises(ConfigError, lambda: Service(name='/')) self.assertRaises(ConfigError, lambda: Service(name='!')) self.assertRaises(ConfigError, lambda: Service(name='\xe2')) self.assertRaises(ConfigError, lambda: Service(name='_')) self.assertRaises(ConfigError, lambda: Service(name='____')) self.assertRaises(ConfigError, lambda: Service(name='foo_bar')) self.assertRaises(ConfigError, lambda: Service(name='__foo_bar__')) Service('a') Service('foo') def test_project_validation(self): self.assertRaises(ConfigError, lambda: Service(name='foo', project='_')) Service(name='foo', project='bar') def test_config_validation(self): self.assertRaises(ConfigError, lambda: Service(name='foo', port=['8000'])) Service(name='foo', ports=['8000'])