# Copyright (c) 2014-present PlatformIO # # 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 time 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(int(time.time() * 1000)) 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('