File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments