コード例 #1
0
ファイル: test_osclients.py プロジェクト: noah8713/rally-ovs
 def test_swift(self):
     fake_swift = fakes.FakeSwiftClient()
     mock_swift = mock.MagicMock()
     mock_swift.client.Connection = mock.MagicMock(return_value=fake_swift)
     self.assertNotIn("swift", self.clients.cache)
     with mock.patch.dict("sys.modules", {"swiftclient": mock_swift}):
         client = self.clients.swift()
         self.assertEqual(client, fake_swift)
         self.service_catalog.url_for.assert_called_once_with(
             service_type="object-store",
             endpoint_type=consts.EndpointType.PUBLIC,
             region_name=self.credential.region_name)
         kw = {
             "retries": 1,
             "preauthurl": self.service_catalog.url_for.return_value,
             "preauthtoken": self.fake_keystone.auth_token,
             "insecure": False,
             "cacert": None,
             "user": self.credential.username,
             "key": self.credential.password,
             "tenant_name": self.credential.tenant_name,
             "authurl": self.credential.auth_url
         }
         mock_swift.client.Connection.assert_called_once_with(**kw)
         self.assertEqual(self.clients.cache["swift"], fake_swift)
コード例 #2
0
ファイル: test_osclients.py プロジェクト: meteorfox/rally
 def test_swift(self):
     with mock.patch("rally.osclients.swift") as mock_swift:
         fake_swift = fakes.FakeSwiftClient()
         mock_swift.Connection = mock.MagicMock(return_value=fake_swift)
         self.assertNotIn("swift", self.clients.cache)
         client = self.clients.swift()
         self.assertEqual(client, fake_swift)
         self.service_catalog.url_for.assert_called_once_with(
             service_type="object-store",
             endpoint_type=consts.EndpointType.PUBLIC,
             region_name=self.endpoint.region_name)
         kw = {
             "retries": 1,
             "preauthurl": self.service_catalog.url_for.return_value,
             "preauthtoken": self.fake_keystone.auth_token,
             "insecure": False,
             "cacert": None
         }
         mock_swift.Connection.assert_called_once_with(**kw)
         self.assertEqual(self.clients.cache["swift"], fake_swift)