Skip to content

Commit

Permalink
Fix two issues with dragonfly's mocked actions
Browse files Browse the repository at this point in the history
- Make each mocked action refer to a class instead.
- Replace mock_dyn_str_action with a mocked Mouse class, as that
  action is the only DynStrActionBase sub-class left that isn't
  implemented for other platforms.
  • Loading branch information
drmfinlay committed Apr 22, 2019
1 parent db2c307 commit 0fadf16
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions dragonfly/os_dependent_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,32 @@
Heavily modified to allow more dragonfly functionality to work
regardless of operating system.
"""

from .actions import ActionBase, DynStrActionBase


# Mock ActionBase and DynStrActionBase classes
class MockBase(object):
def __init__(self, *args, **kwargs):
pass


def mock_action(*args, **kwargs):
return ActionBase()
class MockAction(ActionBase):
""" Mock class for dragonfly actions. """
def __init__(self, *args, **kwargs):
ActionBase.__init__(self)


def mock_dyn_str_action(*args, **kwargs):
return DynStrActionBase(*args, **kwargs)
class Mouse(DynStrActionBase):
""" Mock Mouse action class. """
def __init__(self, spec=None, static=False):
DynStrActionBase.__init__(self, spec, static)


Paste = mock_dyn_str_action
Mouse = mock_dyn_str_action
WaitWindow = mock_action
FocusWindow = mock_action
StartApp = mock_action
BringApp = mock_action
PlaySound = mock_action
WaitWindow = MockAction
FocusWindow = MockAction
StartApp = MockAction
BringApp = MockAction
PlaySound = MockAction


class _WindowInfo(object):
Expand All @@ -54,11 +60,6 @@ def get_foreground():
return _WindowInfo


class MockBase(object):
def __init__(self, *args, **kwargs):
pass


class HardwareInput(MockBase):
pass

Expand Down

0 comments on commit 0fadf16

Please sign in to comment.