From 68e6f0d2c02d30e5a96cb39f6beb59e2f8594e88 Mon Sep 17 00:00:00 2001
From: Lucas Clay <38572212+mlclay@users.noreply.github.com>
Date: Thu, 16 Jul 2020 09:37:46 -0400
Subject: [PATCH 1/2] force entityref pk to string for easier comparisons
 across all uses

---
 .../test_utils/json_asserter.py               |  7 ++++--
 tests/test_json_asserter.py                   | 24 +++++++++++++------
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/src/shipchain_common/test_utils/json_asserter.py b/src/shipchain_common/test_utils/json_asserter.py
index 04741c3..b120ab4 100644
--- a/src/shipchain_common/test_utils/json_asserter.py
+++ b/src/shipchain_common/test_utils/json_asserter.py
@@ -28,6 +28,10 @@ def __init__(self, resource=None, pk=None, attributes=None, relationships=None,
         self.relationships = relationships
         self.meta = meta
 
+        if self.pk is not None:
+            # entity_ref.pk can be a CharField or a UUIDField. Force to string for easier comparisons.
+            self.pk = str(self.pk)
+
     def __str__(self):
         return f'Type: {self.resource}; ID: {self.pk}; ' \
                f'attributes: {self.attributes}; relationships: {self.relationships}'
@@ -201,8 +205,7 @@ def _vnd_assertions(response_data, entity_ref):
         assert response_data['type'] == entity_ref.resource, f'Invalid Resource Type in {response_data}'
 
     if entity_ref.pk:
-        # entity_ref.pk can be a CharField or a UUIDField. Force string comparison for ease of use with UUIDField.
-        assert response_data['id'] == str(entity_ref.pk), f'Invalid ID in {response_data}'
+        assert response_data['id'] == entity_ref.pk, f'Invalid ID in {response_data}'
 
     if entity_ref.attributes:
         _vnd_assert_attributes(response_data, entity_ref.attributes)
diff --git a/tests/test_json_asserter.py b/tests/test_json_asserter.py
index 37ebd94..70997eb 100644
--- a/tests/test_json_asserter.py
+++ b/tests/test_json_asserter.py
@@ -1,9 +1,8 @@
-from unittest.mock import Mock
-import uuid
-
 import pytest
+import uuid
 from rest_framework import status
 from shipchain_common.test_utils import AssertionHelper
+from unittest.mock import Mock
 
 EXAMPLE_PLAIN = {
     'id': '07b374c3-ed9b-4811-901a-d0c5d746f16a',
@@ -738,10 +737,21 @@ def test_entity_list_non_list_response(self, vnd_single):
 
     def test_vnd_entity_uuid_pk(self, vnd_single):
         response = self.build_response(vnd_single)
-        AssertionHelper.HTTP_200(response, entity_refs=AssertionHelper.EntityRef(
-            resource=EXAMPLE_RESOURCE['type'],
-            pk=uuid.UUID(EXAMPLE_RESOURCE['id'])
-        ))
+        AssertionHelper.HTTP_200(
+            response,
+            entity_refs=AssertionHelper.EntityRef(
+                resource=EXAMPLE_RESOURCE['type'],
+                pk=uuid.UUID(EXAMPLE_RESOURCE['id']),
+                attributes=EXAMPLE_RESOURCE['attributes'],
+                relationships={'owner': AssertionHelper.EntityRef(
+                    resource=EXAMPLE_USER['type'],
+                    pk=uuid.UUID(EXAMPLE_USER['id']),
+                )}
+            ),
+            included=AssertionHelper.EntityRef(
+                resource=EXAMPLE_RESOURCE_2['type'],
+                pk=uuid.UUID(EXAMPLE_RESOURCE_2['id']),
+            ))
 
     def test_vnd_entity_full_match(self, vnd_single):
         response = self.build_response(vnd_single)

From 6af98794ca569c0312c99eb7d53ca6f99c8bfa3d Mon Sep 17 00:00:00 2001
From: Lucas Clay <38572212+mlclay@users.noreply.github.com>
Date: Thu, 16 Jul 2020 09:46:47 -0400
Subject: [PATCH 2/2] version bump to 1.0.28

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index 429a200..fa8ce12 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "shipchain-common"
-version = "1.0.27"
+version = "1.0.28"
 description = "A PyPI package containing shared code for ShipChain's Python/Django projects."
 
 license = "Apache-2.0"