def test(self): container = Container.fromConfig(self.testContainerConfig) self._compare(container, "testId", "TEST_VIRTUAL_HOST", "1234", "TEST_VIRTUAL_ALIAS", "testHostname") # try again with paused state self.testContainerConfig.status = 'paused' container = Container.fromConfig(self.testContainerConfig) self._compare(container, "testId", "TEST_VIRTUAL_HOST", "1234", "TEST_VIRTUAL_ALIAS", "testHostname")
def testVirtualPortFromBindings(self): self.testContainerConfig.env.remove("VIRTUAL_PORT=1234") self.testContainerConfig.ports[ 1] = 'test' # int keys should be skipped self.testContainerConfig.ports['port_tcp'] = [{'HostPort': "2345"}] container = Container.fromConfig(self.testContainerConfig) self._compare(container, "testId", "TEST_VIRTUAL_HOST", "2345", "TEST_VIRTUAL_ALIAS", "testHostname")
def testGetContainers(self): self.assertEqual(3, len(self.instanceForTest.containers)) self.assertContainerIn(Container.fromConfig(self.config1), self.instanceForTest.containers) self.assertContainerIn(Container.fromConfig(self.config2), self.instanceForTest.containers) self.assertContainerIn(Container.fromConfig(self.config4), self.instanceForTest.containers) self.assertTrue(os.path.exists("hostsDir/hosts")) with open("hostsDir/hosts", "r", encoding='utf8') as f: lines = f.readlines() self.assertEqual(3, len(lines)) self.assertIn("va1\tvh1\n", lines) self.assertIn("va2\tvh2\n", lines) self.assertIn("va4\tvh4\n", lines)
def testDefaultVirtualAlias(self): self.testContainerConfig.env.remove("VIRTUAL_ALIAS=TEST_VIRTUAL_ALIAS") try: os.environ['DEFAULT_VIRTUAL_ALIAS'] = 'defaultValue' container = Container.fromConfig(self.testContainerConfig) self._compare(container, "testId", "TEST_VIRTUAL_HOST", "1234", "defaultValue", "testHostname") finally: del os.environ['DEFAULT_VIRTUAL_ALIAS']
def testNoVirtualAlias(self): self.testContainerConfig.env.remove("VIRTUAL_ALIAS=TEST_VIRTUAL_ALIAS") container = Container.fromConfig(self.testContainerConfig) self.assertEqual(None, container)
def testNoVirtualPort(self): self.testContainerConfig.env.remove("VIRTUAL_PORT=1234") container = Container.fromConfig(self.testContainerConfig) self.assertEqual(None, container)
def testNoVirtualHost(self): self.testContainerConfig.env.remove("VIRTUAL_HOST=TEST_VIRTUAL_HOST") container = Container.fromConfig(self.testContainerConfig) self.assertEqual(None, container)
def testTagIsThisImage(self): self.testContainerConfig.addTag(thisImage) container = Container.fromConfig(self.testContainerConfig) self.assertEqual(None, container)
def testNotRunningOrPaused(self): self.testContainerConfig.status = 'stopped' container = Container.fromConfig(self.testContainerConfig) self.assertEqual(None, container)