Commit 719d4d46 authored by lopezaguilar's avatar lopezaguilar
Browse files

Improve scripts for documentation

parent b1791947
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
import os
import robot
from os import listdir
from os.path import isdir, dirname, abspath, join
from robot import run


def find_test_data_in_tc(dir, filename, run_matching_tc):
    for file in os.listdir(dir):
        path = dir + "/" + file
        if os.path.isdir(path):
            find_test_data_in_tc(path, filename, run_matching_tc)
def find_test_data_in_tc(dir_name, filename, execute):
    for file in listdir(dir_name):
        path = dir_name + "/" + file
        if isdir(path):
            find_test_data_in_tc(path, filename, execute)
        else:
            if filename in open(path).read():
                if run_matching_tc == "Y":
                    robot.run(path)
                if execute == "Y":
                    run(path)
                print(path)


if __name__ == '__main__':
    # Get the folder of the tests
    base_folder = dirname(dirname(abspath(__file__)))
    test_suite_folder = join(base_folder, "TP")

    test_data_file = input("Name of test data file to search for: ")
    run_matching_tc = input("Run matching Test Cases (Y/N)?: ")
    find_test_data_in_tc("TP", test_data_file, run_matching_tc)
    find_test_data_in_tc(dir_name=test_suite_folder, filename=test_data_file, execute=run_matching_tc)
+33 −14
Original line number Diff line number Diff line
import os
from os import listdir
from os.path import isfile, isdir, dirname, abspath, join
from colorama import Fore, Style


def list_files_in_dir(dirname):
    for fname in os.listdir(dirname):
        if os.path.isfile(dirname + "/" + fname):
            print("Looking at test data file: ", fname)
            find_test_data_in_tc("TP", fname)
def list_files_in_dir(test_suite_folder, data_folder):
    for filename in listdir(data_folder):
        aux = join(data_folder, filename)
        if isfile(aux):
            print(Style.RESET_ALL)
            print("Looking at test data file: ", filename)
            found = find_test_data_in_tc(dir_name=test_suite_folder, filename=filename)
            if not found:
                print(Fore.RED + "    Usage not found")

        else:
            list_files_in_dir(dirname + "/" + fname)
            list_files_in_dir(test_suite_folder=test_suite_folder, data_folder=aux)


def find_test_data_in_tc(dir, filename):
    for file in os.listdir(dir):
        path = dir + "/" + file
        if os.path.isdir(path):
            find_test_data_in_tc(path, filename)
def find_test_data_in_tc(dir_name, filename):
    found = False
    for file in listdir(dir_name):
        path = join(dir_name, file)
        if isdir(path):
            aux = find_test_data_in_tc(path, filename)
            found = aux or found
        else:
            if filename in open(path).read():
                print("Found usage of", filename, "in", path)
                found = True
                print(Fore.GREEN + "    Found usage of", filename, "in", path)

    return found


if __name__ == '__main__':
    # Get the folder of the tests
    base_folder = dirname(dirname(abspath(__file__)))

    test_suite_folder = join(base_folder, "TP")
    data_folder = join(base_folder, 'data')

list_files_in_dir("data")
    list_files_in_dir(test_suite_folder=test_suite_folder, data_folder=data_folder)