Skip to content

Commit

Permalink
Address tox issues before releasing 0.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
subhashb committed Feb 28, 2019
1 parent b180cf6 commit 14c75b4
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 19 deletions.
7 changes: 5 additions & 2 deletions src/protean/core/entity.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""Entity Functionality and Classes"""
import copy
import logging
from typing import Any, Union
from typing import Any
from typing import Union

from protean.core.exceptions import ObjectNotFoundError
from protean.core.exceptions import ValidationError
from protean.core.field import Auto
from protean.core.field import Field, Reference, ReferenceField
from protean.core.field import Field
from protean.core.field import Reference
from protean.core.field import ReferenceField
from protean.utils.generic import classproperty
from protean.utils.query import Q

Expand Down
3 changes: 2 additions & 1 deletion src/protean/core/field/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Package for defining Field type and its implementations"""

from .association import Reference, ReferenceField
from .association import Reference
from .association import ReferenceField
from .base import Field
from .basic import Auto
from .basic import Boolean
Expand Down
12 changes: 7 additions & 5 deletions src/protean/core/field/association.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from abc import abstractmethod

from .base import Field
from .mixins import FieldCacheMixin, FieldDescriptorMixin

from protean.core import exceptions
from protean import utils
from protean.core import exceptions

from .base import Field
from .mixins import FieldCacheMixin
from .mixins import FieldDescriptorMixin


class ReferenceField(Field):
Expand All @@ -24,6 +25,7 @@ def __set__(self, instance, value):
if value:
instance.__dict__[self.field_name] = value
else:
# Important to handle None assignment, and interpret it to mean resetting values
self._reset_values(instance)

def __delete__(self, instance):
Expand Down Expand Up @@ -286,4 +288,4 @@ class HasMany(Association):

def _fetch_objects(self, key, value):
"""Fetch Multiple linked objects"""
return self.to_cls.query.filter(**{key: value})
return self.to_cls.query.filter(**{key: value})
4 changes: 2 additions & 2 deletions src/protean/core/field/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from typing import Any
from typing import Iterable

from .mixins import FieldDescriptorMixin

from protean.core import exceptions

from .mixins import FieldDescriptorMixin

MISSING_ERROR_MESSAGE = (
'ValidationError raised by `{class_name}`, but error key `{key}` does '
'not exist in the `error_messages` dictionary.'
Expand Down
26 changes: 19 additions & 7 deletions tests/core/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@

import mock
import pytest
from tests.support.dog import (Dog, RelatedDog, RelatedDog2, DogRelatedByEmail,
HasOneDog1, HasOneDog2, HasOneDog3,
HasManyDog1, HasManyDog2, HasManyDog3)
from tests.support.human import (Human, HasOneHuman1, HasOneHuman2, HasOneHuman3,
HasManyHuman1, HasManyHuman2, HasManyHuman3)

from tests.support.dog import Dog
from tests.support.dog import DogRelatedByEmail
from tests.support.dog import HasManyDog1
from tests.support.dog import HasManyDog2
from tests.support.dog import HasManyDog3
from tests.support.dog import HasOneDog1
from tests.support.dog import HasOneDog2
from tests.support.dog import HasOneDog3
from tests.support.dog import RelatedDog
from tests.support.dog import RelatedDog2
from tests.support.human import HasManyHuman1
from tests.support.human import HasManyHuman2
from tests.support.human import HasManyHuman3
from tests.support.human import HasOneHuman1
from tests.support.human import HasOneHuman2
from tests.support.human import HasOneHuman3
from tests.support.human import Human

from protean.core import field
from protean.core.entity import Entity, QuerySet
from protean.core.entity import Entity
from protean.core.entity import QuerySet
from protean.core.exceptions import ObjectNotFoundError
from protean.core.exceptions import ValidationError
from protean.utils.query import Q
Expand Down
6 changes: 5 additions & 1 deletion tests/support/dog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""Support Classes for Test Cases"""

from tests.support.human import Human, HasOneHuman1, HasOneHuman2, HasManyHuman1, HasManyHuman2
from tests.support.human import HasManyHuman1
from tests.support.human import HasManyHuman2
from tests.support.human import HasOneHuman1
from tests.support.human import HasOneHuman2
from tests.support.human import Human

from protean.core import field
from protean.core.entity import Entity
Expand Down
2 changes: 1 addition & 1 deletion tests/support/human.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Human Support Class for Test Cases"""

from protean.core import field
from protean.core.field import association
from protean.core.entity import Entity
from protean.core.field import association
from protean.impl.repository.dict_repo import DictModel


Expand Down

0 comments on commit 14c75b4

Please sign in to comment.