import sys
import unittest

from mock import Mock

from libcloud.common.openstack import OpenStackBaseConnection


class OpenStackBaseConnectionTest(unittest.TestCase):

    def setUp(self):
        self.timeout = 10
        OpenStackBaseConnection.conn_classes = (None, Mock())
        self.connection = OpenStackBaseConnection('foo', 'bar',
                                                  timeout=self.timeout,
                                                  ex_force_auth_url='https://127.0.0.1')
        self.connection.driver = Mock()
        self.connection.driver.name = 'OpenStackDriver'

    def test_base_connection_timeout(self):
        self.connection.connect()
        self.assertEquals(self.connection.timeout, self.timeout)
        self.connection.conn_classes[1].assert_called_with(host='127.0.0.1',
                                                           port=443,
                                                           timeout=10)


if __name__ == '__main__':
    sys.exit(unittest.main())

import sys
import unittest

from mock import Mock

from libcloud.common.openstack import OpenStackBaseConnection
from libcloud.utils.py3 import PY25


class OpenStackBaseConnectionTest(unittest.TestCase):

    def setUp(self):
        self.timeout = 10
        OpenStackBaseConnection.conn_classes = (None, Mock())
        self.connection = OpenStackBaseConnection('foo', 'bar',
                                                  timeout=self.timeout,
                                                  ex_force_auth_url='https://127.0.0.1')
        self.connection.driver = Mock()
        self.connection.driver.name = 'OpenStackDriver'

    def test_base_connection_timeout(self):
        self.connection.connect()
        self.assertEquals(self.connection.timeout, self.timeout)
        if PY25:
            self.connection.conn_classes[1].assert_called_with(host='127.0.0.1',
                                                               port=443)
        else:
            self.connection.conn_classes[1].assert_called_with(host='127.0.0.1',
                                                               port=443,
                                                               timeout=10)


if __name__ == '__main__':
    sys.exit(unittest.main())

Fix test so it works with python 2.5.
Fix test so it works with python 2.5.


git-svn-id: 9ad005ce451fa0ce30ad6352b03eb45b36893355@1342997 13f79535-47bb-0310-9956-ffa450edef68

  import sys
  import unittest
  
  from mock import Mock
  
  from libcloud.common.openstack import OpenStackBaseConnection
+ from libcloud.utils.py3 import PY25
  
  
  class OpenStackBaseConnectionTest(unittest.TestCase):
  
      def setUp(self):
          self.timeout = 10
          OpenStackBaseConnection.conn_classes = (None, Mock())
          self.connection = OpenStackBaseConnection('foo', 'bar',
                                                    timeout=self.timeout,
                                                    ex_force_auth_url='https://127.0.0.1')
          self.connection.driver = Mock()
          self.connection.driver.name = 'OpenStackDriver'
  
      def test_base_connection_timeout(self):
          self.connection.connect()
          self.assertEquals(self.connection.timeout, self.timeout)
+         if PY25:
-         self.connection.conn_classes[1].assert_called_with(host='127.0.0.1',
+             self.connection.conn_classes[1].assert_called_with(host='127.0.0.1',
+                                                                port=443)
+         else:
+             self.connection.conn_classes[1].assert_called_with(host='127.0.0.1',
-                                                            port=443,
+                                                                port=443,
-                                                            timeout=10)
+                                                                timeout=10)
  
  
  if __name__ == '__main__':
      sys.exit(unittest.main())
  
Fix test so it works with python 2.5.
## Code Before:
import sys
import unittest

from mock import Mock

from libcloud.common.openstack import OpenStackBaseConnection


class OpenStackBaseConnectionTest(unittest.TestCase):

    def setUp(self):
        self.timeout = 10
        OpenStackBaseConnection.conn_classes = (None, Mock())
        self.connection = OpenStackBaseConnection('foo', 'bar',
                                                  timeout=self.timeout,
                                                  ex_force_auth_url='https://127.0.0.1')
        self.connection.driver = Mock()
        self.connection.driver.name = 'OpenStackDriver'

    def test_base_connection_timeout(self):
        self.connection.connect()
        self.assertEquals(self.connection.timeout, self.timeout)
        self.connection.conn_classes[1].assert_called_with(host='127.0.0.1',
                                                           port=443,
                                                           timeout=10)


if __name__ == '__main__':
    sys.exit(unittest.main())

## Instruction:
Fix test so it works with python 2.5.
## Code After:
import sys
import unittest

from mock import Mock

from libcloud.common.openstack import OpenStackBaseConnection
from libcloud.utils.py3 import PY25


class OpenStackBaseConnectionTest(unittest.TestCase):

    def setUp(self):
        self.timeout = 10
        OpenStackBaseConnection.conn_classes = (None, Mock())
        self.connection = OpenStackBaseConnection('foo', 'bar',
                                                  timeout=self.timeout,
                                                  ex_force_auth_url='https://127.0.0.1')
        self.connection.driver = Mock()
        self.connection.driver.name = 'OpenStackDriver'

    def test_base_connection_timeout(self):
        self.connection.connect()
        self.assertEquals(self.connection.timeout, self.timeout)
        if PY25:
            self.connection.conn_classes[1].assert_called_with(host='127.0.0.1',
                                                               port=443)
        else:
            self.connection.conn_classes[1].assert_called_with(host='127.0.0.1',
                                                               port=443,
                                                               timeout=10)


if __name__ == '__main__':
    sys.exit(unittest.main())
