summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-02-12 01:18:43 +0000
committerGerrit Code Review <review@openstack.org>2019-02-12 01:18:43 +0000
commit3eb23d227625b524b23795a2490119b84709865a (patch)
treeb827ab1f8504234b0a3262392e0c8247cda113a4
parent5957d7a95e677116f39e52c2a44d4ca8b795da34 (diff)
parent09d92bfbac20b064471fe428c75a27cd7b6f964d (diff)
Merge "Add a note about sqlalchemy metadata"
-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']