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 django.contrib import admin | |
from shop.models import Cart, Item, CartItem | |
class ItemInline(admin.StackedInline): | |
model = CartItem | |
extra = 5 | |
class CartAdmin(admin.ModelAdmin): |
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 django.db import models | |
class Item(models.Model): | |
name = models.CharField(max_length=100) | |
price = models.DecimalField(default=0, decimal_places=2, max_digits=10) | |
def __str__(self): | |
return f"{self.name}: ${self.price}" |
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 dataclasses | |
from dataclasses import dataclass | |
from decimal import Decimal | |
@dataclass(frozen=True) | |
class Account: | |
amount: Decimal | |
blocked: Decimal |
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 dataclasses | |
from dataclasses import dataclass | |
from decimal import Decimal | |
@dataclass(frozen=True) | |
class Account: | |
amount: Decimal | |
blocked: Decimal |
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 pytest | |
from decimal import Decimal | |
from main import Account | |
class TestNormalAccount: | |
def test_add_amount(self) -> None: | |
account = Account( | |
amount=Decimal(10), | |
blocked=Decimal(0), |
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 pytest | |
from decimal import Decimal | |
from main import Account | |
class TestNormalAccount: | |
def test_add_amount(self) -> None: | |
account = Account( | |
amount=Decimal(10), | |
blocked=Decimal(0), |
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 decimal import Decimal | |
@dataclass | |
class Account: | |
amount: Decimal | |
blocked: Decimal | |
def add_amount(self, amount: Decimal) -> None: |
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 engine.engine import Engine | |
from gasoline.gasoline import Gasoline, GasPortion | |
from gaspump.gaspump import GasPump | |
from pedal.pedal import Pedal | |
class TestEverythingTogether: | |
def test_everything_ok(self) -> None: | |
""" | |
Here is the scenario: |
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 gasoline.gasoline import GasPortion, Gasoline | |
from gaspump.gaspump import GasPump | |
from pedal.pedal import Pedal | |
class Benzine(Gasoline): | |
pass | |
class TestPedal: |
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 gasoline.gasoline import GasPortion | |
from gaspump.gaspump import GasPump | |
@dataclass | |
class Pedal: | |
connected_gas_pump: GasPump |
NewerOlder