Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Homework second lesson #76

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions data/db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"posts": [
{
"id": 1,
"title": "json-server",
"author": "typicode"
}
],
"comments": [
{
"id": 1,
"body": "some comment",
"postId": 1
}
],
"profile": {
"name": "typicode"
}
}
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ services:
retries: 5
start_period: 30s

json-server:
image: "vimagick/json-server"
command: -H 0.0.0.0 -p 5200 --watch db.json
container_name: "json_server"
ports:
- "5200:5200"
volumes:
- ./data:/data
restart: always
networks:
- webnet


# This task is an example of how to extend existing ones:
# some_worker:
# <<: *web
Expand Down
152 changes: 149 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ dennis = "^1.1"
dump-env = "^1.3"
ipython = "^8.15"
import-linter = "^1.11"
mixer = "^7.2.2"
json-server = "^0.1.3"

[tool.poetry.group.docs]
optional = true
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ filterwarnings =
ignore::DeprecationWarning:password_reset.*:
ignore::DeprecationWarning:pytest_freezegun:

markers =
slow


[coverage:run]
# Coverage configuration:
Expand Down
24 changes: 23 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,31 @@
2. https://docs.pytest.org/en/latest/doctest.html
"""

import pytest
import random


pytest_plugins = [
# Should be the first custom one:
'plugins.django_settings',

'plugins.identity.user',
'plugins.pictures.pictures'
# TODO: add your own plugins here!
]


def pytest_configure(config: pytest.Config) -> None:
seed_value = config.getoption("randomly_seed")
# рандомный seed:
default_seed = random.Random().getrandbits(32)

if seed_value == 'last':
seed = config.cache.get('randomly_seed', default_seed)
elif seed_value == 'default':
seed = default_seed
else:
seed = seed_value

if hasattr(config, 'cache'):
config.cache.set('randomly_seed', seed)
config.option.randomly_seed = seed
1 change: 1 addition & 0 deletions tests/plugins/django_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ def cache(settings: LazySettings) -> BaseCache:
# Clearing cache:
caches[test_cache].clear()
return caches[test_cache]

Loading
Loading