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
from dataclasses import dataclass | |
from enum import Enum | |
class TaskStatus(str, Enum): | |
OPEN = "OPEN" | |
CLOSED = "CLOSED" | |
@dataclass |
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
import sqlite3 | |
import pytest | |
from models import Task, TaskStatus | |
from store import TaskStoreSQLite | |
@pytest.fixture | |
def connection(tmp_path) -> sqlite3.Connection: |
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
from dataclasses import dataclass | |
from enum import Enum | |
class TaskStatus(str, Enum): | |
OPEN = "OPEN" | |
CLOSED = "CLOSED" | |
@dataclass |
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
# behavior/tests.py | |
def test_add_task_(): | |
store = TaskStoreInMemory() | |
task = Task(title="Do the dishes", status=TaskStatus.OPEN) | |
store.add_task(task) | |
assert store.tasks[0].title == "Do the dishes" |
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
# behavior/store.py | |
class TaskStoreInMemory(TaskStore): | |
def __init__(self): | |
self._tasks = [] | |
def add_task(self, task: Task) -> None: | |
self._tasks.append(task) | |
def list_tasks(self) -> list[Task]: |
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
# behavior/models.py | |
from dataclasses import dataclass | |
from enum import Enum | |
class TaskStatus(str, Enum): | |
OPEN = "OPEN" | |
CLOSED = "CLOSED" | |
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
# implementation_details/models.py | |
from dataclasses import dataclass | |
from enum import Enum | |
class TaskStatus(str, Enum): | |
OPEN = "OPEN" | |
CLOSED = "CLOSED" | |
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
class Stick: | |
def __init__(self, color, length, weight): | |
self.color = color | |
self.length = length | |
self.weight = weight | |
stick = Stick('yellow', 1, 0.324) | |
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
def my_function(): | |
print('Hi') | |
print(my_function) | |
# <function my_function at 0x7efea5c36050> | |
def send_email_ses(email_message): | |
print(f'Send email using AWS SES: {email_message}') |
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
import datetime | |
class User: | |
def __init__(self, username, banned_until): | |
self.username = username | |
self.banned_until = banned_until | |
def save(self): | |
print('I am saving to PostgreSQL') |
NewerOlder