Skip to content

Commit

Permalink
Update test scripts and mechanisms
Browse files Browse the repository at this point in the history
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
  • Loading branch information
troydai committed Jul 5, 2017
1 parent c240fe6 commit 7344bdc
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 120 deletions.
6 changes: 3 additions & 3 deletions .coveragerc
@@ -1,5 +1,5 @@
[run]
parallel = true
parallel = True
concurrency = multiprocessing
omit =
*/env/*
Expand All @@ -8,5 +8,5 @@ omit =
cover.py
source =
src/
branch = on

branch = True
disable_warnings = no-data-collected
6 changes: 2 additions & 4 deletions scripts/build.sh
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-testsdk/setup.py
Expand Up @@ -34,7 +34,7 @@
'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:
Expand Down
Expand Up @@ -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:
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/command_modules/azure-cli-storage/__init__.py
@@ -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')
112 changes: 0 additions & 112 deletions src/command_modules/azure-cli-storage/test_storage_url_helpers.py

This file was deleted.

0 comments on commit 7344bdc

Please sign in to comment.