Skip to content

Commit 675b9b7

Browse files
committed
added new test
1 parent b028c41 commit 675b9b7

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
tests/.env
66
*.zip
77
dist/
8-
*.pyc
8+
build/
9+
*.pyc
10+
venv

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
MIT License
3+
4+
Copyright (c) 2021
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

test-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pytest
22
python-dotenv
33
flake8
4-
pylint
4+
pylint
5+
pre-commit

tests/test_api_no_sandbox.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,35 @@
22
Test the api methods that do NOT require a blueprint
33
Live Cloudshell server is still a dependency
44
"""
5+
import pytest
56
from constants import DEFAULT_EMPTY_BLUEPRINT
67

78
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
89

910

11+
@pytest.fixture(scope="module")
12+
def api_token(admin_session: SandboxRestApiSession):
13+
token = admin_session.get_token_for_target_user("admin")
14+
return token
15+
16+
17+
def test_delete_token(admin_session: SandboxRestApiSession, api_token: str):
18+
assert isinstance(api_token, str)
19+
print(f"Token response: '{api_token}'")
20+
admin_session.delete_token(api_token)
21+
22+
23+
def test_reset_session(admin_session: SandboxRestApiSession):
24+
print("\ndeleting admin token...")
25+
admin_session.invalidate_auth()
26+
print("logging back in..")
27+
admin_session.refresh_auth_from_stored_credentials()
28+
print("Calling get blueprints...")
29+
res = admin_session.get_blueprints()
30+
assert isinstance(res, list)
31+
print(f"blueprint count {len(res)}")
32+
33+
1034
def test_get_sandboxes(admin_session: SandboxRestApiSession):
1135
res = admin_session.get_sandboxes()
1236
assert isinstance(res, list)
@@ -24,9 +48,3 @@ def test_get_default_blueprint(admin_session: SandboxRestApiSession):
2448
assert isinstance(bp_res, dict)
2549
bp_name = bp_res["name"]
2650
print(f"Pulled details for '{bp_name}'")
27-
28-
29-
def test_get_and_delete_token(admin_session: SandboxRestApiSession):
30-
token_res = admin_session.get_token_for_target_user("admin")
31-
assert isinstance(token_res, str)
32-
print(f"Token response: '{token_res}'")

0 commit comments

Comments
 (0)