def test_type_value(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test/html/click_test.html') panel = fixture_session.wait_for(LoginPanel) assert (panel.get_attribute('name', 'value') == 'John') panel.clear('name') panel.type('name', 'xuzg') assert (panel.get_attribute('name', 'value') == 'xuzg')
def main(): context = Context() context.logger.create_new_log_file() context.logger.info("Starting the program.") context.logger.info("Parsing arguments.") kwargs = cli_arguments() context.logger.info("Parsing arguments done.") if kwargs["paths"]: do_renamings(context, **kwargs) else: undo_renamings(context) context.logger.info("Exiting the program.")
def _queue_new_message(self, message: str, client_opt: dict = None): """ Queues an input to be processed by skills :param message: String formatted input text :param client_opt: Optional client context information :return: """ # print("Added new Message: {} to queue of length {}".format(message, len(self.inbound_fifo))) if message == "": return message = Context(message, self, client_opt) self.skill_handler.find_skills(message) message.run_next_skill()
def test_with_unsupported_platform(): with pytest.raises(UnsupportedOSError): get_editor_command(Context("MS-DOS"), Path("foobar"))
#!/usr/bin/env python import os from sys import argv from src.arg import process_args from src.context import Context if __name__ == '__main__': Context.set('APP_ROOT', os.path.dirname(os.path.abspath(__file__))) Context.set('APP_DIR', Context.get('APP_ROOT')) Context.set('DATA_DIR', "%s/data" % Context.get('APP_DIR')) process_args(argv[1:]) exit(0)
from src.context import Context from src.game import start from zs_globals import Settings from app.get_classes import get_all_classes entities, interfaces = get_all_classes() class_dict = {cls.__name__: cls for cls in entities} context = Context(class_dict, *interfaces) if __name__ == "__main__": start(Settings.APP_START, context).main()
def test_wait_for_element_locate_with_name(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test/html/click_test.html') panel = fixture_session.wait_for(ClickPanel) panel.wait_for_all_element_locate(name='single')
def webserver(args): sock_file = "%s/daemon.sock" % Context.get("DATA_DIR") srv = DaemonHTTPServer(sock_file, Handler) srv.serve_forever()
from pathlib import Path import os import pytest __import__("sys").path[0:0] = "." from src.context import Context from src.renamings import * from src.user_types import Arc from src.goodies import rm_tree context = Context("mockOS") logger = context.logger def test_rename(): """All renamings succeed.""" renamer = Renamer(context, testing=True) base = Path("test") / "happy_path" rm_tree(base) base.mkdir() arcs = [ Arc(base / "source_0", base / "target_0"), Arc(base / "source_1", base / "target_1"), Arc(base / "source_2", base / "target_2"), ] for arc in arcs: arc.source.touch() renamer.perform_renamings(arcs) assert set(base.iterdir()) == set(arc.target for arc in arcs) print(logger.get_contents()) assert logger.get_contents() == "\n".join([
def test_text_of(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test/html/click_test.html') panel = fixture_session.wait_for(ClickPanel) text = panel.text_of('double') assert (text == 'Double-click me')
def test_mouse_over(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test/html/click_test.html') panel = fixture_session.wait_for(MouseOverPanel) panel.hover('hover') assert (panel.text_of('hover') == 'I was Mouse-over!')
def test_page_jump_new(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test/html/click_test.html') panel = fixture_session.wait_for(ClickPanel) panel.click('jump new') assert (panel.context.browser.current_url == 'file:///D:/code/ppo/test.html')
def test_double_click_element(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test/html/click_test.html') panel = fixture_session.wait_for(ClickPanel) assert (panel.text_of('double') == 'Double-click me') panel.double_click('double') assert (panel.text_of('double') == 'I was double-clicked!')
def test_wait_for_element_locate_with_css_selector(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test/html/click_test.html') panel = fixture_session.wait_for(ClickPanel) panel.wait_for_all_element_locate(css_selector='#single_click')
def test_with_mock_os(): config_path = Path("test") / "workspace" / "config.json" if config_path.exists(): config_path.unlink() # Python 3.8 and newer: use `missing_ok`` parameter. context = Context("mockOS") assert get_editor_command(context, Path("foobar")) == "mock_default_command foobar"
def test_when_favorite_editor_is_set(): config_path = Path("test") / "workspace" / "config.json" config_path.write_text('{"editor_command": "mock_favorite_command"}') context = Context("mockOS") assert get_editor_command(context, Path("foobar")) == "mock_favorite_command foobar"
def test_find_ui_node(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test.html') panel = fixture_session.wait_for(PostPanel1) node = panel.find_ui_node('post1') assert (node['selector'] == 'body div:nth-child(1)') assert (node['name'] == 'post1')
def find_skills(self, msg: Context): """ Gets an ordered list of skills and attaches them to the message """ result = self.skill_handler.get_skills(msg.msg) # get list of skills from the skill handler result += self.fallback_skills # attach fallback skills to the end msg.set_skill(result) # set skill list in the message
def test_outer_html(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test/html/click_test.html') panel = fixture_session.wait_for(ClickPanel) outer_html = panel.outer_html('jump') assert ('id="jump"' in outer_html) assert ('a href=' in outer_html)
def __init__(self, args): self.args = args self.pid_file = "%s/daemon.pid" % Context.get("DATA_DIR") self.stop_file = "%s/daemon.stop" % Context.get("DATA_DIR")
def test_get_element_by_name(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test/html/click_test.html') panel = fixture_session.wait_for(ClickPanel) element = panel.get_element_by_name('jump') assert (isinstance(element, WebElement))
playground / "a/ab", playground / "a", playground / "b/ba", ] rm_tree(playground) for path in paths: path.parent.mkdir(parents=True, exist_ok=True) if not path.exists(): path.touch() print("Playground recreated. Now, have fun renaming some files and folders...") context = Context() context.logger.create_new_log_file() do_renamings(context, paths=paths) input("Press Enter to show the log file...") print(context.logger.get_contents()) input("Press Enter to revert the previous renamings...") context.logger.create_new_log_file() undo_renamings(context) input("Press Enter to show the log file...") print(context.logger.get_contents()) input("Press Enter to erase the playground...") rm_tree(playground)
def test_get_attributes(fixture_session: Context): fixture_session.browser.get('file:///D:/code/ppo/test/html/click_test.html') panel = fixture_session.wait_for(ClickPanel) attrs = panel.get_attributes('single') assert (attrs['id'] == 'single_click') assert (attrs['onclick'] == 'SingleClick()')