Skip to content

Commit

Permalink
test: more
Browse files Browse the repository at this point in the history
  • Loading branch information
klen committed Aug 7, 2023
1 parent c24331f commit e823bbf
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 38 deletions.
36 changes: 36 additions & 0 deletions .git-commits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---

convention:
commitTypes:
- feat
- fix
- perf
- refactor
- style
- test
- build
- ops
- docs
- merge
commitScopes: []
releaseTagGlobPattern: v[0-9]*.[0-9]*.[0-9]*

changelog:
commitTypes:
- feat
- fix
- perf
- merge
includeInvalidCommits: true
commitScopes: []
commitIgnoreRegexPattern: "^WIP "
headlines:
feat: Features
fix: Bug Fixes
perf: Performance Improvements
merge: Merges
breakingChange: BREAKING CHANGES
commitUrl: https://github.com/klen/peewee_migrate/commit/%commit%
commitRangeUrl: https://github.com/klen/peewee_migrate/compare/%from%...%to%?diff=split
issueRegexPattern: "#[0-9]+"
issueUrl: https://github.com/klen/peewee_migrate/issues/%issue%
104 changes: 68 additions & 36 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,83 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

fail_fast: true
default_install_hook_types: [commit-msg, pre-commit, pre-push]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/qoomon/git-conventional-commits
rev: 'v2.6.5'
hooks:
- id: conventional-commits
args: ["-c", ".git-commits.yaml"]
stages: ["commit-msg"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-case-conflict
stages: ["pre-commit"]
- id: check-merge-conflict
stages: ["pre-commit"]
- id: check-added-large-files
stages: ["pre-commit"]
- id: check-ast
stages: ["pre-commit"]
- id: check-executables-have-shebangs
stages: ["pre-commit"]
- id: check-symlinks
stages: ["pre-commit"]
- id: check-toml
stages: ["pre-commit"]
- id: check-yaml
stages: ["pre-commit"]
- id: debug-statements
stages: ["pre-commit"]
- id: end-of-file-fixer
stages: ["pre-commit"]
- id: trailing-whitespace
stages: ["pre-commit"]

- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.7.0
hooks:
- id: black
stages: ["pre-commit"]

- repo: https://github.com/python-poetry/poetry
rev: '1.5.1'
rev: '1.5.0'
hooks:
- id: poetry-check
- id: poetry-lock
args: ["--no-update"]
- id: poetry-check
files: ^(.*/)?pyproject\.toml$
stages: ["pre-commit"]
- id: poetry-lock
files: ^(.*/)?(poetry\.lock|pyproject\.toml)$
args: ["--no-update"]
stages: ["pre-commit"]

- repo: local
hooks:
- id: ruff
name: ruff
entry: poetry run ruff peewee_migrate
language: system
pass_filenames: false
files: \.py$
stages: ["pre-commit"]

- id: mypy
name: mypy
entry: poetry run mypy
language: system
pass_filenames: false
files: \.py$
stages: ["pre-push"]

- id: mypy
name: mypy
entry: poetry run mypy
language: system
pass_filenames: false

- id: ruff
name: ruff
entry: poetry run ruff peewee_migrate
language: system
pass_filenames: false

- id: pytest
name: pytest
entry: poetry run pytest
language: system
pass_filenames: false
- id: pytest
name: pytest
entry: poetry run pytest
language: system
pass_filenames: false
files: \.py$
stages: ["pre-push"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ all: $(VIRTUAL_ENV)
# Development
# =============

$(VIRTUAL_ENV): pyproject.toml
$(VIRTUAL_ENV): pyproject.toml .pre-commit-config.yaml
@poetry install --with dev
@poetry run pre-commit install --hook-type pre-push
@poetry run pre-commit install
@touch $(VIRTUAL_ENV)

.PHONY: t test
Expand Down
1 change: 1 addition & 0 deletions peewee_migrate/migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def add_fields(self, model: Union[str, TModelType], **fields: pw.Field) -> TMode
meta.table_name, field.column_name, field
)
)

return model

add_columns = depricated_method(add_fields, "add_columns")
Expand Down
15 changes: 15 additions & 0 deletions tests/test_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ class User(pw.Model):
assert not migrations


def test_add_field_unique(migrator: Migrator):
@migrator.create_model
class TestTable(pw.Model):
class Meta:
table_name = "test_table"

field = pw.CharField(null=False)

migrator()
migrator.add_fields("test_table", field2=pw.CharField(unique=True))
ops = migrator.__ops__
assert len(ops) == 1
assert ops[0].method == "add_column" # type: ignore[union-attr]


def test_change_field_constraint(migrator: Migrator):
@migrator.create_model
class TestTable(pw.Model):
Expand Down

0 comments on commit e823bbf

Please sign in to comment.