Skip to content

Commit

Permalink
chore: update project structure to 78c5496a
Browse files Browse the repository at this point in the history
* chore: update project structure to 78c5496a

* fix: refresh package registry first
  • Loading branch information
escaped committed Jan 11, 2021
1 parent adcb426 commit e0d51ec
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/escaped/cookiecutter-pypackage.git",
"commit": "46edce6ba837a29c6a7b6867ab259ce93391fd13",
"commit": "78c5496a422a0047307d337f970c73f01dd9e392",
"context": {
"cookiecutter": {
"author": "Alexander Frenzel",
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ on:
- main

jobs:
lint_cruft:
name: Check if automatic project update was successful
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Fail if .rej files exist as structure update was not successful
run: test -z "$(find . -iname '*.rej')"

lint:
name: Lint
needs: [lint_cruft]
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -30,6 +42,7 @@ jobs:

test:
name: Test
needs: [lint_cruft]
runs-on: ${{ matrix.platform }}
strategy:
max-parallel: 4
Expand All @@ -48,6 +61,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions coveralls
sudo apt-get update
sudo apt-get install -y ffmpeg
- name: Test with tox
run: tox
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
run: |
cruft update -y
poetry lock --no-update # add new dependencies
poetry run pre-commit run -a
poetry install
poetry run pre-commit run -a || true # we have to fix other issue manually
- name: Get new template version
# extract new cooiecutter template version
Expand All @@ -34,7 +35,7 @@ jobs:
token: ${{ secrets.AUTO_UPDATE_GITHUB_TOKEN }}
commit-message: >-
chore: update project structure to ${{ env.TEMPLATE_COMMIT }}
title: "[Cruft] Auto-Update project structure"
title: "[Actions] Auto-Sync cookiecutter template"
body: ""
branch: chore/cookiecutter-pypackage
delete-branch: true
Expand Down
83 changes: 82 additions & 1 deletion poetry.lock

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

4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ autoflake = "^1.4"
black = "^20.8b1"
flake8 = "^3.8.3"
flake8-bugbear = "^20.11.1"
flake8-builtins = "^1.5.3"
flake8-comprehensions = "^3.3.1"
flake8-debugger = "^4.0.0"
isort = "^5.5.2"
mypy = "^0.782"
pep8-naming = "^0.11.1"
pre-commit = "^2.7.1"
pytest = "^6.0.1"
pytest-cov = "^2.10.1"
Expand Down
15 changes: 7 additions & 8 deletions test_proj/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,23 @@ def local_video(video_path) -> Generator[Video, None, None]:
# file has already been deleted
pass

for format in video.format_set.all():
format.file.delete()
for format_ in video.format_set.all():
format_.file.delete()

video.delete()


@pytest.fixture
def format(video_path, local_video) -> Generator[Format, None, None]:
format = Format.objects.create(
def video_format(video_path, local_video) -> Generator[Format, None, None]:
format_ = Format.objects.create(
object_id=local_video.pk,
content_type=ContentType.objects.get_for_model(local_video),
field_name='file',
format='mp4_hd',
progress=100,
)
#
format.file.save('test.MTS', File(open(video_path, 'rb')), save=True)
yield format
format_.file.save('test.MTS', File(open(video_path, 'rb')), save=True)
yield format_


@pytest.fixture
Expand Down Expand Up @@ -110,7 +109,7 @@ def delete(self, name: str) -> None:
def exists(self, name: str) -> bool:
return self.__path(name).exists()

def open(self, name: str, mode: str) -> IO[Any]:
def open(self, name: str, mode: str) -> IO[Any]: # noqa: A003
return open(self.__path(name), mode)

def path(self, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion test_proj/media_library/tests/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_encoding(video):

assert video.format_set.count() == 4

formats = dict([(o['name'], o) for o in settings.VIDEO_ENCODING_FORMATS['FFmpeg']])
formats = {o['name']: o for o in settings.VIDEO_ENCODING_FORMATS['FFmpeg']}
assert set(video.format_set.values_list('format', flat=True)) == set(
formats.keys()
) # NOQA
Expand Down
6 changes: 3 additions & 3 deletions test_proj/media_library/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_signals__encoding_failed(

@pytest.mark.django_db
def test_signals__encoding_skipped(
monkeypatch, mocker, local_video: models.Video, format: models.Format
monkeypatch, mocker, local_video: models.Video, video_format: models.Format
) -> None:
"""
Make sure encoding signal reports skipped, if file had been encoded before.
Expand All @@ -143,8 +143,8 @@ def test_signals__encoding_skipped(

mocker.patch.object(tasks, '_encode') # don't encode anything
# encoding has already been done for the given format
format.format = encoding_format["name"]
format.save()
video_format.format = encoding_format["name"]
video_format.save()

listener = mocker.MagicMock()
signals.format_started.connect(listener)
Expand Down
2 changes: 1 addition & 1 deletion video_encoding/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Format(models.Model):
editable=False,
verbose_name=_("Progress"),
)
format = models.CharField(
format = models.CharField( # noqa: A003
max_length=255,
editable=False,
verbose_name=_("Format"),
Expand Down
4 changes: 2 additions & 2 deletions video_encoding/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def convert_all_videos(app_label, model_name, object_pk):
Automatically converts all videos of a given instance.
"""
# get instance
Model = apps.get_model(app_label=app_label, model_name=model_name)
instance = Model.objects.get(pk=object_pk)
model_class = apps.get_model(app_label=app_label, model_name=model_name)
instance = model_class.objects.get(pk=object_pk)

# search for `VideoFields`
fields = instance._meta.fields
Expand Down

0 comments on commit e0d51ec

Please sign in to comment.