Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve manual testing check #41

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions setup/01-manual_testing.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import os
import sys
import re
from setup.static import LOGIN_ROBOT_FILE
from setup.static import LOGIN_ROBOT_FILE, check_running_in_root


def check_file_exists():
if not os.path.isfile(LOGIN_ROBOT_FILE):
print(f"login.robot not found under {LOGIN_ROBOT_FILE}, please create one")
print(f"❌ Hmm. I don't see your 'login.robot' file. I was expecting to see it at '{LOGIN_ROBOT_FILE}'")
print("Double-check that it's in the right place and named correctly and try again.")
sys.exit(1)
else:
print("✔️ Found your 'login.robot' file.")

def check_content():
is_browser = False
Expand All @@ -20,25 +24,41 @@ def check_content():
data = f.readlines()
for line in data:
lowered_line = line.lower()
if re.search(r"(new|open) (page|browser)", lowered_line):
if re.search(r"(new|open).+(page|browser|app)", lowered_line):
is_browser = True
elif re.search(r"localhost:7272", lowered_line):
if re.search(r"localhost:7272", lowered_line):
is_url = True
elif "username" in lowered_line:
if "username" in lowered_line:
is_username = True
elif "password" in lowered_line:
if "password" in lowered_line:
is_password = True
elif "click" in lowered_line or "login" in lowered_line:
if re.search("(log ?in)|button", lowered_line):
is_login = True
elif "welcome" in lowered_line:
if "welcome" in lowered_line:
is_welcome = True

if is_browser:
print("✔️ Found open browser step.")
if is_url:
print("✔️ Found specific URL in steps.")
if is_username:
print("✔️ Found mention of username field in steps.")
if is_password:
print("✔️ Found mention of password field in steps.")
if is_login:
print("✔️ Found login step.")
if is_welcome:
print("✔️ Found welcome page step.")

if is_browser and is_url and is_password and is_username and is_login and is_welcome:
print("Ready to proceed!")
print("Ready to proceed!")
else:
print("Not quite there yet! Did you remember browser, username, password or perhaps missing url? Did you verify your login succeeded?")
print("❌ Not quite there yet! Did you remember browser, username, password or perhaps missing url? Did you "
"verify your login succeeded and took you to the welcome page?")
sys.exit(1)

def main():
check_running_in_root()
check_file_exists()
check_content()

Expand Down
19 changes: 18 additions & 1 deletion setup/static.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import sys

ROBOT_ROOT_PATH = os.path.abspath(os.path.join(".", "robot"))
LOGIN_ROBOT_FILE = os.path.abspath(os.path.join(ROBOT_ROOT_PATH, "login.robot"))
INVALID_LOGIN_ROBOT = os.path.abspath(os.path.join(ROBOT_ROOT_PATH, "invalid_login.robot"))
Expand All @@ -8,5 +10,20 @@
else:
CURRENT_ENV["PYTHONPATH"] = f"setup{os.pathsep}"


def normalize(keyword):
return keyword.strip().title()
return keyword.strip().title()


def check_running_in_root():
current_folder = os.getcwd()
supposed_exercises_folder = os.path.abspath(os.path.join(current_folder, "exercises"))
supposed_setup_folder = os.path.abspath(os.path.join(current_folder, "setup"))

in_root = os.path.isdir(supposed_exercises_folder) and os.path.isdir(supposed_setup_folder)
if not in_root:
print(f"🚩 Hmm. It looks like the script is running in '{current_folder}' instead of the repo root folder.")
print("For the verification to work correctly, you need to run the script from the root of the repository ("
"probably named 'rf-katas').")
print("Try again, but double-check that you're running the verify script from the repository root.")
sys.exit(1)