Skip to content

Commit 7344bdc

Browse files
committed
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
1 parent c240fe6 commit 7344bdc

File tree

9 files changed

+121
-120
lines changed

9 files changed

+121
-120
lines changed

.coveragerc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[run]
2-
parallel = true
2+
parallel = True
33
concurrency = multiprocessing
44
omit =
55
*/env/*
@@ -8,5 +8,5 @@ omit =
88
cover.py
99
source =
1010
src/
11-
branch = on
12-
11+
branch = True
12+
disable_warnings = no-data-collected

scripts/build.sh

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ python -m azure.cli --debug
1616
# Ensure tokens are erased from VCR recordings
1717
python -m automation.tests.check_vcr_recordings
1818

19-
# check_style --ci;
19+
check_style --ci;
2020

2121
if [ "$CODE_COVERAGE" == "True" ]; then
2222
echo "Run tests with code coverage."
2323
pip install -qqq coverage codecov
24-
find src -name tests | xargs nosetests --with-coverage --cover-branches --processes=-1 --process-timeout=600 --process-restartworker -v -c ./nose.cfg
25-
26-
24+
coverage run -m automation.tests.run --parallel
2725
coverage combine
2826
codecov
2927
else

src/azure-cli-testsdk/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'jmespath',
3535
'mock',
3636
'vcrpy>=1.10.3',
37-
'azure-devtools==0.4.1'
37+
'azure-devtools==0.4.3'
3838
]
3939

4040
with open('README.rst', 'r', encoding='utf-8') as f:

src/command_modules/azure-cli-interactive/azclishell/gather_commands.py

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def _get_window_columns():
3131
_, col = get_window_dim()
3232
return col
3333

34+
3435
def add_new_lines(long_phrase, line_min=None, tolerance=TOLERANCE):
3536
""" not everything fits on the screen, based on the size, add newlines """
3637
if line_min is None:

src/command_modules/azure-cli-profile/azure/cli/command_modules/profile/custom.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55

6+
from __future__ import print_function
7+
68
from azure.cli.core.prompting import prompt_pass, NoTTYException
79
import azure.cli.core.azlogging as azlogging
810
from azure.cli.core._profile import Profile

src/command_modules/azure-cli-role/azure/cli/command_modules/role/custom.py

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
5+
6+
from __future__ import print_function
7+
58
import datetime
69
import re
710
import os
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
import unittest
7+
from azure.cli.command_modules.storage.storage_url_helpers import StorageResourceIdentifier
8+
9+
10+
class TestStorageUrlHelpers(unittest.TestCase):
11+
def test_is_url(self):
12+
def _check_is_url(moniker, expectation):
13+
assert StorageResourceIdentifier(moniker).is_url() == expectation
14+
15+
_check_is_url('sample', False)
16+
_check_is_url('http://test.blob.core.windows.net/cont', True)
17+
_check_is_url('https://test.blob.core.windows.net/cont', True)
18+
_check_is_url('https://test.file.core.windows.net/cont', True)
19+
20+
def test_container_parsing(self):
21+
def _test(moniker, expected_container=None, expected_blob=None, expected_snapshot=None):
22+
i = StorageResourceIdentifier(moniker)
23+
24+
if expected_container is not None:
25+
assert i.container == expected_container
26+
assert i.share is None
27+
assert i.directory is None
28+
assert i.filename is None
29+
else:
30+
assert i.container is None
31+
32+
assert i.blob == expected_blob
33+
assert i.snapshot == expected_snapshot
34+
35+
_test('sample')
36+
_test('https://momba.file.core.windows.net/snake')
37+
_test('http://momba.else.core.windows.net/snake')
38+
_test('http://momba.blob.core.windows.net/snake', 'snake')
39+
_test('https://momba.blob.core.windows.net/snake', 'snake')
40+
_test('https://momba.blob.core.windows.net/snake/blob', 'snake', 'blob')
41+
_test('https://momba.blob.core.windows.net/snake/blob/blob2', 'snake', 'blob/blob2')
42+
_test('https://momba.blob.core.windows.net/snake/blob?some=thing', 'snake', 'blob')
43+
44+
def test_share_parsing(self):
45+
def _test(moniker, expected_share=None, expected_dir=None, expected_file=None):
46+
i = StorageResourceIdentifier(moniker)
47+
48+
if expected_share is not None:
49+
assert i.container is None
50+
assert i.blob is None
51+
assert i.snapshot is None
52+
assert i.share == expected_share
53+
else:
54+
assert i.share is None
55+
56+
assert i.directory == expected_dir
57+
assert i.filename == expected_file
58+
59+
_test('sample')
60+
_test('https://momba.blob.core.windows.net/snake')
61+
_test('http://momba.blob.core.windows.net/snake')
62+
_test('http://momba.else.core.windows.net/snake')
63+
_test('http://momba.file.core.windows.net/snake/d/f.txt', 'snake', 'd', 'f.txt')
64+
_test('http://momba.file.core.windows.net/snake/f.txt', 'snake', '', 'f.txt')
65+
_test('http://momba.file.core.windows.net/snake/d/e/f.txt', 'snake', 'd/e', 'f.txt')
66+
_test('http://momba.file.core.windows.net/snake/d/e/f.txt?s=t', 'snake', 'd/e', 'f.txt')
67+
68+
def test_account_name(self):
69+
def _test(moniker, expected_account=None):
70+
i = StorageResourceIdentifier(moniker)
71+
assert i.account_name == expected_account
72+
73+
_test('sample')
74+
_test('https://momba.else.core.windows.net/snake')
75+
_test('https://momba.blob.core.windows.net/snake', 'momba')
76+
_test('http://momba.file.core.windows.net/snake', 'momba')
77+
_test('http://momba.file.core.windows.net/snake/d/e/f.txt?s=t', 'momba')
78+
79+
def test_default_value(self):
80+
i = StorageResourceIdentifier('')
81+
assert not i.is_url()
82+
assert not i.is_valid
83+
assert i.account_name is None
84+
assert i.container is None
85+
assert i.blob is None
86+
assert i.share is None
87+
assert i.directory is None
88+
assert i.filename is None
89+
90+
def test_get_sas_token(self):
91+
def _test(moniker, expected_sas=None):
92+
i = StorageResourceIdentifier(moniker)
93+
assert i.sas_token == expected_sas
94+
95+
_test('https://momba.blob.core.windows.net/blob?sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se='
96+
'2016-12-05T23:02:02Z&st=2016-12-05T15:02:02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL'
97+
'33Pr0v3Fs5VIjsUL6A%3D',
98+
'sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se=2016-12-05T23:02:02Z&st=2016-12-05T15:02:'
99+
'02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL33Pr0v3Fs5VIjsUL6A%3D')
100+
101+
_test('https://momba.blob.core.windows.net/blob?sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se='
102+
'2016-12-05T23:02:02Z&st=2016-12-05T15:02:02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL'
103+
'33Pr0v3Fs5VIjsUL6A%3D&snapshot=2016-12-05T23:12:03.1181304Z',
104+
'sv=2015-04-05&ss=bfqt&srt=sco&sp=rwdlacup&se=2016-12-05T23:02:02Z&st=2016-12-05T15:02:'
105+
'02Z&spr=https&sig=e0xYWg%2F142F5uUsPBflsUVQqL33Pr0v3Fs5VIjsUL6A%3D')

src/command_modules/azure-cli-storage/test_storage_url_helpers.py

-112
This file was deleted.

0 commit comments

Comments
 (0)