Skip to content

fix: remove pytest-depends from project #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ coverage.xml

# virtual env
venv/
venv*/
# python 3 virtual env
python3/

Expand Down
Binary file modified case_management.env.enc
Binary file not shown.
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ python_dotenv>=0.1.5
pylint>=1.4.4
tox>=2.9.1
pytest-rerunfailures>=3.1
pytest-depends>=1.0.1

# code coverage
coverage<5
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ jproperties
requests>=2.0,<3.0
python_dateutil>=2.5.3
websocket-client==0.48.0
ibm_cloud_sdk_core>=2.0.0,<3.0.0
ibm_cloud_sdk_core>=2.0.1,<3.0.0
66 changes: 22 additions & 44 deletions test/integration/test_case_management_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@

# Read config file
configFile = 'case_management.env'
configLoaded = None

if os.path.exists(configFile):
os.environ['IBM_CREDENTIALS_FILE'] = configFile
configLoaded = True

class TestCaseManagementV1(unittest.TestCase):

Expand All @@ -42,23 +37,18 @@ class TestCaseManagementV1(unittest.TestCase):
file_attachment_id = ''

@classmethod
def setUpClass(self):

if not configLoaded:
def setUpClass(cls):
if os.path.exists(configFile):
os.environ['IBM_CREDENTIALS_FILE'] = configFile
else:
raise unittest.SkipTest('External configuration not available, skipping...')

self.service = CaseManagementV1.new_instance()
assert self.service is not None

self.config = read_external_sources(CaseManagementV1.DEFAULT_SERVICE_NAME)
assert self.config is not None
self.test_api_key = self.config.get('APIKEY')
assert self.test_api_key is not None
cls.service = CaseManagementV1.new_instance()
assert cls.service is not None

print('\nSetup complete.')
print('Setup complete.')

@pytest.mark.depends(name='case_creation')
def test_create_case(self):
def test_01_create_case(self):

# Offering info can be retrieved via /case-management/utilities/v1/offerings/technical
offering_payload_type_model = {}
Expand Down Expand Up @@ -92,7 +82,7 @@ def test_create_case(self):
assert subject == response.result['short_description']
assert description == response.result['description']

def test_create_case_with_empty_offering(self):
def test_02_create_case_with_empty_offering(self):

type = 'technical'
subject = 'Python - Integration test'
Expand All @@ -109,7 +99,7 @@ def test_create_case_with_empty_offering(self):
)
assert e.value.code == 400

def test_create_case_with_empty_subject_and_description(self):
def test_03_create_case_with_empty_subject_and_description(self):

# Offering info can be retrieved via /case-management/utilities/v1/offerings/technical
offering_payload_type_model = {}
Expand Down Expand Up @@ -139,8 +129,7 @@ def test_create_case_with_empty_subject_and_description(self):
)
assert e.value.code == 500

@pytest.mark.depends(on='case_creation')
def test_get_cases(self):
def test_04_get_cases(self):

offset = 0
limit = 2
Expand All @@ -158,8 +147,7 @@ def test_get_cases(self):
assert response.status_code == 200
assert response.result['total_count'] > 0

@pytest.mark.depends(on='case_creation')
def test_get_case(self):
def test_05_get_case(self):

fields = ['number', 'short_description']
case_number = TestCaseManagementV1.new_case_number
Expand All @@ -173,7 +161,7 @@ def test_get_case(self):
assert TestCaseManagementV1.new_case_number == response.result['number']
assert response.result['short_description'] != ''

def test_get_case_with_invalid_field(self):
def test_06_get_case_with_invalid_field(self):

fields = ['number', 'short_description', 'invalid_field']
case_number = TestCaseManagementV1.new_case_number
Expand All @@ -186,8 +174,7 @@ def test_get_case_with_invalid_field(self):
)
assert e.value.code == 400

@pytest.mark.depends(on='case_creation')
def test_add_comment(self):
def test_07_add_comment(self):

case_number = TestCaseManagementV1.new_case_number
comment = 'This is a test comment!'
Expand All @@ -201,7 +188,7 @@ def test_add_comment(self):
assert response.status_code == 200
assert comment == response.result["value"]

def test_add_comment_to_nonexisting_case(self):
def test_08_add_comment_to_nonexisting_case(self):

case_number = 'fake-case-number'
comment = 'This is a test comment!'
Expand All @@ -214,8 +201,7 @@ def test_add_comment_to_nonexisting_case(self):
)
assert e.value.code == 404

@pytest.mark.depends(on='case_creation')
def test_add_watch_list_member(self):
def test_09_add_watch_list_member(self):

# Users can be retrieved via the User Management API.
user_id_and_realm_model = {}
Expand All @@ -239,9 +225,7 @@ def test_add_watch_list_member(self):
if user['user_id'] == user_id_and_realm_model['user_id']]
assert len(found_users) == 1

@pytest.mark.depends(on='case_creation')
@pytest.mark.depends(name='file_upload')
def test_file_upload(self):
def test_10_file_upload(self):

fileName = "test_file.txt"

Expand All @@ -262,9 +246,7 @@ def test_file_upload(self):
assert response.status_code == 200
assert response.result['filename'] == fileName

@pytest.mark.depends(on='file_upload')
@pytest.mark.depends(name='file_download')
def test_download_file(self):
def test_11_download_file(self):

response = self.service.download_file(
TestCaseManagementV1.new_case_number,
Expand All @@ -275,8 +257,7 @@ def test_download_file(self):
assert response.status_code == 200
assert 'content-type' in response.headers

@pytest.mark.depends(on='file_download')
def test_delete_file(self):
def test_12_delete_file(self):

response = self.service.delete_file(
TestCaseManagementV1.new_case_number,
Expand All @@ -288,9 +269,7 @@ def test_delete_file(self):
# Assert the file attachment list is empty
assert len(response.result['attachments']) == 0

@pytest.mark.depends(on='file_download')
@pytest.mark.depends(name='add_resource')
def test_add_resource(self):
def test_13_add_resource(self):

# Adding a resource requires a valid CRN (Cloud Resource Name)
# CRN's can be retrieved via the Search and Tagging API
Expand All @@ -310,8 +289,7 @@ def test_add_resource(self):
)
assert e.value.code == 500

@pytest.mark.depends(on='add_resource')
def test_resolve_case(self):
def test_14_resolve_case(self):

status_payload = {}
status_payload['action'] = 'resolve'
Expand All @@ -325,4 +303,4 @@ def test_resolve_case(self):
)

assert response.status_code == 200
assert TestCaseManagementV1.new_case_number == response.result["number"]
assert TestCaseManagementV1.new_case_number == response.result["number"]
11 changes: 3 additions & 8 deletions test/integration/test_iam_access_groups_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,13 @@

# Read config file
configFile = 'iam_access_groups.env'
configLoaded = None

if os.path.exists(configFile):
os.environ['IBM_CREDENTIALS_FILE'] = configFile
configLoaded = True
else:
print('External configuration was not found, skipping tests...')

class TestIamAccessGroupsV2(unittest.TestCase):
@classmethod
def setUpClass(cls):
if not configLoaded:
if os.path.exists(configFile):
os.environ['IBM_CREDENTIALS_FILE'] = configFile
else:
raise unittest.SkipTest('External configuration not available, skipping...')

cls.service = IamAccessGroupsV2.new_instance()
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ commands = pylint --rcfile=.pylintrc ibm_platform_services test
[testenv]
passenv = TOXENV CI TRAVIS*
commands =
py.test --reruns 3 --cov=ibm_platform_services {posargs}
py.test --reruns 2 --cov=ibm_platform_services {posargs}
codecov -e TOXENV
deps =
-r{toxinidir}/requirements.txt
Expand Down