zuul-jobs/roles/upload-logs-base/library/test_zuul_azure_upload.py
Ian Wienand b3ddaecb06 zuul_azure_storage_upload: rename
roles/upload-logs-azure/tasks/main.yaml calls
"zuul_azure_storage_upload:" but the library file is currently called
"zuul_azure_upload.py".  Since it says in the comments of the file to
call it as "zuul_azure_storage_upload.py" (and that matches the google
one) rename it.

I found this when working backwards with an ansible-lint that runs
against Ansible 2.8.  I think this is an ansible-lint bug; see [1]

[1] https://github.com/ansible/ansible-lint/issues/2283

Change-Id: Ic30d82771e6c591cf17bcd15ca9dc92fb0f89e04
2022-09-26 09:28:55 -07:00

65 lines
1.9 KiB
Python

# Copyright (C) 2018-2019 Red Hat, Inc.
#
# 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.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import testtools
try:
from unittest import mock
except ImportError:
import mock
from .zuul_azure_storage_upload import Uploader
from ..module_utils.zuul_jobs.upload_utils import FileDetail
FIXTURE_DIR = os.path.join(os.path.dirname(__file__),
'test-fixtures')
class TestUpload(testtools.TestCase):
def test_upload_result(self):
client = mock.Mock()
uploader = Uploader(client=client, container="container")
# Get some test files to upload
files = [
FileDetail(
os.path.join(FIXTURE_DIR, "logs/job-output.json"),
"job-output.json",
),
FileDetail(
os.path.join(FIXTURE_DIR, "logs/zuul-info/inventory.yaml"),
"inventory.yaml",
),
]
uploader.upload(files)
client.create_container.assert_called_with(
'container', public_access='container')
upload_calls = uploader.client.get_blob_client.mock_calls
self.assertIn(
mock.call(container='container', blob='job-output.json'),
upload_calls)
self.assertIn(
mock.call(container='container', blob='inventory.yaml'),
upload_calls)