Skip to content

Commit

Permalink
Use __version__ inside the code itself.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anderycks committed Apr 6, 2017
1 parent 7001865 commit d479a61
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 31 deletions.
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
if sys.version_info[0] != 3 or sys.version_info[1] < 4:
requirements.append('enum34')

from sqlalchemy_jsonapi import __version__

setup(name='SQLAlchemy-JSONAPI',
version='4.0.9',
version=__version__,
url='http://github.com/coltonprovias/sqlalchemy-jsonapi',
license='MIT',
author='Colton J. Provias',
Expand Down
5 changes: 4 additions & 1 deletion sqlalchemy_jsonapi/errors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import json
from uuid import uuid4

# Relative import here is to avoid circular import in setup.py.
from ._version import __version__


class BaseError(Exception):
@property
Expand Down Expand Up @@ -160,7 +163,7 @@ def user_error(status_code, title, detail, pointer):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
return json.dumps(response), status_code
3 changes: 2 additions & 1 deletion sqlalchemy_jsonapi/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
RelationshipNotFoundError, ResourceNotFoundError,
ResourceTypeNotFoundError, ToManyExpectedError,
ValidationError)
from ._version import __version__


class AttributeActions(Enum):
Expand Down Expand Up @@ -139,7 +140,7 @@ def __init__(self):
self.status_code = 200
self.data = {
'jsonapi': {'version': '1.0'},
'meta': {'sqlalchemy_jsonapi_version': '4.0.9'}
'meta': {'sqlalchemy_jsonapi_version': __version__}
}


Expand Down
3 changes: 2 additions & 1 deletion sqlalchemy_jsonapi/unittests/test_errors_user_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import unittest

from sqlalchemy_jsonapi import errors
from sqlalchemy_jsonapi import __version__


class TestUserError(unittest.TestCase):
Expand All @@ -30,7 +31,7 @@ def test_user_error(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
expected = json.dumps(data), status_code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from sqlalchemy_jsonapi.unittests.utils import testcases
from sqlalchemy_jsonapi.unittests import models
from sqlalchemy_jsonapi import __version__


class DeleteResource(testcases.SqlalchemyJsonapiTestCase):
Expand All @@ -22,7 +23,7 @@ def test_delete_resource_successs_response(self):

expected = {
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'jsonapi': {
'version': '1.0'
Expand Down
25 changes: 13 additions & 12 deletions sqlalchemy_jsonapi/unittests/test_serializer_get_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from sqlalchemy_jsonapi.unittests.utils import testcases
from sqlalchemy_jsonapi.unittests import models
from sqlalchemy_jsonapi import __version__


class GetCollection(testcases.SqlalchemyJsonapiTestCase):
Expand Down Expand Up @@ -54,7 +55,7 @@ def test_get_collection_response_with_no_query_args(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'included': []
}
Expand Down Expand Up @@ -141,7 +142,7 @@ def test_get_collection_response_with_single_include_model(self):
}
}],
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'jsonapi': {
'version': '1.0'
Expand Down Expand Up @@ -217,7 +218,7 @@ def test_get_collection_asc_sorted_response(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'included': []
}
Expand Down Expand Up @@ -291,7 +292,7 @@ def test_get_collection_desc_sorted_response(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'included': []
}
Expand Down Expand Up @@ -360,7 +361,7 @@ def test_get_collection_access_denied(self):
'data': [],
'included': [],
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'jsonapi': {
'version': '1.0'
Expand Down Expand Up @@ -435,7 +436,7 @@ def test_get_collection_paginated_response_by_page(self):
}],
'included': [],
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'jsonapi': {
'version': '1.0'
Expand Down Expand Up @@ -475,7 +476,7 @@ def test_get_collection_with_single_field(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down Expand Up @@ -558,7 +559,7 @@ def test_get_collection_when_including_model_and_its_attribute(self):
}
}],
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'data': [{
'id': 1,
Expand Down Expand Up @@ -636,7 +637,7 @@ def test_get_collection_given_an_included_model_that_is_null(self):
}
}],
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'included': []
}
Expand Down Expand Up @@ -748,7 +749,7 @@ def test_get_collection_with_multiple_included_models(self):
}
}],
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down Expand Up @@ -781,7 +782,7 @@ def test_get_collection_given_pagination_with_offset(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'included': [],
'data': [{
Expand Down Expand Up @@ -913,7 +914,7 @@ def test_get_collection_when_pagnation_is_out_of_range(self):
'data': [],
'included': [],
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'jsonapi': {
'version': '1.0'
Expand Down
7 changes: 4 additions & 3 deletions sqlalchemy_jsonapi/unittests/test_serializer_get_related.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from sqlalchemy_jsonapi.unittests.utils import testcases
from sqlalchemy_jsonapi.unittests import models
from sqlalchemy_jsonapi import __version__


class GetRelated(testcases.SqlalchemyJsonapiTestCase):
Expand Down Expand Up @@ -67,7 +68,7 @@ def test_get_related_of_to_one(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down Expand Up @@ -142,7 +143,7 @@ def test_get_related_of_to_many(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down Expand Up @@ -195,7 +196,7 @@ def test_get_related_when_related_object_is_null(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from sqlalchemy_jsonapi.unittests.utils import testcases
from sqlalchemy_jsonapi.unittests import models
from sqlalchemy_jsonapi import __version__


class GetRelationship(testcases.SqlalchemyJsonapiTestCase):
Expand Down Expand Up @@ -41,7 +42,7 @@ def test_get_relationship_on_to_many(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}

Expand Down Expand Up @@ -73,7 +74,7 @@ def test_get_relationship_on_to_one(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from sqlalchemy_jsonapi.unittests.utils import testcases
from sqlalchemy_jsonapi.unittests import models
from sqlalchemy_jsonapi import __version__


class GPatchRelationship(testcases.SqlalchemyJsonapiTestCase):
Expand Down Expand Up @@ -43,7 +44,7 @@ def test_patch_relationship_on_to_one_set_to_resource_response(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down Expand Up @@ -102,7 +103,7 @@ def test_patch_relationship_on_to_one_set_resource_to_null_response(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down Expand Up @@ -167,7 +168,7 @@ def test_patch_relationship_on_to_many_set_resources_response(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down Expand Up @@ -234,7 +235,7 @@ def test_patch_relationship_on_to_many_set_to_empty_response(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from sqlalchemy_jsonapi.unittests.utils import testcases
from sqlalchemy_jsonapi.unittests import models
from sqlalchemy_jsonapi import __version__


class PatchResource(testcases.SqlalchemyJsonapiTestCase):
Expand Down Expand Up @@ -103,7 +104,7 @@ def test_patch_resource_response(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from sqlalchemy_jsonapi.unittests.utils import testcases
from sqlalchemy_jsonapi.unittests import models
from sqlalchemy_jsonapi import __version__


class PostCollection(testcases.SqlalchemyJsonapiTestCase):
Expand Down Expand Up @@ -88,7 +89,7 @@ def test_add_resource_response(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}

Expand Down Expand Up @@ -190,7 +191,7 @@ def test_add_resource_with_many_to_one_relationship_response(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down Expand Up @@ -567,7 +568,7 @@ def test_add_resource_with_a_null_relationship(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
},
'included': []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from sqlalchemy_jsonapi.unittests.utils import testcases
from sqlalchemy_jsonapi.unittests import models
from sqlalchemy_jsonapi import __version__


class PostRelationship(testcases.SqlalchemyJsonapiTestCase):
Expand Down Expand Up @@ -90,7 +91,7 @@ def test_post_relationship_on_to_many_response(self):
'version': '1.0'
},
'meta': {
'sqlalchemy_jsonapi_version': '4.0.9'
'sqlalchemy_jsonapi_version': __version__
}
}
actual = response.data
Expand Down

0 comments on commit d479a61

Please sign in to comment.