Skip to content

Commit

Permalink
Initialize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
koldakov committed Dec 30, 2023
1 parent 958d280 commit a2a1c23
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Futuramaapi

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff pytest
pip install -r requirements.txt
- name: Ruff
run: |
ruff --output-format=github .
- name: Pytest
run: |
python -m pytest -p tests.plugins.env_vars
Empty file.
18 changes: 18 additions & 0 deletions app/repositories/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from app.repositories.models import to_camel


class TestModelUtils:
def test_to_camel_should_return_snake_case_when_lower_case_text_has_one_underline(
self
):
assert to_camel("snake_case") == "snakeCase"

def test_to_camel_should_return_snake_case_when_lower_case_text_has_two_underlines(
self
):
assert to_camel("snake_case_snake") == "snakeCaseSnake"

def test_to_camel_should_return_snake_case_when_upper_case_text_has_one_underline(
self
):
assert to_camel("SNAKE_CASE") == "snakeCase"
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tool.pytest.ini_options]
pythonpath = [
"."
]
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@ Hypercorn==0.15.0
hyperframe==6.0.1
identify==2.5.32
idna==3.4
iniconfig==2.0.0
Jinja2==3.1.2
jmespath==1.0.1
Mako==1.3.0
MarkupSafe==2.1.3
nodeenv==1.8.0
packaging==23.2
Pillow==10.1.0
platformdirs==4.0.0
pluggy==1.3.0
pre-commit==3.5.0
priority==2.0.0
pydantic==2.5.1
pydantic_core==2.14.3
pytest==7.4.3
python-dateutil==2.8.2
python-multipart==0.0.6
PyYAML==6.0.1
Expand Down
Empty file added tests/__init__.py
Empty file.
Empty file added tests/plugins/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions tests/plugins/env_vars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os

import pytest


@pytest.hookimpl(tryfirst=True)
def pytest_load_initial_conftests(args, early_config, parser):
with open(".env.template") as file:
data = file.read()

for line in data.split():
if line.startswith("#"):
continue

key, value = line.split()[0].split("=", 1)
os.environ[key] = value

0 comments on commit a2a1c23

Please sign in to comment.