-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new field types and format source
- Loading branch information
Showing
11 changed files
with
141 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Python Formatting | ||
on: [push, pull_request] | ||
|
||
concurrency: | ||
group: test-${{ github.head_ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
PYTHONUNBUFFERED: "1" | ||
FORCE_COLOR: "1" | ||
|
||
jobs: | ||
run: | ||
name: Python Formatting on 'Linux' | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: [ "3.10" ] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Hatch | ||
run: pip install --upgrade hatch | ||
- name: Run linting | ||
run: hatch run lint:all | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest | ||
black==24.3.0 | ||
coverage[toml]>=6.5 |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from datetime import datetime | ||
from typing import Type, Any | ||
|
||
import pytest | ||
|
||
from src.couch_potato._types import Field | ||
from src.couch_potato.fields import Float, String, Integer, Boolean, DateTime | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"field_class, value, expected_result", | ||
[ | ||
pytest.param(Integer, 1, 1, id="Integer"), | ||
pytest.param(Float, 1.0, 1.0, id="Float"), | ||
pytest.param(String, "foobar", "foobar", id="String"), | ||
pytest.param(Boolean, True, True, id="Boolean"), | ||
pytest.param( | ||
DateTime, | ||
datetime(2024, 3, 23, 0, 0, 0), | ||
"2024-03-23T00:00:00", | ||
id="DateTime", | ||
), | ||
], | ||
) | ||
def test_field_serialize(field_class: Type[Field], value: Any, expected_result: Any): | ||
field = field_class() | ||
serialized_value = field.serialize(value) | ||
assert serialized_value == expected_result | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"field_class, value, expected_result", | ||
[ | ||
pytest.param(Integer, 1, 1, id="Integer"), | ||
pytest.param(Float, 1.0, 1.0, id="Float"), | ||
pytest.param(String, "foobar", "foobar", id="String"), | ||
pytest.param(Boolean, True, True, id="Boolean"), | ||
pytest.param( | ||
DateTime, | ||
"2024-03-23T00:00:00", | ||
datetime(2024, 3, 23, 0, 0, 0), | ||
id="DateTime", | ||
), | ||
], | ||
) | ||
def test_field_deserialize(field_class: Type[Field], value: Any, expected_result: Any): | ||
field = field_class() | ||
serialized_value = field.deserialize(value) | ||
assert serialized_value == expected_result |