예제 #1
0
 def test_split_domainname_fqdn(self):
     service = Service('foo',
             hostname = 'name.domain.tld',
         )
     service.next_container_name = lambda x: 'foo'
     opts = service._get_container_create_options({})
     self.assertEqual(opts['hostname'], 'name', 'hostname')
     self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
예제 #2
0
 def test_split_domainname_fqdn(self):
     service = Service('foo',
             hostname='name.domain.tld',
             client=self.mock_client)
     self.mock_client.containers.return_value = []
     opts = service._get_container_create_options({})
     self.assertEqual(opts['hostname'], 'name', 'hostname')
     self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
예제 #3
0
 def test_split_domainname_fqdn(self):
     service = Service('foo',
             hostname='name.domain.tld',
             client=self.mock_client)
     self.mock_client.containers.return_value = []
     opts = service._get_container_create_options({'image': 'foo'})
     self.assertEqual(opts['hostname'], 'name', 'hostname')
     self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
예제 #4
0
 def test_env_from_multiple_files(self):
     service = Service(
         "foo",
         env_file=["tests/fixtures/env/one.env", "tests/fixtures/env/two.env"],
         client=self.mock_client,
         image="image_name",
     )
     options = service._get_container_create_options({})
     self.assertEqual(options["environment"], {"ONE": "2", "TWO": "1", "THREE": "3", "FOO": "baz", "DOO": "dah"})
예제 #5
0
 def test_parse_environment(self):
     service = Service(
         "foo",
         environment=["NORMAL=F1", "CONTAINS_EQUALS=F=2", "TRAILING_EQUALS="],
         client=self.mock_client,
         image="image_name",
     )
     options = service._get_container_create_options({})
     self.assertEqual(options["environment"], {"NORMAL": "F1", "CONTAINS_EQUALS": "F=2", "TRAILING_EQUALS": ""})
예제 #6
0
파일: service_test.py 프로젝트: hubert/fig
 def test_env_from_multiple_files(self):
     service = Service('foo',
             env_file=['tests/fixtures/env/one.env', 'tests/fixtures/env/two.env'],
             client=self.mock_client,
         )
     options = service._get_container_create_options({})
     self.assertEqual(
         options['environment'],
         {'ONE': '2', 'TWO': '1', 'THREE': '3', 'FOO': 'baz', 'DOO': 'dah'}
         )
예제 #7
0
파일: service_test.py 프로젝트: hubert/fig
 def test_parse_environment(self):
     service = Service('foo',
             environment=['NORMAL=F1', 'CONTAINS_EQUALS=F=2', 'TRAILING_EQUALS='],
             client=self.mock_client,
         )
     options = service._get_container_create_options({})
     self.assertEqual(
         options['environment'],
         {'NORMAL': 'F1', 'CONTAINS_EQUALS': 'F=2', 'TRAILING_EQUALS': ''}
         )
예제 #8
0
 def test_resolve_environment_from_file(self):
     os.environ["FILE_DEF"] = "E1"
     os.environ["FILE_DEF_EMPTY"] = "E2"
     os.environ["ENV_DEF"] = "E3"
     service = Service(
         "foo", env_file=["tests/fixtures/env/resolve.env"], client=self.mock_client, image="image_name"
     )
     options = service._get_container_create_options({})
     self.assertEqual(
         options["environment"], {"FILE_DEF": "F1", "FILE_DEF_EMPTY": "", "ENV_DEF": "E3", "NO_DEF": ""}
     )
예제 #9
0
 def test_env_from_file(self):
     service = Service('foo',
             env_file='tests/fixtures/env/one.env',
             client=self.mock_client,
             image='image_name',
         )
     options = service._get_container_create_options({})
     self.assertEqual(
         options['environment'],
         {'ONE': '2', 'TWO': '1', 'THREE': '3', 'FOO': 'bar'}
         )
예제 #10
0
파일: service_test.py 프로젝트: hubert/fig
 def test_resolve_environment(self):
     os.environ['FILE_DEF'] = 'E1'
     os.environ['FILE_DEF_EMPTY'] = 'E2'
     os.environ['ENV_DEF'] = 'E3'
     service = Service('foo',
             environment={'FILE_DEF': 'F1', 'FILE_DEF_EMPTY': '', 'ENV_DEF': None, 'NO_DEF': None},
             client=self.mock_client,
         )
     options = service._get_container_create_options({})
     self.assertEqual(
         options['environment'],
         {'FILE_DEF': 'F1', 'FILE_DEF_EMPTY': '', 'ENV_DEF': 'E3', 'NO_DEF': ''}
         )
예제 #11
0
파일: service_test.py 프로젝트: hubert/fig
 def test_resolve_environment_from_file(self):
     os.environ['FILE_DEF'] = 'E1'
     os.environ['FILE_DEF_EMPTY'] = 'E2'
     os.environ['ENV_DEF'] = 'E3'
     service = Service('foo',
             env_file=['tests/fixtures/env/resolve.env'],
             client=self.mock_client,
         )
     options = service._get_container_create_options({})
     self.assertEqual(
         options['environment'],
         {'FILE_DEF': 'F1', 'FILE_DEF_EMPTY': '', 'ENV_DEF': 'E3', 'NO_DEF': ''}
         )
예제 #12
0
 def test_env_from_file(self):
     service = Service(
         'foo',
         env_file='tests/fixtures/env/one.env',
         client=self.mock_client,
         image='image_name',
     )
     options = service._get_container_create_options({})
     self.assertEqual(options['environment'], {
         'ONE': '2',
         'TWO': '1',
         'THREE': '3',
         'FOO': 'bar'
     })
예제 #13
0
 def test_resolve_environment(self):
     os.environ["FILE_DEF"] = "E1"
     os.environ["FILE_DEF_EMPTY"] = "E2"
     os.environ["ENV_DEF"] = "E3"
     service = Service(
         "foo",
         environment={"FILE_DEF": "F1", "FILE_DEF_EMPTY": "", "ENV_DEF": None, "NO_DEF": None},
         client=self.mock_client,
         image="image_name",
     )
     options = service._get_container_create_options({})
     self.assertEqual(
         options["environment"], {"FILE_DEF": "F1", "FILE_DEF_EMPTY": "", "ENV_DEF": "E3", "NO_DEF": ""}
     )
예제 #14
0
 def test_parse_environment(self):
     service = Service(
         'foo',
         environment=[
             'NORMAL=F1', 'CONTAINS_EQUALS=F=2', 'TRAILING_EQUALS='
         ],
         client=self.mock_client,
         image='image_name',
     )
     options = service._get_container_create_options({})
     self.assertEqual(options['environment'], {
         'NORMAL': 'F1',
         'CONTAINS_EQUALS': 'F=2',
         'TRAILING_EQUALS': ''
     })
예제 #15
0
 def test_resolve_environment_from_file(self):
     os.environ['FILE_DEF'] = 'E1'
     os.environ['FILE_DEF_EMPTY'] = 'E2'
     os.environ['ENV_DEF'] = 'E3'
     service = Service(
         'foo',
         env_file=['tests/fixtures/env/resolve.env'],
         client=self.mock_client,
         image='image_name',
     )
     options = service._get_container_create_options({})
     self.assertEqual(options['environment'], {
         'FILE_DEF': 'F1',
         'FILE_DEF_EMPTY': '',
         'ENV_DEF': 'E3',
         'NO_DEF': ''
     })
예제 #16
0
 def test_split_domainname_none(self):
     service = Service('foo', hostname='name', client=self.mock_client)
     self.mock_client.containers.return_value = []
     opts = service._get_container_create_options({'image': 'foo'})
     self.assertEqual(opts['hostname'], 'name', 'hostname')
     self.assertFalse('domainname' in opts, 'domainname')
예제 #17
0
파일: service_test.py 프로젝트: JerryR7/fig
 def test_split_domainname_none(self):
     service = Service('foo', hostname='name', client=self.mock_client)
     self.mock_client.containers.return_value = []
     opts = service._get_container_create_options({})
     self.assertEqual(opts['hostname'], 'name', 'hostname')
     self.assertFalse('domainname' in opts, 'domainname')
예제 #18
0
 def test_split_domainname_weird(self):
     service = Service("foo", hostname="name.sub", domainname="domain.tld", client=self.mock_client)
     self.mock_client.containers.return_value = []
     opts = service._get_container_create_options({"image": "foo"})
     self.assertEqual(opts["hostname"], "name.sub", "hostname")
     self.assertEqual(opts["domainname"], "domain.tld", "domainname")