summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@redhat.com>2019-02-11 09:45:07 -0800
committerJames E. Blair <jeblair@redhat.com>2019-02-11 13:52:55 -0800
commit09d92bfbac20b064471fe428c75a27cd7b6f964d (patch)
tree9e15f68268d8ee99b8f674a0f952ca2d9b9fb1ec
parentf12453f6cbb452451bcce0cef9c4da4b957fd4a5 (diff)
Add a note about sqlalchemy metadata
It's not obvious why we're renaming the attribute here. Leave a clue for later explorers. Also, make test_artifacts handle artifacts being returned in a different order. Change-Id: Iffa216105f7e4951ea57fc073dacaa4040f82040
Notes
Notes (review): Code-Review+2: Clark Boylan <cboylan@sapwetik.org> Code-Review+2: Monty Taylor <mordred@inaugust.com> Workflow+1: Monty Taylor <mordred@inaugust.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 12 Feb 2019 01:18:43 +0000 Reviewed-on: https://review.openstack.org/636189 Project: openstack-infra/zuul Branch: refs/heads/master
-rwxr-xr-xtests/unit/test_web.py6
-rw-r--r--zuul/driver/sql/sqlconnection.py5
2 files changed, 9 insertions, 2 deletions
diff --git a/tests/unit/test_web.py b/tests/unit/test_web.py
index e267734..c31633c 100755
--- a/tests/unit/test_web.py
+++ b/tests/unit/test_web.py
@@ -733,11 +733,13 @@ class TestArtifacts(ZuulDBTestCase, BaseTestWeb, AnsibleZuulTestCase):
733 "job_name=project-test1").json() 733 "job_name=project-test1").json()
734 self.assertEqual(len(build_query), 1) 734 self.assertEqual(len(build_query), 1)
735 self.assertEqual(len(build_query[0]['artifacts']), 3) 735 self.assertEqual(len(build_query[0]['artifacts']), 3)
736 arts = build_query[0]['artifacts']
737 arts.sort(key=lambda x: x['name'])
736 self.assertEqual(build_query[0]['artifacts'], [ 738 self.assertEqual(build_query[0]['artifacts'], [
737 {'url': 'http://example.com/tarball',
738 'name': 'tarball'},
739 {'url': 'http://example.com/docs', 739 {'url': 'http://example.com/docs',
740 'name': 'docs'}, 740 'name': 'docs'},
741 {'url': 'http://logs.example.com/build/relative/docs', 741 {'url': 'http://logs.example.com/build/relative/docs',
742 'name': 'relative'}, 742 'name': 'relative'},
743 {'url': 'http://example.com/tarball',
744 'name': 'tarball'},
743 ]) 745 ])
diff --git a/zuul/driver/sql/sqlconnection.py b/zuul/driver/sql/sqlconnection.py
index 170dddf..1a9f590 100644
--- a/zuul/driver/sql/sqlconnection.py
+++ b/zuul/driver/sql/sqlconnection.py
@@ -223,6 +223,11 @@ class SQLConnection(BaseConnection):
223 223
224 def createArtifact(self, *args, **kw): 224 def createArtifact(self, *args, **kw):
225 session = orm.session.Session.object_session(self) 225 session = orm.session.Session.object_session(self)
226 # SQLAlchemy reserves the 'metadata' attribute on
227 # object models, so our model and table names use
228 # 'meta', but here we accept data directly from
229 # zuul_return where it's called 'metadata'. Transform
230 # the attribute name.
226 if 'metadata' in kw: 231 if 'metadata' in kw:
227 kw['meta'] = kw['metadata'] 232 kw['meta'] = kw['metadata']
228 del kw['metadata'] 233 del kw['metadata']