Example #1
0
    def __init__(self):
        self.pkg = None
        self.module = None
        self.func = None
        self.qname = None

        self.__tvars = None
        self.__threads = None
        self.__deps = None
        self.__drefs = None
        self.__dsources = []
        self.__instances = []

        self.__skipped = False
        self.__skip_code = None
        self.selected = False
        self.__unpicked = True
        self.__unpick_code = None

        self.consumed = False

        from arjuna.tpi import Arjuna
        self.console = Arjuna.get_console()
        self.logger = Arjuna.get_logger()
        self.central_config = Arjuna.get_central_config()
Example #2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     Arjuna.init(
         "/Users/rahulverma/Documents/github_tm/arjuna/arjuna-samples/workspace/arjex-new"
     )
     self.__automator = None
     self.__config = None
Example #3
0
 def __init__(self):
     self.files = []
     self.found_class_names = set()
     self.temp_map = {}
     from arjuna.tpi import Arjuna
     self.logger = Arjuna.get_logger()
     self.console = Arjuna.get_console()
Example #4
0
 def wrapper(actual_kallable):
     msg = "You are decorating {} in {} module with @skip by providing one or more arguments."
     msg += "Remove the arguments and proceed."
     Arjuna.get_console().display_error(msg.format(
             actual_kallable.__qualname__,
             actual_kallable.__module__
         ))
     sys_utils.fexit()
Example #5
0
 def init(self, root_dir, cli_config=None, run_id=None):
     self.__configurator.init(root_dir, cli_config)
     config = self.__configurator.create_project_conf()
     from arjuna.tpi import Arjuna
     Arjuna.init_logger(self.id,
                        config.arjuna_config.value(ArjunaOption.LOG_DIR))
     self.__databroker_handler = TestSessionDataBrokerHandler(
         self, self.__data_broker)
     self.__guimgr = GuiManager(config)
     return self.__create_config(config)
Example #6
0
 def __init__(self):
     self.lock = threading.RLock()
     self.__loading_completed = False
     self.__mlmap = {}
     from arjuna.tpi import Arjuna
     ref_config = Arjuna.get_ref_config()
     self.proj_dir = ref_config.get_arjuna_option_value(ArjunaOption.PROJECT_ROOT_DIR).as_str()
     self.test_dir = ref_config.get_arjuna_option_value(ArjunaOption.UNITEE_PROJECT_TESTS_DIR).as_str()
     self.logger = Arjuna.get_logger()
     self.console = Arjuna.get_console()
Example #7
0
 def __init__(self, pkg, module, qname):
     self.pkg = pkg
     self.module = module
     self.qname = qname
     from arjuna.tpi import Arjuna
     self.console = Arjuna.get_console()
     self.logger = Arjuna.get_logger()
     self.mdef = ModDef(pkg, module, qname)
     self._current_kall_ids = {}
     self._current_kall_decs = {}
     self.__multidecs = {}
     from arjuna.tpi import Arjuna
     self.unitee = Arjuna.get_unitee_instance()
Example #8
0
 def __validate_state(self, kallable, dec_type):
     if self.__loading_completed:
         ktype = type(kallable) is type and "class" or "function"
         from arjuna.tpi import Arjuna
         Arjuna.get_console().display_error(
             "You are decorating inner {} {} with {} in {} module. These decorators are ignored by Arjuna.".format(
                 ktype,
                 kallable.__qualname__,
                 dec_type,
                 kallable.__module__
             ))
         return False
     return True
Example #9
0
 def __init__(self, sname):
     super().__init__()
     self.name = sname
     self.config = ConfigContainer()
     self.fpath = None
     self.raw_contents = None
     self.root = None
     self.stage_defs = []
     self.tmcount = 0
     # self.evars.update(self.central_config.clone_evars())
     self.__iter = None
     self.__fixtures = FixturesDef()
     self.logger = Arjuna.get_logger()
     self.unitee = Arjuna.get_unitee_instance()
Example #10
0
 def __init__(self):
     self.lock = threading.RLock()
     from arjuna.tpi import Arjuna
     from arjuna.tpi.enums import ArjunaOption
     self.path = Arjuna.get_central_config().get_arjuna_option_value(
         ArjunaOption.UNITEE_PROJECT_RUN_REPORT_DIR).as_str(
         ) + "/ArjunaTestReport.xls"
Example #11
0
def test(my):
    automator = Arjuna.create_gui_automator()

    WPLoginLogout.login(automator)

    automator.element(With.link_text("Posts")).click()
    automator.element(With.link_text("Add New")).click()

    automator.element(With.id("title")).set_text("Sample")

    tinymce = With.id("tinymce")
    publish = With.id("publish")

    # Frame by identifier and jump to root
    automator.Frame(With.id("content_ifr")).focus()
    automator.element(tinymce).set_text("This is a test - frame by name.")
    automator.DomRoot().focus()
    automator.element(publish).click()

    # Frame by index
    automator.Frame(With.index(0)).focus()
    automator.element(tinymce).set_text("This is a test - frame by index.")
    automator.DomRoot().focus()
    automator.element(publish).click()

    # jump to parent frame
    frame = automator.Frame(With.xpath("//iframe"))
    frame.focus()
    automator.element(tinymce).set_text(
        "This is a test - jumping to parent after this.")
    frame.ParentFrame().focus()
    automator.element(publish).click()

    WPLoginLogout.logout(automator)
def test(my):

    automator = Arjuna.create_gui_automator()

    # Create Gui. Provide GNS file path
    app = DefaultGui(automator, "WordPress", "simpleapp/WordPress.gns")

    # Login
    app.Browser().go_to_url(automator.get_config().get_user_option_value("wp.login.url").as_string())
    app.Element("login").set_text("user")
    app.Element("password").set_text("bitnami")
    app.Element("submit").click()
    app.Element("view-site").wait_until_clickable()

    # Tweak Settings
    app.Element("settings").click()

    role_select = app.DropDown("role")
    print(role_select.has_visible_text_selected("Subscriber"))
    print(role_select.has_value_selected("subscriber"))
    print(role_select.has_index_selected(2))
    print(role_select.get_first_selected_option_text())
    role_select.select_by_value("editor")
    role_select.select_by_visible_text("Subscriber")
    role_select.select_by_index(4)

    # Logout
    app.Browser().go_to_url(automator.get_config().get_user_option_value("wp.logout.url").as_string())
    app.get_automator().quit()
Example #13
0
 def load_session(self, session_name):
     from arjuna.tpi import Arjuna
     from arjuna.unitee.test.defs.session import UserDefinedSessionDef
     sdir = Arjuna.get_central_config().get_arjuna_option_value(
         ArjunaOption.UNITEE_PROJECT_SESSIONS_DIR).as_str()
     session_file_path = os.path.join(sdir, session_name + ".xml")
     if not file_utils.is_file(session_file_path):
         Arjuna.get_console().display_error(
             "Not able to find session file {}.xml at {}".format(
                 session_name, sdir))
         sys_utils.fexit()
     sdef = UserDefinedSessionDef(session_name, session_file_path)
     sdef.process()
     self.__session = sdef.pick()
     self.__session.context = self.__create_test_context()
     self.__session.load()
Example #14
0
 def __init__(self, test_session, name, parent_config=None):
     self.__test_session = test_session
     self.__name = name
     self.__parent_config = parent_config and parent_config or None
     from arjuna.tpi import Arjuna
     self.__configs = {"default_config" : Arjuna.get_ref_config()}
     self.__conf_trace = dict()
Example #15
0
 def __init__(self, config=None):
     from arjuna.tpi import Arjuna
     self.__config = config and config or Arjuna.get_ref_config()
     self.__test_session = self.config.test_session
     self.__dom_root = None
     self.__main_window = None
     self.__browser = None
     self.__auto_context = None
Example #16
0
 def __get_pkg_module_qname_for_discovered_file(self, f):
     qname = None
     from arjuna.tpi import Arjuna
     project = Arjuna.get_central_arjuna_option(ArjunaOption.PROJECT_NAME).as_str()
     pkg = ".".join([project, f.attr(DiscoveredFileAttributeEnum.PACKAGE_DOT_NOTATION).strip()])
     module = f.attr(DiscoveredFileAttributeEnum.NAME).strip()
     qname = ".".join([pkg, module])
     return pkg, module, qname
Example #17
0
 def configure_fixture(fixdef, ftypestr, mname, fname):
     from arjuna.tpi import Arjuna
     fix_prefix = Arjuna.get_central_config().get_arjuna_option_value(
         ArjunaOption.UNITEE_PROJECT_FIXTURES_IMPORT_PREFIX).as_str()
     module = importlib.import_module(fix_prefix + mname)
     func = getattr(module, fname)
     fixdef.add_fixture_func(FixtureTypeEnum[ftypestr.upper()],
                             kfactory.create_fixture(ftypestr, func))
Example #18
0
    def execute(self, arg_dict):
        for parent in self.parents:
            parent.process(arg_dict)

        from arjuna.tpi import Arjuna
        project_root_dir = arg_dict["project.root.dir"]
        del arg_dict["project.root.dir"]
        Arjuna.init(project_root_dir, CliArgsConfig(arg_dict))

        import sys
        proj_dir = Arjuna.get_central_arjuna_option(ArjunaOption.PROJECT_ROOT_DIR).as_str()
        sys.path.append(proj_dir + "/..")

        py_3rdparty_dir = Arjuna.get_central_config().get_arjuna_option_value(ArjunaOption.ARJUNA_EXTERNAL_IMPORTS_DIR).as_str()
        sys.path.append(py_3rdparty_dir)
        self.unitee = Arjuna.get_unitee_instance()
        self.unitee.load_testdb()
Example #19
0
 def __init__(self, fpath, gname, rules_node):
     self.gname = gname
     self.fpath = fpath
     self.root = rules_node
     self.__rules = []
     from arjuna.tpi import Arjuna
     self.console = Arjuna.get_console()
     self.__process()
Example #20
0
 def __load_pick_all(gconfs):
     from arjuna.tpi import Arjuna
     central_config = Arjuna.get_central_config()
     arjuna_root_dir = central_config.get_arjuna_option_value(ArjunaOption.ARJUNA_ROOT_DIR).as_str()
     fpath = os.path.join(
         arjuna_root_dir,
         "res/st/magroup.xml"
     )
     group_xml = ETree.parse(fpath).getroot()
     group_name = group_xml.attrib['name']
     gconfs[group_name] = GroupConf(group_name, group_xml, fpath)
Example #21
0
 def __init__(self, totype):
     self.unitee = Arjuna.get_unitee_instance()
     self.__type = totype
     self.__tvars = None
     self.__thcount = 1
     self.__thname = None
     self.__iter = None
     self.__before_fixtures = []
     self.__after_fixtures = []
     self.__children = None
     self.__state = None
     self.__reported = False
Example #22
0
    def __init__(self):
        self.__dep_tree_builder = DepTreeBuilder()
        # For pulling out class definitions by name
        self.__skipped = []
        self.__unpicked = []

        self.__mdefs = {}
        self.__mqueue = []
        # The following gets populated from above, if classDef.isNotPickedByAnyGroup() is True
        self.__for_processor = []
        from arjuna.tpi import Arjuna
        self.logger = Arjuna.get_logger()
Example #23
0
    def __init__(self, sdef, stage_def, id, group_xml_from_session):
        super().__init__()
        self.unitee = Arjuna.get_unitee_instance()
        self.sdef = sdef
        self.stage_def = stage_def
        self.id = id
        self.root = group_xml_from_session
        self.__gconf = None
        self.__iter = None
        self.__process()

        self.__mnames = []
        self.__mod_fname_map = {}
Example #24
0
    def __init__(self, fpath, gname, pickers_node):
        self.gname = gname
        self.fpath = fpath
        self.root = pickers_node

        # Although using a set would give better performance, using a list so that pickers are evaluated
        # in the order they are specified.
        self._rule_dict = CIStringDict({
            'cm': [],
            'im': [],
            'cf': [],
            'if': []
        })

        self.__module_matcher = None
        self.__function_matcher = None

        from arjuna.tpi import Arjuna
        self.console = Arjuna.get_console()
        self.tm_prefix = Arjuna.get_central_config().get_arjuna_option_value(
            ArjunaOption.UNITEE_PROJECT_TEST_MODULE_IMPORT_PREFIX).as_str()
        self.__process()
Example #25
0
    def __load_user_gconfs(gconfs):
        from arjuna.tpi import Arjuna
        console = Arjuna.get_console()
        central_config = Arjuna.get_central_config()
        ugcdir = central_config.get_arjuna_option_value(ArjunaOption.CONFIG_DIR).as_str()
        ugfpath = os.path.join(ugcdir, "groups.xml")

        def display_err_and_exit(msg):
            console.display_error((msg + " Fix groups template file: {}").format(ugfpath))
            sys_utils.fexit()

        if not os.path.exists(ugfpath) or not os.path.isfile(ugfpath):
            return

        try:
            tree = ETree.parse(ugfpath)
        except Exception as e:
            print(e)
            display_err_and_exit("Groups definition file could not be loaded because of errors in XML.")
        else:
            root = tree.getroot()
            if root.tag != 'groups':
                display_err_and_exit("Invalid groups template file. Root element tag should be >>groups<<.")
            node_dict = etree_utils.convert_to_cidict(root)

            # Validate only group keys exist.
            if node_dict.keys() != {'group'}:
                display_err_and_exit(">>groups<< element can contain only one or more >>group<< elements.")
            elif not node_dict:
                display_err_and_exit(">>groups<< element must contain atleast one >>group<< element.")
            else:
                for group in list(root):
                    run_conf_utils.validate_group_xml_child("session", ugfpath, group)
                    group_attrs = etree_utils.convert_attribs_to_cidict(group)
                    name = group_attrs['name'].strip()
                    if not name:
                        display_err_and_exit(">>name<< attribute in group definition can not be empty.")
                    gconfs[name] = GroupConf(name, group, ugfpath)
def test(my):

    automator = Arjuna.create_gui_automator()

    home = HomePage(automator)
    home\
    .login()\
    .left_nav\
    .go_to_settings()\
    .tweak_settings()\
    .top_nav\
    .logout()

    automator.quit()
Example #27
0
def skip_me(kallable):
    from arjuna.tpi import Arjuna
    if obj_utils.callable(kallable):
        return Arjuna.get_unitee_instance().test_loader.register_skip_func(kallable)
    else:
        def wrapper(actual_kallable):
            msg = "You are decorating {} in {} module with @skip by providing one or more arguments."
            msg += "Remove the arguments and proceed."
            Arjuna.get_console().display_error(msg.format(
                    actual_kallable.__qualname__,
                    actual_kallable.__module__
                ))
            sys_utils.fexit()
        return wrapper
Example #28
0
 def __init__(self, config=None, extended_config=None):
     from arjuna.tpi import Arjuna
     self.__config = config and config or Arjuna.get_ref_config()
     self.__test_session = self.config.test_session
     self.__dom_root = None
     self.__main_window = None
     self.__browser = None
     self.__auto_context = None
     self._set_impl_automator(ImplGuiAutomator(config, extended_config))
     self._set_main_window(
         GuiAutoComponentFactory.MainWindow(
             self, self.impl_automator.main_window))
     self._set_browser(
         GuiAutoComponentFactory.Browser(self, self.impl_automator.browser))
Example #29
0
def test(my):
    automator = Arjuna.create_gui_automator()

    WPLoginLogout.login(automator)

    automator.element(With.link_text("Settings")).click()

    data_format = automator.RadioGroup(With.name("date_format"))
    print(data_format.has_value_selected("Y-m-d"))
    print(data_format.has_index_selected(1))
    print(data_format.get_first_selected_option_value())
    data_format.select_by_value(r"\c\u\s\t\o\m")
    data_format.select_by_index(2)

    WPLoginLogout.logout(automator)
def test(my):
    automator = Arjuna.create_gui_automator()

    WPLoginLogout.login(automator)

    automator.element(With.link_text("Posts")).click()
    automator.element(With.link_text("Categories")).click()

    checkboxes = automator.multi_element(With.name("delete_tags[]"))
    checkboxes.IndexedElement(0).uncheck()
    checkboxes.IndexedElement(0).check()
    checkboxes.IndexedElement(0).check()
    checkboxes.IndexedElement(1).check()

    WPLoginLogout.logout(automator)