This file contains hidden or 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 pydantic.dataclasses import dataclass | |
@dataclass | |
class Customer: | |
id: int | |
name: str | |
address: str | |
city: str | |
state: str | |
zip_code: int |
This file contains hidden or 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
@dataclass | |
class Customer: | |
id: int | |
name: str | |
address: str | |
city: str | |
state: str | |
zip_code: int |
This file contains hidden or 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 inject | |
from src.xpto.common.models.order import Order | |
from src.xpto.invoices.models.invoice import Invoice | |
from src.xpto.invoices.repositories.invoice_repository import InvoiceRepository | |
class CreateInvoiceService: | |
@inject.autoparams() |
This file contains hidden or 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 inject | |
from src.xpto.invoices.repositories.invoice_repository import InvoiceRepository | |
from src.xpto.invoices.repositories.mongodb.MongoDBInvoiceRepository import MongoDBInvoiceRepository | |
def ioc_config(binder): | |
binder.bind(InvoiceRepository, MongoDBInvoiceRepository()) | |
This file contains hidden or 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 abc import abstractmethod | |
from typing import List, Protocol, runtime_checkable | |
from src.domain.customer.customer import Customer | |
@runtime_checkable | |
class CustomerRepository(Protocol): | |
@abstractmethod |
This file contains hidden or 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 abc import abstractmethod | |
from typing import List, Protocol, runtime_checkable | |
from dataclasses import dataclass | |
@dataclass | |
class Customer: | |
id: int | |
name: str |
This file contains hidden or 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 MongoCustomerRepository(CustomerRepository): | |
def get_customers(self) -> List[Customer]: | |
return [Customer(1, 'xpto'), Customer(2, 'foo bar')] | |
def get_special_customers(self) -> List[Customer]: | |
return [Customer(1, 'xpto')] | |
This file contains hidden or 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 abc import abstractmethod | |
from typing import List, Protocol | |
from dataclasses import dataclass | |
@dataclass | |
class Customer: | |
id: int | |
name: str |
This file contains hidden or 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 tracemalloc | |
class Tracer: | |
"""Traces the memory being allocated""" | |
def __enter__(self): | |
if tracemalloc.is_tracing(): | |
raise ValueError("Cant nest Tracers") | |
self.bytes_allocated = None |
This file contains hidden or 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 unittest | |
from pyravendb.commands.raven_commands import GetDocumentCommand | |
from pyravendb.custom_exceptions.exceptions import InvalidOperationException | |
from pyravendb.data.document_conventions import DocumentConventions | |
from pyravendb.tests.test_base import TestBase | |
class Address: | |
def __init__(self, street, city, state): |