-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbbba0f
commit 91c7d45
Showing
13 changed files
with
310 additions
and
338 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,18 @@ | ||
from unittest.mock import ANY, Mock | ||
from unittest.mock import ANY | ||
|
||
from cibo.actions.connect import Connect | ||
from tests.conftest import ClientFactory, ConnectActionFactory | ||
|
||
|
||
def test_aliases(): | ||
connect = Connect(Mock(), Mock(), Mock()) | ||
class TestConnectAction(ClientFactory, ConnectActionFactory): | ||
def test_aliases(self): | ||
assert not self.connect.aliases() | ||
|
||
assert not connect.aliases() | ||
def test_required_args(self): | ||
assert not self.connect.required_args() | ||
|
||
def test_process(self): | ||
self.connect.process(self.mock_client, None, []) | ||
|
||
def test_required_args(): | ||
connect = Connect(Mock(), Mock(), Mock()) | ||
|
||
assert not connect.required_args() | ||
|
||
|
||
def test_process(): | ||
output = Mock() | ||
connect = Connect(Mock(), Mock(), output) | ||
client = Mock() | ||
|
||
connect.process(client, None, []) | ||
|
||
output.private.assert_called_once_with(client, ANY, justify="center") | ||
self.output.private.assert_called_once_with( | ||
self.mock_client, ANY, justify="center" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,39 @@ | ||
from unittest.mock import Mock | ||
|
||
from cibo.actions.disconnect import Disconnect | ||
from cibo.client import Client | ||
from tests.conftest import ClientFactory, DisconnectActionFactory | ||
|
||
|
||
def test_aliases(): | ||
connect = Disconnect(Mock(), Mock(), Mock()) | ||
class TestDisconnectAction(ClientFactory, DisconnectActionFactory): | ||
def test_aliases(self): | ||
assert not self.disconnect.aliases() | ||
|
||
assert not connect.aliases() | ||
def test_required_args(self): | ||
assert not self.disconnect.required_args() | ||
|
||
def test_process_not_logged_in(self): | ||
self.mock_client.player = Mock() | ||
|
||
def test_required_args(): | ||
connect = Disconnect(Mock(), Mock(), Mock()) | ||
self.disconnect.process(self.mock_client, None, []) | ||
|
||
assert not connect.required_args() | ||
self.mock_client.player.send.assert_not_called() | ||
self.output.private.assert_not_called() | ||
|
||
def test_process_no_player(self): | ||
self.disconnect.process(self.mock_client, None, []) | ||
|
||
def test_process_not_logged_in(mock_client: Client): | ||
output = Mock() | ||
connect = Disconnect(Mock(), Mock(), output) | ||
self.output.private.assert_not_called() | ||
|
||
mock_client.player = Mock() | ||
def test_process(self): | ||
self.mock_client.player = Mock() | ||
self.mock_client.player.name = "John" | ||
self.mock_client.player.current_room_id = 1 | ||
self.mock_client.is_logged_in.return_value = True | ||
|
||
connect.process(mock_client, None, []) | ||
self.disconnect.process(self.mock_client, None, []) | ||
|
||
mock_client.player.send.assert_not_called() | ||
output.private.assert_not_called() | ||
|
||
|
||
def test_process_no_player(mock_client: Client): | ||
output = Mock() | ||
connect = Disconnect(Mock(), Mock(), output) | ||
|
||
connect.process(mock_client, None, []) | ||
|
||
output.private.assert_not_called() | ||
|
||
|
||
def test_process(mock_client: Client): | ||
output = Mock() | ||
connect = Disconnect(Mock(), Mock(), output) | ||
|
||
mock_client.player = Mock() | ||
mock_client.player.name = "John" | ||
mock_client.player.current_room_id = 1 | ||
mock_client.is_logged_in.return_value = True | ||
|
||
connect.process(mock_client, None, []) | ||
|
||
mock_client.player.save.assert_called_once() | ||
output.local.assert_called_once_with( | ||
1, | ||
"You watch in horror as [cyan]John[/] proceeds to slowly eat their own head. They eventually disappear into nothingness.", | ||
[mock_client], | ||
) | ||
self.mock_client.player.save.assert_called_once() | ||
self.output.local.assert_called_once_with( | ||
1, | ||
"You watch in horror as [cyan]John[/] proceeds to slowly eat their own head. They eventually disappear into nothingness.", | ||
[self.mock_client], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,16 @@ | ||
from unittest.mock import Mock | ||
from tests.conftest import ClientFactory, ErrorActionFactory | ||
|
||
from cibo.actions.error import Error | ||
|
||
class TestErrorAction(ClientFactory, ErrorActionFactory): | ||
def test_aliases(self): | ||
assert not self.error.aliases() | ||
|
||
def test_aliases(): | ||
error = Error(Mock(), Mock(), Mock()) | ||
def test_required_args(self): | ||
assert self.error.required_args() == ["message"] | ||
|
||
assert not error.aliases() | ||
def test_process(self): | ||
self.error.process(self.mock_client, None, ["Something unexpected happened!"]) | ||
|
||
|
||
def test_required_args(): | ||
error = Error(Mock(), Mock(), Mock()) | ||
|
||
assert error.required_args() == ["message"] | ||
|
||
|
||
def test_process(): | ||
output = Mock() | ||
error = Error(Mock(), Mock(), output) | ||
client = Mock() | ||
|
||
error.process(client, None, ["Something unexpected happened!"]) | ||
|
||
output.private.assert_called_once_with( | ||
client, "[bright_red]Something unexpected happened![/]" | ||
) | ||
self.output.private.assert_called_once_with( | ||
self.mock_client, "[bright_red]Something unexpected happened![/]" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,14 @@ | ||
from unittest.mock import Mock | ||
from tests.conftest import ClientFactory, PromptActionFactory | ||
|
||
from cibo.actions.prompt import Prompt | ||
from cibo.client import Client | ||
|
||
class TestPromptAction(ClientFactory, PromptActionFactory): | ||
def test_aliases(self): | ||
assert not self.prompt.aliases() | ||
|
||
def test_aliases(): | ||
prompt = Prompt(Mock(), Mock(), Mock()) | ||
def test_required_args(self): | ||
assert not self.prompt.required_args() | ||
|
||
assert not prompt.aliases() | ||
def test_process(self): | ||
self.prompt.process(self.mock_client, None, []) | ||
|
||
|
||
def test_required_args(): | ||
prompt = Prompt(Mock(), Mock(), Mock()) | ||
|
||
assert not prompt.required_args() | ||
|
||
|
||
def test_process(client: Client): | ||
output = Mock() | ||
output.prompt = Mock() | ||
prompt = Prompt(Mock(), Mock(), output) | ||
|
||
prompt.process(client, None, []) | ||
|
||
output.prompt.assert_called_once_with(client) | ||
self.output.prompt.assert_called_once_with(self.mock_client) |
Oops, something went wrong.