openstacksdk/shade/tests/unit/test_usage.py
Monty Taylor 766d6227a3
Use get_discovery from keystoneauth
If we use the get_discovery call, we'll re-use the keystoneauth cache.
This removes the last stupid extra discovery call.

While doing this, noticed the dns version discovery was wrong, but we
weren't noticing because adapter magic. Fix it.

Change-Id: I01d07554d094fffd498f21a9291710c8eb0041f6
2017-06-06 17:05:16 -05:00

33 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import datetime
import mock
import shade
from shade.tests.unit import base
class TestUsage(base.RequestsMockTestCase):
@mock.patch.object(shade.OpenStackCloud, 'nova_client')
def test_get_usage(self, mock_nova):
project = self.mock_for_keystone_projects(project_count=1,
list_get=True)[0]
start = end = datetime.datetime.now()
self.op_cloud.get_compute_usage(project.project_id, start, end)
mock_nova.usage.get.assert_called_once_with(
start=start, end=end, tenant_id=project.project_id)
self.assert_calls()