add go-license

This commit is contained in:
Timo Zimmermann 2025-02-27 17:06:37 +00:00
commit 0ddeb7d4aa
16 changed files with 462 additions and 0 deletions

View file

37
parameterize/app/code.py Normal file
View file

@ -0,0 +1,37 @@
# coding: utf-8
import logging
from waffle import switch_is_active
logger = logging.getLogger("app_tests")
def simple(name: str) -> str:
name = name.replace(" ", "-")
name = name.lower()
return name
def complex_function(x: int, y: int) -> int:
if switch_is_active("new_complex"):
return rewrite_complex_function(x, y)
return deprecated_complex_function(x, y)
def rewrite_complex_function(x: int, y: int) -> int:
logger.info("rewrite complex")
return x * y
def deprecated_complex_function(x: int, y: int) -> int:
def foo() -> int:
return int(True)
logger.info("deprecated complex")
return x * y * foo()
def foo():
x = Double(3.4)

25
parameterize/app/tests.py Normal file
View file

@ -0,0 +1,25 @@
# coding: utf-8
import pytest
from waffle.testutils import override_switch
from app.code import simple, complex_function
@pytest.mark.parametrize(
"name",
(
"foo bar",
"baz zab",
"1 2 3 4 5"
)
)
def test_simple(name):
assert " " not in simple(name)
@pytest.mark.parametrize("switch", (True, False))
@pytest.mark.django_db
def test_complex_function(switch):
with override_switch("new_complex", active=switch):
assert complex_function(2, 2) == 4