From 0d8272890c901f5bb4d56d875ce743a01fc4cf61 Mon Sep 17 00:00:00 2001 From: Shahrustam Date: Wed, 10 Jun 2020 12:02:34 +0300 Subject: [PATCH] merge account, org and team tests into one file --- ...st_account.py => test_account_org_team.py} | 293 ++++++++++++++++++ tests/commands/test_orgs.py | 163 ---------- tests/commands/test_teams.py | 175 ----------- 3 files changed, 293 insertions(+), 338 deletions(-) rename tests/commands/{test_account.py => test_account_org_team.py} (51%) delete mode 100644 tests/commands/test_orgs.py delete mode 100644 tests/commands/test_teams.py diff --git a/tests/commands/test_account.py b/tests/commands/test_account_org_team.py similarity index 51% rename from tests/commands/test_account.py rename to tests/commands/test_account_org_team.py index dff24f52..49530f5d 100644 --- a/tests/commands/test_account.py +++ b/tests/commands/test_account_org_team.py @@ -20,7 +20,9 @@ import pytest import requests from platformio.commands.account import cli as cmd_account +from platformio.commands.org import cli as cmd_org from platformio.commands.package import cli as cmd_package +from platformio.commands.team import cli as cmd_team from platformio.downloader import FileDownloader from platformio.unpacker import FileUnpacker @@ -275,3 +277,294 @@ def test_account( finally: result = clirunner.invoke(cmd_account, ["destroy"], "y") validate_cliresult(result) + + +@pytest.mark.skipif( + not os.environ.get("TEST_EMAIL_LOGIN"), + reason="requires TEST_EMAIL_LOGIN, TEST_EMAIL_PASSWORD environ variables", +) # pylint:disable=too-many-arguments +def test_org(clirunner, validate_cliresult, receive_email, isolated_pio_home): + username = "test-piocore-%s" % str(random.randint(0, 100000)) + splited_email = os.environ.get("TEST_EMAIL_LOGIN").split("@") + email = "%s+%s@%s" % (splited_email[0], username, splited_email[1]) + firstname = "Test" + lastname = "User" + password = "Qwerty123!" + + # pio account register + result = clirunner.invoke( + cmd_account, + [ + "register", + "-u", + username, + "-e", + email, + "-p", + password, + "--firstname", + firstname, + "--lastname", + lastname, + ], + ) + validate_cliresult(result) + + # email verification + result = receive_email(email) + link = ( + result.split("Click on the link below to start this process.")[1] + .split("This link will expire within 12 hours.")[0] + .strip() + ) + session = requests.Session() + result = session.get(link).text + link = result.split(' -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json -import os -import random - -import pytest -import requests - -from platformio.commands.account import cli as cmd_account -from platformio.commands.org import cli as cmd_org - - -@pytest.mark.skipif( - not os.environ.get("TEST_EMAIL_LOGIN"), - reason="requires TEST_EMAIL_LOGIN, TEST_EMAIL_PASSWORD environ variables", -) # pylint:disable=too-many-arguments -def test_org(clirunner, validate_cliresult, receive_email, isolated_pio_home): - username = "test-piocore-%s" % str(random.randint(0, 100000)) - splited_email = os.environ.get("TEST_EMAIL_LOGIN").split("@") - email = "%s+%s@%s" % (splited_email[0], username, splited_email[1]) - firstname = "Test" - lastname = "User" - password = "Qwerty123!" - - # pio account register - result = clirunner.invoke( - cmd_account, - [ - "register", - "-u", - username, - "-e", - email, - "-p", - password, - "--firstname", - firstname, - "--lastname", - lastname, - ], - ) - validate_cliresult(result) - - # email verification - result = receive_email(email) - link = ( - result.split("Click on the link below to start this process.")[1] - .split("This link will expire within 12 hours.")[0] - .strip() - ) - session = requests.Session() - result = session.get(link).text - link = result.split(' -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json -import os -import random - -import pytest -import requests - -from platformio.commands.account import cli as cmd_account -from platformio.commands.org import cli as cmd_org -from platformio.commands.team import cli as cmd_team - - -@pytest.mark.skipif( - not os.environ.get("TEST_EMAIL_LOGIN"), - reason="requires TEST_EMAIL_LOGIN, TEST_EMAIL_PASSWORD environ variables", -) # pylint:disable=too-many-arguments -def test_teams(clirunner, validate_cliresult, receive_email, isolated_pio_home): - username = "test-piocore-%s" % str(random.randint(0, 100000)) - splited_email = os.environ.get("TEST_EMAIL_LOGIN").split("@") - email = "%s+%s@%s" % (splited_email[0], username, splited_email[1]) - firstname = "Test" - lastname = "User" - password = "Qwerty123!" - - # pio account register - result = clirunner.invoke( - cmd_account, - [ - "register", - "-u", - username, - "-e", - email, - "-p", - password, - "--firstname", - firstname, - "--lastname", - lastname, - ], - ) - validate_cliresult(result) - - # email verification - result = receive_email(email) - link = ( - result.split("Click on the link below to start this process.")[1] - .split("This link will expire within 12 hours.")[0] - .strip() - ) - session = requests.Session() - result = session.get(link).text - link = result.split('