зеркало из https://github.com/Azure/azure-cli.git
Update test scripts and mechanisms
1. Ping to azure-devtools==0.4.3 2. Change the test invocation in build.sh to reduce output from coverage. 3. Update coverage configuration 4. Fix missing storage test
This commit is contained in:
Родитель
c240fe659d
Коммит
7344bdcc45
|
@ -1,5 +1,5 @@
|
|||
[run]
|
||||
parallel = true
|
||||
parallel = True
|
||||
concurrency = multiprocessing
|
||||
omit =
|
||||
*/env/*
|
||||
|
@ -8,5 +8,5 @@ omit =
|
|||
cover.py
|
||||
source =
|
||||
src/
|
||||
branch = on
|
||||
|
||||
branch = True
|
||||
disable_warnings = no-data-collected
|
||||
|
|
|
@ -16,14 +16,12 @@ python -m azure.cli --debug
|
|||
# Ensure tokens are erased from VCR recordings
|
||||
python -m automation.tests.check_vcr_recordings
|
||||
|
||||
# check_style --ci;
|
||||
check_style --ci;
|
||||
|
||||
if [ "$CODE_COVERAGE" == "True" ]; then
|
||||
echo "Run tests with code coverage."
|
||||
pip install -qqq coverage codecov
|
||||
find src -name tests | xargs nosetests --with-coverage --cover-branches --processes=-1 --process-timeout=600 --process-restartworker -v -c ./nose.cfg
|
||||
|
||||
|
||||
coverage run -m automation.tests.run --parallel
|
||||
coverage combine
|
||||
codecov
|
||||
else
|
||||
|
|
|
@ -34,7 +34,7 @@ DEPENDENCIES = [
|
|||
'jmespath',
|
||||
'mock',
|
||||
'vcrpy>=1.10.3',
|
||||
'azure-devtools==0.4.1'
|
||||
'azure-devtools==0.4.3'
|
||||
]
|
||||
|
||||
with open('README.rst', 'r', encoding='utf-8') as f:
|
||||
|
|
|
@ -31,6 +31,7 @@ def _get_window_columns():
|
|||
_, col = get_window_dim()
|
||||
return col
|
||||
|
||||
|
||||
def add_new_lines(long_phrase, line_min=None, tolerance=TOLERANCE):
|
||||
""" not everything fits on the screen, based on the size, add newlines """
|
||||
if line_min is None:
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from azure.cli.core.prompting import prompt_pass, NoTTYException
|
||||
import azure.cli.core.azlogging as azlogging
|
||||
from azure.cli.core._profile import Profile
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import datetime
|
||||
import re
|
||||
import os
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# --------------------------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
# --------------------------------------------------------------------------------------------
|
|
@ -0,0 +1,105 @@
|
|||
# --------------------------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
import unittest
|
||||
from azure.cli.command_modules.storage.storage_url_helpers import StorageResourceIdentifier
|
||||
|
||||
|
||||
class TestStorageUrlHelpers(unittest.TestCase):
|
||||
def test_is_url(self):
|
||||
def _check_is_url(moniker, expectation):
|
||||
assert StorageResourceIdentifier(moniker).is_url() == expectation
|
||||
|
||||
_check_is_url('sample', False)
|
||||
_check_is_url('http://test.blob.core.windows.net/cont', True)
|
||||
_check_is_url('https://test.blob.core.windows.net/cont', True)
|
||||
_check_is_url('https://test.file.core.windows.net/cont', True)
|
||||
|
||||
def test_container_parsing(self):
|
||||
def _test(moniker, expected_container=None, expected_blob=None, expected_snapshot=None):
|
||||
i = StorageResourceIdentifier(moniker)
|
||||
|
||||
if expected_container is not None:
|
||||
assert i.container == expected_container
|
||||
assert i.share is None
|
||||
assert i.directory is None
|
||||
assert i.filename is None
|
||||
else:
|
||||
assert i.container is None
|
||||
|
||||
assert i.blob == expected_blob
|
||||
assert i.snapshot == expected_snapshot
|
||||
|
||||
_test('sample')
|
||||
_test('https://momba.file.core.windows.net/snake')
|
||||
_test('http://momba.else.core.windows.net/snake')
|
||||
_test('http://momba.blob.core.windows.net/snake', 'snake')
|
||||
_test('https://momba.blob.core.windows.net/snake', 'snake')
|
||||
_test('https://momba.blob.core.windows.net/snake/blob', 'snake', 'blob')
|
||||
_test('https://momba.blob.core.windows.net/snake/blob/blob2', 'snake', 'blob/blob2')
|
||||
_test('https://momba.blob.core.windows.net/snake/blob?some=thing', 'snake', 'blob')
|
||||
|
||||
def test_share_parsing(self):
|
||||
def _test(moniker, expected_share=None, expected_dir=None, expected_file=None):
|
||||
i = StorageResourceIdentifier(moniker)
|
||||
|
||||
if expected_share is not None:
|
||||
assert i.container is None
|
||||
assert i.blob is None
|
||||
assert i.snapshot is None
|
||||
assert i.share == expected_share
|
||||
else:
|
||||
assert i.share is None
|
||||
|
||||
assert i.directory == expected_dir
|
||||
assert i.filename == expected_file
|
||||
|
||||
_test('sample')
|
||||
_test('https://momba.blob.core.windows.net/snake')
|
||||
_test('http://momba.blob.core.windows.net/snake')
|
||||
_test('http://momba.else.core.windows.net/snake')
|
||||
_test('http://momba.file.core.windows.net/snake/d/f.txt', 'snake', 'd', 'f.txt')
|
||||
_test('http://momba.file.core.windows.net/snake/f.txt', 'snake', '', 'f.txt')
|
||||
_test('http://momba.file.core.windows.net/snake/d/e/f.txt', 'snake', 'd/e', 'f.txt')
|
||||
_test('http://momba.file.core.windows.net/snake/d/e/f.txt?s=t', 'snake', 'd/e', 'f.txt')
|
||||
|
||||
def test_account_name(self):
|
||||
def _test(moniker, expected_account=None):
|
||||
i = StorageResourceIdentifier(moniker)
|
||||
assert i.account_name == expected_account
|
||||
|
||||
_test('sample')
|
||||
_test('https://momba.else.core.windows.net/snake')
|
||||
_test('https://momba.blob.core.windows.net/snake', 'momba')
|
||||
_test('http://momba.file.core.windows.net/snake', 'momba')
|
||||
_test('http://momba.file.core.windows.net/snake/d/e/f.txt?s=t', 'momba')
|
||||
|
||||
def test_default_value(self):
|
||||
i = StorageResourceIdentifier('')
|
||||
assert not i.is_url()
|
||||
assert not i.is_valid
|
||||
assert i.account_name is None
|
||||
assert i.container is None
|
||||
assert i.blob is None
|
||||
assert i.share is None
|
||||
assert i.directory is None
|
||||
assert i.filename is None
|
||||
|
||||
def test_get_sas_token(self):
|
||||
def _test(moniker, expected_sas=None):
|
||||
i = StorageResourceIdentifier(moniker)
|
||||
assert i.sas_token == expected_sas
|
||||
|
||||
_test('https://momba.blob.core.windows.net/blob?sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se='
|
||||
'2016-12-05T23:02:02Z&st=2016-12-05T15:02:02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL'
|
||||
'33Pr0v3Fs5VIjsUL6A%3D',
|
||||
'sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se=2016-12-05T23:02:02Z&st=2016-12-05T15:02:'
|
||||
'02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL33Pr0v3Fs5VIjsUL6A%3D')
|
||||
|
||||
_test('https://momba.blob.core.windows.net/blob?sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se='
|
||||
'2016-12-05T23:02:02Z&st=2016-12-05T15:02:02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL'
|
||||
'33Pr0v3Fs5VIjsUL6A%3D&snapshot=2016-12-05T23:12:03.1181304Z',
|
||||
'sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se=2016-12-05T23:02:02Z&st=2016-12-05T15:02:'
|
||||
'02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL33Pr0v3Fs5VIjsUL6A%3D')
|
|
@ -1,112 +0,0 @@
|
|||
# --------------------------------------------------------------------------------------------
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
from azure.cli.command_modules.storage.storage_url_helpers import StorageResourceIdentifier
|
||||
|
||||
# pylint: disable=line-too-long
|
||||
|
||||
|
||||
def test_is_url():
|
||||
def _check_is_url(moniker, expectation):
|
||||
assert StorageResourceIdentifier(moniker).is_url() == expectation
|
||||
|
||||
yield _check_is_url, 'sample', False
|
||||
yield _check_is_url, 'http://test.blob.core.windows.net/cont', True
|
||||
yield _check_is_url, 'https://test.blob.core.windows.net/cont', True
|
||||
yield _check_is_url, 'https://test.file.core.windows.net/cont', True
|
||||
|
||||
|
||||
def test_container_parsing():
|
||||
def _test(moniker, expected_container=None, expected_blob=None, expected_snapshot=None):
|
||||
i = StorageResourceIdentifier(moniker)
|
||||
|
||||
if expected_container is not None:
|
||||
assert i.container == expected_container
|
||||
assert i.share is None
|
||||
assert i.directory is None
|
||||
assert i.filename is None
|
||||
else:
|
||||
assert i.container is None
|
||||
|
||||
assert i.blob == expected_blob
|
||||
assert i.snapshot == expected_snapshot
|
||||
|
||||
yield _test, 'sample'
|
||||
yield _test, 'https://momba.file.core.windows.net/snake'
|
||||
yield _test, 'http://momba.else.core.windows.net/snake'
|
||||
yield _test, 'http://momba.blob.core.windows.net/snake', 'snake'
|
||||
yield _test, 'https://momba.blob.core.windows.net/snake', 'snake'
|
||||
yield _test, 'https://momba.blob.core.windows.net/snake/blob', 'snake', 'blob'
|
||||
yield _test, 'https://momba.blob.core.windows.net/snake/blob/blob2', 'snake', 'blob/blob2'
|
||||
yield _test, 'https://momba.blob.core.windows.net/snake/blob?some=thing', 'snake', 'blob'
|
||||
|
||||
|
||||
def test_share_parsing():
|
||||
def _test(moniker, expected_share=None, expected_dir=None, expected_file=None):
|
||||
i = StorageResourceIdentifier(moniker)
|
||||
|
||||
if expected_share is not None:
|
||||
assert i.container is None
|
||||
assert i.blob is None
|
||||
assert i.snapshot is None
|
||||
assert i.share == expected_share
|
||||
else:
|
||||
assert i.share is None
|
||||
|
||||
assert i.directory == expected_dir
|
||||
assert i.filename == expected_file
|
||||
|
||||
yield _test, 'sample'
|
||||
yield _test, 'https://momba.blob.core.windows.net/snake'
|
||||
yield _test, 'http://momba.blob.core.windows.net/snake'
|
||||
yield _test, 'http://momba.else.core.windows.net/snake'
|
||||
yield _test, 'http://momba.file.core.windows.net/snake/d/f.txt', 'snake', 'd', 'f.txt'
|
||||
yield _test, 'http://momba.file.core.windows.net/snake/f.txt', 'snake', '', 'f.txt'
|
||||
yield _test, 'http://momba.file.core.windows.net/snake/d/e/f.txt', 'snake', 'd/e', 'f.txt'
|
||||
yield _test, 'http://momba.file.core.windows.net/snake/d/e/f.txt?s=t', 'snake', 'd/e', 'f.txt'
|
||||
|
||||
|
||||
def test_account_name():
|
||||
def _test(moniker, expected_account=None):
|
||||
i = StorageResourceIdentifier(moniker)
|
||||
assert i.account_name == expected_account
|
||||
|
||||
yield _test, 'sample'
|
||||
yield _test, 'https://momba.else.core.windows.net/snake'
|
||||
yield _test, 'https://momba.blob.core.windows.net/snake', 'momba'
|
||||
yield _test, 'http://momba.file.core.windows.net/snake', 'momba'
|
||||
yield _test, 'http://momba.file.core.windows.net/snake/d/e/f.txt?s=t', 'momba'
|
||||
|
||||
|
||||
def test_default_value():
|
||||
i = StorageResourceIdentifier('')
|
||||
assert not i.is_url()
|
||||
assert not i.is_valid
|
||||
assert i.account_name is None
|
||||
assert i.container is None
|
||||
assert i.blob is None
|
||||
assert i.share is None
|
||||
assert i.directory is None
|
||||
assert i.filename is None
|
||||
|
||||
|
||||
def test_get_sas_token():
|
||||
def _test(moniker, expected_sas=None):
|
||||
i = StorageResourceIdentifier(moniker)
|
||||
assert i.sas_token == expected_sas
|
||||
|
||||
yield _test,\
|
||||
'https://momba.blob.core.windows.net/blob?sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se=' \
|
||||
'2016-12-05T23:02:02Z&st=2016-12-05T15:02:02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL' \
|
||||
'33Pr0v3Fs5VIjsUL6A%3D',\
|
||||
'sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se=2016-12-05T23:02:02Z&st=2016-12-05T15:02:' \
|
||||
'02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL33Pr0v3Fs5VIjsUL6A%3D'
|
||||
|
||||
yield _test, \
|
||||
'https://momba.blob.core.windows.net/blob?sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se=' \
|
||||
'2016-12-05T23:02:02Z&st=2016-12-05T15:02:02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL' \
|
||||
'33Pr0v3Fs5VIjsUL6A%3D&snapshot=2016-12-05T23:12:03.1181304Z', \
|
||||
'sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se=2016-12-05T23:02:02Z&st=2016-12-05T15:02:' \
|
||||
'02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL33Pr0v3Fs5VIjsUL6A%3D'
|
Загрузка…
Ссылка в новой задаче