-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Online Automated Tests, Squashed a couple bugs (#32)
* Revise Memberships API wrapper tests Revise method for generating test accounts; the test accounts need to be ‘Messaging’ licensed users (to enable the moderator functionality). * Add TestPeople class to Manage Test Accounts Add a TestPeople class to create, manage and delete (when tests are complete) test (person) accounts. * Simplify pytest.fixture rooms_list and dependencies Add group_room, direct_rooms, and team_room to the use / dependency list of fixture rooms_list; remove these dependencies from the tests that depend on rooms_list * Change page_size to 1 in test_list_rooms_with_paging There is no need for each ‘page’ to contain more than a single item. This may help minimize the number of test rooms created, which will help minimize the number of API calls that must be made to create and delete these test rooms. * Initial TeamsAPI tests * Generalize test accounts Remove “group_room_” prefix from test account references to enable them to be reused by the team_memberships tests. * Optimize dependencies for authenticated_user_memberships Add group_room, team_room, and direct_rooms dependencies to authenticated_user_memberships and remove them from tests that depend on authenticated_user_memberships. * Change page_size to 1 in test_list_user_memberships_with_paging There is no need for each ‘page’ to contain more than a single item. This may help minimize the number of rooms created, which will help minimize the number of API calls that must be made to create and delete these test rooms. * Optimize use of test accounts when testing deleting memberships Use a generic / reusable ’named test account’ instead of a temp_account. This same test_account can be reused when testing team memberships. * Initial TeamMembershipsAPI tests * Initial PeopleAPI tests * mentionedPeople should be of type list not string_types * Add CiscoSparkAPI.people.delete() method / API call I don’t know how I missed this one… * Squash some test bugs * Initial MessagesAPI tests * Squash memberships test bugs * Temporarily disable test account deletion Temporarily disabling test account deletion to work on account capabilities issues. * Temp Disable Test: Update Person API is not working * Temp Disable Test: Spark API / documentation bug in GET 'team/memberships' * Temp Disable Test: Update team name API is not working
- Loading branch information
Showing
13 changed files
with
1,148 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
"""pytest Licenses API wrapper tests and fixtures.""" | ||
|
||
|
||
import pytest | ||
|
||
import ciscosparkapi | ||
|
||
|
||
# Helper Functions | ||
|
||
def get_list_of_licenses(api, orgId=None, max=None): | ||
return api.licenses.list(orgId=orgId, max=max) | ||
|
||
|
||
def get_license_by_id(api, licenseId): | ||
return api.licenses.get(licenseId) | ||
|
||
|
||
def is_valid_license(obj): | ||
return isinstance(obj, ciscosparkapi.License) and obj.id is not None | ||
|
||
|
||
def are_valid_licenses(iterable): | ||
return all([is_valid_license(obj) for obj in iterable]) | ||
|
||
|
||
# pytest Fixtures | ||
|
||
@pytest.fixture(scope="session") | ||
def licenses_list(api): | ||
return list(get_list_of_licenses(api)) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def licenses_dict(licenses_list): | ||
return {lic.name: lic for lic in licenses_list} | ||
|
||
|
||
# Tests | ||
|
||
class TestLicensesAPI(object): | ||
"""Test LicensesAPI methods.""" | ||
|
||
def test_list_licenses(self, licenses_list): | ||
assert are_valid_licenses(licenses_list) | ||
|
||
def test_list_licenses_with_paging(self, api): | ||
paging_generator = get_list_of_licenses(api, max=1) | ||
licenses = list(paging_generator) | ||
assert licenses > 1 | ||
assert are_valid_licenses(licenses) | ||
|
||
def test_get_licenses_for_organization(self, api, me): | ||
licenses = list(get_list_of_licenses(api, orgId=me.orgId)) | ||
assert are_valid_licenses(licenses) | ||
|
||
def test_get_license_by_id(self, api, licenses_list): | ||
assert len(licenses_list) >= 1 | ||
license_id = licenses_list[0].id | ||
license = get_license_by_id(api, licenseId=license_id) | ||
assert is_valid_license(license) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.