Browse Source

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
changes/89/636189/2
James E. Blair 3 years ago
parent
commit
09d92bfbac
  1. 6
      tests/unit/test_web.py
  2. 5
      zuul/driver/sql/sqlconnection.py

6
tests/unit/test_web.py

@ -733,11 +733,13 @@ class TestArtifacts(ZuulDBTestCase, BaseTestWeb, AnsibleZuulTestCase):
"job_name=project-test1").json()
self.assertEqual(len(build_query), 1)
self.assertEqual(len(build_query[0]['artifacts']), 3)
arts = build_query[0]['artifacts']
arts.sort(key=lambda x: x['name'])
self.assertEqual(build_query[0]['artifacts'], [
{'url': 'http://example.com/tarball',
'name': 'tarball'},
{'url': 'http://example.com/docs',
'name': 'docs'},
{'url': 'http://logs.example.com/build/relative/docs',
'name': 'relative'},
{'url': 'http://example.com/tarball',
'name': 'tarball'},
])

5
zuul/driver/sql/sqlconnection.py

@ -223,6 +223,11 @@ class SQLConnection(BaseConnection):
def createArtifact(self, *args, **kw):
session = orm.session.Session.object_session(self)
# SQLAlchemy reserves the 'metadata' attribute on
# object models, so our model and table names use
# 'meta', but here we accept data directly from
# zuul_return where it's called 'metadata'. Transform
# the attribute name.
if 'metadata' in kw:
kw['meta'] = kw['metadata']
del kw['metadata']

Loading…
Cancel
Save