forked from TencentBlueKing/bkpaas-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix fetch_esb_public_key command (TencentBlueKing#147)
- Loading branch information
1 parent
cab64c3
commit 910de73
Showing
3 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
.../apigw-manager/tests/apigw_manager/apigw/management/commands/test_fetch_esb_public_key.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-蓝鲸 PaaS 平台(BlueKing-PaaS) available. | ||
* Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved. | ||
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at http://opensource.org/licenses/MIT | ||
* 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 pytest | ||
|
||
from apigw_manager.apigw.management.commands.fetch_esb_public_key import Command | ||
|
||
|
||
@pytest.fixture() | ||
def manager(mocker): | ||
return mocker.MagicMock() | ||
|
||
|
||
@pytest.fixture() | ||
def public_key_manager(mocker): | ||
return mocker.MagicMock() | ||
|
||
|
||
@pytest.fixture() | ||
def command(mocker, manager, public_key_manager): | ||
mock_fun = mocker.patch("apigw_manager.apigw.helper.make_default_public_key_manager") | ||
mock_fun.return_value = public_key_manager | ||
|
||
command = Command() | ||
command.manager_class = mocker.MagicMock(return_value=manager) | ||
|
||
return command | ||
|
||
|
||
def test_handle_no_save(command, manager, public_key_manager): | ||
command.handle(gateway_name="foo", print_=True, no_save=True) | ||
manager.public_key.assert_called() | ||
public_key_manager.set.assert_not_called() | ||
|
||
|
||
def test_handle(command, manager, public_key_manager): | ||
command.handle(gateway_name="foo", print_=True, no_save=False) | ||
manager.public_key.assert_called() | ||
public_key_manager.set.assert_called() |