diff --git a/.travis.yml b/.travis.yml index b428a3c..460169e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python python: - - 3.4 + - 3.6 script: make test notifications: email: false @@ -13,6 +13,8 @@ env: - DJANGO='django>=1.8,<1.9' - DJANGO='django>=1.9,<1.10' - DJANGO='django>=1.10,<1.11' + - DJANGO='django>=2.0,<2.1' + - DJANGO='django>=2.1,<2.2' - DJANGO='--upgrade --pre django' matrix: fast_finish: true diff --git a/CHANGELOG.md b/CHANGELOG.md index e8937a5..42dd158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.1.1 + +* Added support for Django 2.x+ +* Updated requirements for testing +* Updated travis config with Python 3.6 and additional environments + ## 2.1.0 Thanks to @peterfarrell: diff --git a/README.md b/README.md index 9a6ea08..e0621bc 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,9 @@ PGP symmetric fields are: ## Requirements - postgres with `pgcrypto` + - Supports Django 1.8 to 2.1 + - Compatible with Python 3 only + ## Installation diff --git a/pgcrypto/forms.py b/pgcrypto/forms.py index 0a5e9cf..15efa73 100644 --- a/pgcrypto/forms.py +++ b/pgcrypto/forms.py @@ -11,7 +11,7 @@ class DateField(forms.DateField): def __init__(self, input_formats=None, *args, **kwargs): """Init that pops off the max_length attribute.""" kwargs.pop('max_length', None) - super().__init__(input_formats, *args, **kwargs) + super().__init__(input_formats=input_formats, **kwargs) class DateTimeField(forms.DateTimeField): @@ -24,4 +24,4 @@ class DateTimeField(forms.DateTimeField): def __init__(self, input_formats=None, *args, **kwargs): """Init that pops off the max_length attribute.""" kwargs.pop('max_length', None) - super().__init__(input_formats, *args, **kwargs) + super().__init__(input_formats=input_formats, **kwargs) diff --git a/pgcrypto/lookups.py b/pgcrypto/lookups.py index f2847a5..c093248 100644 --- a/pgcrypto/lookups.py +++ b/pgcrypto/lookups.py @@ -52,7 +52,7 @@ class DateLookupBase(Lookup): operator = None # Set in subclasses def __init__(self, lhs, rhs): - """Implementing an abstract class.""" + """Implement an abstract class.""" super(DateLookupBase, self).__init__(lhs, rhs) # pragma: no cover def as_sql(self, qn, connection): diff --git a/pgcrypto/mixins.py b/pgcrypto/mixins.py index bd301ad..8af0a6b 100644 --- a/pgcrypto/mixins.py +++ b/pgcrypto/mixins.py @@ -21,11 +21,13 @@ class HashMixin: `HashMixin` uses 'pgcrypto' to encrypt data in a postgres database. """ def __init__(self, original=None, *args, **kwargs): + """Tells the init the original attr.""" self.original = original super(HashMixin, self).__init__(*args, **kwargs) def pre_save(self, model_instance, add): + """Save the original_value.""" if self.original: original_value = getattr(model_instance, self.original) setattr(model_instance, self.attname, original_value) diff --git a/requirements.txt b/requirements.txt index 8c4cd2c..3dd4bd1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,11 +2,12 @@ colour-runner==0.0.5 coverage==4.3.1 dj-database-url==0.4.2 -django>=1.10,<1.11 +django>=1.10,<2.2 factory-boy==2.8.1 -flake8-docstrings==1.0.2 +flake8-docstrings==1.3.0 flake8-import-order==0.11 -flake8==3.2.1 +flake8==3.5.0 incuna-test-utils==6.6.0 -psycopg2==2.6.2 -pyflakes==1.4.0 +psycopg2-binary==2.7.5 +pyflakes==1.6.0 +pycodestyle==2.3.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 24735ed..985b554 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import find_packages, setup -version = '2.1.0' +version = '2.1.1' setup( diff --git a/tests/factories.py b/tests/factories.py index 00ac048..79dd654 100644 --- a/tests/factories.py +++ b/tests/factories.py @@ -7,8 +7,6 @@ class EncryptedModelFactory(factory.DjangoModelFactory): """Factory to generate hashed and encrypted data.""" - class Meta: - model = EncryptedModel digest_field = factory.Sequence('Text digest {}'.format) hmac_field = factory.Sequence('Text hmac {}'.format) @@ -22,3 +20,7 @@ class Meta: pgp_sym_field = factory.Sequence('Text with symmetric key {}'.format) date_pgp_sym_field = date.today() + + class Meta: + """Sets up meta for test factory.""" + model = EncryptedModel diff --git a/tests/models.py b/tests/models.py index 8c88ece..4a47ada 100644 --- a/tests/models.py +++ b/tests/models.py @@ -10,9 +10,11 @@ class EncryptedModelManager(managers.PGPManager): class EncryptedModel(models.Model): """Dummy model used for tests to check the fields.""" digest_field = fields.TextDigestField(blank=True, null=True) - digest_with_original_field = fields.TextDigestField(blank=True, null=True, original='pgp_sym_field') + digest_with_original_field = fields.TextDigestField(blank=True, null=True, + original='pgp_sym_field') hmac_field = fields.TextHMACField(blank=True, null=True) - hmac_with_original_field = fields.TextHMACField(blank=True, null=True, original='pgp_sym_field') + hmac_with_original_field = fields.TextHMACField(blank=True, null=True, + original='pgp_sym_field') email_pgp_pub_field = fields.EmailPGPPublicKeyField(blank=True, null=True) integer_pgp_pub_field = fields.IntegerPGPPublicKeyField(blank=True, null=True) @@ -25,6 +27,7 @@ class EncryptedModel(models.Model): datetime_pgp_sym_field = fields.DateTimePGPSymmetricKeyField(blank=True, null=True) class Meta: + """Sets up the meta for the test model.""" app_label = 'tests' @@ -33,4 +36,5 @@ class EncryptedModelWithManager(EncryptedModel): objects = EncryptedModelManager() class Meta: + """Sets up the meta for the test manager.""" proxy = True diff --git a/tests/test_fields.py b/tests/test_fields.py index 290b710..8306890 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -207,7 +207,9 @@ def test_digest_with_original_lookup(self): expected = EncryptedModelFactory.create(pgp_sym_field=value) EncryptedModelFactory.create() - queryset = EncryptedModel.objects.filter(digest_with_original_field__hash_of=value) + queryset = EncryptedModel.objects.filter( + digest_with_original_field__hash_of=value + ) self.assertCountEqual(queryset, [expected]) def test_hmac_lookup(self):