コード例 #1
0
    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")
コード例 #2
0
 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")
コード例 #3
0
    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)
コード例 #4
0
 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']
コード例 #5
0
 def testNoVirtualAlias(self):
     self.testContainerConfig.env.remove("VIRTUAL_ALIAS=TEST_VIRTUAL_ALIAS")
     container = Container.fromConfig(self.testContainerConfig)
     self.assertEqual(None, container)
コード例 #6
0
 def testNoVirtualPort(self):
     self.testContainerConfig.env.remove("VIRTUAL_PORT=1234")
     container = Container.fromConfig(self.testContainerConfig)
     self.assertEqual(None, container)
コード例 #7
0
 def testNoVirtualHost(self):
     self.testContainerConfig.env.remove("VIRTUAL_HOST=TEST_VIRTUAL_HOST")
     container = Container.fromConfig(self.testContainerConfig)
     self.assertEqual(None, container)
コード例 #8
0
 def testTagIsThisImage(self):
     self.testContainerConfig.addTag(thisImage)
     container = Container.fromConfig(self.testContainerConfig)
     self.assertEqual(None, container)
コード例 #9
0
 def testNotRunningOrPaused(self):
     self.testContainerConfig.status = 'stopped'
     container = Container.fromConfig(self.testContainerConfig)
     self.assertEqual(None, container)