Skip to content

Commit

Permalink
tests: Cover missing tests and kill_cache for coveralls badge
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-pl committed Jul 26, 2024
1 parent c4265a4 commit 74ffff8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# UPTo

![tests](https://github.com/lu-pl/upto/actions/workflows/tests.yml/badge.svg)
[![coverage](https://coveralls.io/repos/github/lu-pl/upto/badge.svg?branch=main)](https://coveralls.io/github/lu-pl/upto?branch=main)
[![coverage](https://coveralls.io/repos/github/lu-pl/upto/badge.svg?branch=main)](https://coveralls.io/github/lu-pl/upto?branch=main&kill_cache=1)
[![PyPI version](https://badge.fury.io/py/upto.svg)](https://badge.fury.io/py/upto)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_compose_router.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Pytest entry point for upto.ComposeRouter tests."""

import pytest

from toolz import compose
from upto import ComposeRouter

Expand All @@ -23,3 +25,18 @@ def method(self, x, y):

no_route = foo.method(2, 3)
assert foo.route.method(2, 3) == compose(*_components)(no_route)


def test_simple_compse_router_unregistered_fail():
_components = [lambda x: x + 1, lambda y: y * 2]

class Foo:
route = ComposeRouter(*_components)

def method(self, x, y):
return x * y

foo = Foo()

with pytest.raises(AttributeError):
foo.route.method(2, 3)
6 changes: 5 additions & 1 deletion upto/pydantic_tools/curry_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

class CurryModel[ModelType: BaseModel]:
"""Constructor for currying a Pydantic Model.
Example:
class MyModel(BaseModel):
x: str
y: int
z: tuple[str, int]
curried_model = CurryModel(MyModel)
curried_model(x="1")
curried_model(y=2)
model_instance = curried_model(z=("3", 4))
print(model_instance)
"""
Expand All @@ -24,7 +28,7 @@ def __init__(self, model: type[ModelType]) -> None:
self._kwargs_cache: dict = {}
self._model_fields: dict = model.model_fields

def __repr__(self):
def __repr__(self): # pragma: no cover
return f"CurryModel object {self._kwargs_cache}"

@staticmethod
Expand Down

0 comments on commit 74ffff8

Please sign in to comment.