Browse Source

Merge "Add a note about sqlalchemy metadata"

Zuul 2 months ago
parent
commit
3eb23d2276
2 changed files with 9 additions and 2 deletions
  1. 4
    2
      tests/unit/test_web.py
  2. 5
    0
      zuul/driver/sql/sqlconnection.py

+ 4
- 2
tests/unit/test_web.py View File

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

+ 5
- 0
zuul/driver/sql/sqlconnection.py View File

@@ -223,6 +223,11 @@ class SQLConnection(BaseConnection):
223 223
 
224 224
             def createArtifact(self, *args, **kw):
225 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 231
                 if 'metadata' in kw:
227 232
                     kw['meta'] = kw['metadata']
228 233
                     del kw['metadata']

Loading…
Cancel
Save