-
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
Showing
6 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .internal.color import Color | ||
from .internal.cursor import Cursor |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from enum import Enum | ||
from random import randint | ||
|
||
class Color(Enum): | ||
RED = "RED" | ||
YELLOW = "YELLOW" | ||
GREEN = "GREEN" | ||
BLUE = "BLUE" | ||
|
||
@staticmethod | ||
def get_random(): | ||
rand_idx = randint(0, len(Color._member_names_) - 1) | ||
color = Color._member_names_[rand_idx] | ||
return Color._member_map_[color] |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from board import Point | ||
from .color import Color | ||
from dataclasses import dataclass | ||
|
||
@dataclass | ||
class Cursor: | ||
conn_id: str | ||
position: Point | ||
pointer: Point | None | ||
color: Color | ||
|
||
@staticmethod | ||
def create(conn_id: str): | ||
return Cursor( | ||
conn_id=conn_id, | ||
position=Point(0, 0), | ||
pointer=None, | ||
color=Color.get_random() | ||
) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from .cursor_test import CursorTestCase |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from cursor import Cursor, Color | ||
import unittest | ||
|
||
class CursorTestCase(unittest.TestCase): | ||
def test_cursor_create(self): | ||
conn_id = "some id" | ||
cursor = Cursor.create(conn_id) | ||
|
||
self.assertEqual(cursor.conn_id, conn_id) | ||
self.assertEqual(cursor.position.x, 0) | ||
self.assertEqual(cursor.position.y, 0) | ||
self.assertIsNone(cursor.pointer) | ||
self.assertIn(cursor.color, Color) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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