Skip to content

Commit

Permalink
feat: Add RPA integration examples and tests (#71)
Browse files Browse the repository at this point in the history
* Add RPA integration examples and tests

* Add RPA integration examples and tests

* Refactor RPA integration examples and tests

* Refactor RPA integration examples and tests

* Refactor RPA integration tests and add pytest marker

* Refactor RPA integration tests and examples

* Refactor RPA integration: Remove unused local helper functions
  • Loading branch information
theijhay authored Jan 22, 2025
1 parent 7a0116e commit b76647a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/linux_desktop/rpa_python/home.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from guara.transaction import AbstractTransaction


class SubmitTextRPA(AbstractTransaction):
"""
Submits text using RPA for Python
Args:
text (str): The text to be submitted
"""

def __init__(self, driver):
super().__init__(driver)

def do(self, text):
self._driver.init()
self._driver.type(text)
self._driver.keyboard("[enter]")
29 changes: 29 additions & 0 deletions examples/linux_desktop/rpa_python/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from guara.transaction import AbstractTransaction


class OpenApplication(AbstractTransaction):
"""
Opens an application using RPA for Python
Args:
app_path (str): the path to the application executable.
"""

def __init__(self, driver):
super().__init__(driver)

def do(self, app_path):
self._driver.init()
self._driver.run(app_path)


class CloseApplication(AbstractTransaction):
"""
Closes an application using RPA for Python
"""

def __init__(self, driver):
super().__init__(driver)

def do(self):
self._driver.close()
24 changes: 24 additions & 0 deletions examples/linux_desktop/rpa_python/test_rpa_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import rpa as r
import pytest
from guara.transaction import Application
from guara import it
from examples.linux_desktop.rpa_python import setup
from examples.linux_desktop.rpa_python import home


@pytest.mark.skip(reason="Complex setup in CI environment")
class TestRPAIntegration:
"""
TestRPAIntegration is a test class for integrating RPA for Python with a local application.
"""

def setup_method(self, method):
self._app = Application(r)
self._app.at(setup.OpenApplication, app_path="path/to/application.exe")

def teardown_method(self, method):
self._app.at(setup.CloseApplication)

def test_submit_text(self):
text = "Hello, RPA for Python!"
self._app.at(home.SubmitTextRPA, text=text).asserts(it.IsEqualTo, text)
2 changes: 2 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ pyautogui
opencv-python
dogtail
splinter
rpa

0 comments on commit b76647a

Please sign in to comment.