Skip to content

Commit 2b0e130

Browse files
committed
Add tests and fixtures for the Organizations API wrapper
1 parent d5a2f1b commit 2b0e130

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/api/test_organizations.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""pytest Licenses functions, fixtures and tests."""
4+
5+
6+
import pytest
7+
8+
import ciscosparkapi
9+
10+
11+
# Helper Functions
12+
13+
def list_organizations(api, max=None):
14+
return list(api.organizations.list(max=max))
15+
16+
17+
def get_organization_by_id(api, orgId):
18+
return api.organizations.get(orgId)
19+
20+
21+
def is_valid_organization(obj):
22+
return isinstance(obj, ciscosparkapi.Organization) and obj.id is not None
23+
24+
def are_valid_organizations(iterable):
25+
return all([is_valid_organization(obj) for obj in iterable])
26+
27+
28+
# pytest Fixtures
29+
30+
@pytest.fixture(scope="session")
31+
def organizations_list(api):
32+
return list_organizations(api)
33+
34+
35+
# Tests
36+
37+
class TestOrganizationsAPI(object):
38+
"""Test OrganizationsAPI methods."""
39+
40+
def test_list_organizations(self, organizations_list):
41+
assert are_valid_organizations(organizations_list)
42+
43+
def test_get_organization_by_id(self, api, organizations_list):
44+
assert len(organizations_list) >= 1
45+
org_id = organizations_list[0].id
46+
org = get_organization_by_id(api, orgId=org_id)
47+
assert is_valid_organization(org)

0 commit comments

Comments
 (0)