Пример #1
0
def test_can_be_instantiated():
    """Actor can be instantiated"""
    a1 = Actor.named("test")
    a2 = Actor.named("test").can(None)
    a3 = Actor.named("test").who_can(None)
    a4 = AnActor.named("test")

    assert isinstance(a1, Actor)
    assert isinstance(a2, Actor)
    assert isinstance(a3, Actor)
    assert isinstance(a4, Actor)
Пример #2
0
    def perform_as(self, the_actor: Actor) -> None:
        """
        Direct the actor to search github for the given term.

        Args:
            the_actor: the actor who will perform this task.
        """
        the_actor.attempts_to(
            Enter.the_text(self.search_query).into(SEARCH_INPUT).then_hit(
                Keys.RETURN),
            Wait.for_the(RESULTS_MESSAGE),
        )
Пример #3
0
    def perform_as(self, the_actor: Actor) -> None:
        """
        Asks the actor to perform the Enter2FAToken action, which will get the
        current token using the actor's AuthenticateWith2FA ability.

        Args:
            the_actor: the |Actor| who will perform this action.

        Raises:
            |UnableToPerformError|: if the actor does not have the
                abilities to |AuthenticateWith2FA| and |BrowseTheWeb|.
        """
        token = the_actor.uses_ability_to(AuthenticateWith2FA).to_get_token()
        the_actor.attempts_to(Enter.the_text(token).into_the(self.target))
Пример #4
0
def test_forgets_abilities_when_exiting():
    """Actors forget their abilities when they exit"""
    mocked_ability = mock.Mock()
    mocked_ability.forget = mock.Mock()
    actor = Actor.named("test").who_can(mocked_ability)

    actor.exit()

    mocked_ability.forget.assert_called_once()
    assert len(actor.abilities) == 0
Пример #5
0
def fixture_actor() -> Generator:
    """Create the actor for our example tests!"""
    the_actor = Actor.named("Perry").who_can(BrowseTheWeb.using(Firefox()))
    yield the_actor
    the_actor.exit_stage_left()
Пример #6
0
def test_remembers_abilities():
    """Actors remember abilities granted to them"""
    ability = 1
    actor = Actor.named("test").who_can(ability)

    assert actor.ability_to(int) is ability
Пример #7
0
 def setUp(self):
     self.perry = Actor.named("Perry").who_can(BrowseTheWeb.using(Firefox()))