Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
wesker-albert committed Aug 1, 2023
1 parent 2baba10 commit f605ec7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type_check:
@poetry run mypy

formatting:
@poetry run black --diff --check cibo/
@poetry run black --diff --check ./cibo ./tests

test:
@poetry run pytest --durations=5
Expand Down
12 changes: 10 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from cibo.events.connect import ConnectEvent
from cibo.events.disconnect import DisconnectEvent
from cibo.events.input import InputEvent
from cibo.models.room import Room, RoomDescription
from cibo.models.room import Direction, Room, RoomDescription, RoomExit
from cibo.output import Output
from cibo.resources.doors import Doors
from cibo.resources.rooms import Rooms
Expand All @@ -25,6 +25,7 @@ class BaseFactory:
def fixture_base(self) -> None:
self.telnet = Mock()
self.output = Mock()
yield


class ClientFactory:
Expand Down Expand Up @@ -165,5 +166,12 @@ def fixture_room(self) -> Room:
smell=None,
listen=None,
),
exits=[],
exits=[
RoomExit(direction=Direction.NORTH, id_=2, description=None),
RoomExit(direction=Direction.EAST, id_=3, description=None),
RoomExit(direction=Direction.SOUTH, id_=4, description=None),
RoomExit(direction=Direction.WEST, id_=5, description=None),
RoomExit(direction=Direction.UP, id_=6, description=None),
RoomExit(direction=Direction.DOWN, id_=7, description=None),
],
)
33 changes: 7 additions & 26 deletions tests/resources/test_rooms.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
from pytest import raises

from cibo.exception import ResourceNotFound
from cibo.models.room import Direction, Room, RoomDescription, RoomExit
from cibo.models.room import Direction, Room, RoomExit
from tests.conftest import WorldFactory


class TestRooms(WorldFactory):
def test_get_by_id(self):
room = self.rooms.get_by_id(1)

assert room == Room(
id_=1,
name="A Room Marked #1",
description=RoomDescription(
normal="The walls and floor of this room are a bright, sterile white. You feel as if you are inside a simulation.",
extra=None,
night=None,
under=None,
behind=None,
above=None,
smell=None,
listen=None,
),
exits=[
RoomExit(direction=Direction.NORTH, id_=2, description=None),
RoomExit(direction=Direction.EAST, id_=3, description=None),
RoomExit(direction=Direction.SOUTH, id_=4, description=None),
RoomExit(direction=Direction.WEST, id_=5, description=None),
RoomExit(direction=Direction.UP, id_=6, description=None),
RoomExit(direction=Direction.DOWN, id_=7, description=None),
],
)
def test_get_by_id(self, room: Room):
fetched_room = self.rooms.get_by_id(1)

assert fetched_room == room

def test_get_by_id_not_found(self):
with raises(ResourceNotFound):
Expand Down Expand Up @@ -60,6 +39,8 @@ def test_get_formatted_exits_single_exit(self, room: Room):
assert self.rooms.get_formatted_exits(room) == "[green]Exit:[/] north"

def test_get_formatted_exits_none(self, room: Room):
room.exits = []

assert self.rooms.get_formatted_exits(room) == "[green]Exits:[/] none"

def test_get_direction_exit(self, room: Room):
Expand Down

0 comments on commit f605ec7

Please sign in to comment.