Moved display_type_name attribute to to each artifact detail object
Change-Id: Id869ea4106bc08fd3fa7c76611474740a694dab0
This commit is contained in:
parent
5408124b87
commit
d1edf09ef5
@ -385,8 +385,7 @@ class ArtifactsController(api_versioning.VersionedResource):
|
||||
artifacts = artifacts_data["artifacts"]
|
||||
result = {'artifacts': artifacts,
|
||||
'type_name': type_name,
|
||||
'total_count': artifacts_data['total_count'],
|
||||
'display_type_name': artifacts_data['display_type_name']}
|
||||
'total_count': artifacts_data['total_count']}
|
||||
if len(artifacts) != 0 and len(artifacts) == limit:
|
||||
result['next_marker'] = artifacts[-1]['id']
|
||||
return result
|
||||
@ -546,8 +545,7 @@ class ResponseSerializer(api_versioning.VersionedResource,
|
||||
'artifacts': af_list['artifacts'],
|
||||
'first': '/artifacts/%s' % type_name,
|
||||
'schema': '/schemas/%s' % type_name,
|
||||
'total_count': af_list['total_count'],
|
||||
'display_type_name': af_list['display_type_name']
|
||||
'total_count': af_list['total_count']
|
||||
}
|
||||
if query:
|
||||
body['first'] = '%s?%s' % (body['first'], query)
|
||||
|
@ -352,9 +352,6 @@ class Engine(object):
|
||||
context, filters, marker, limit, sort, latest, list_all_artifacts)
|
||||
artifacts_data["artifacts"] = [af.to_dict()
|
||||
for af in artifacts_data["artifacts"]]
|
||||
artifacts_data['display_type_name'] = \
|
||||
artifact_type.get_display_type_name()
|
||||
|
||||
return artifacts_data
|
||||
|
||||
@staticmethod
|
||||
|
@ -33,15 +33,7 @@ class All(base.BaseArtifact):
|
||||
filter_ops=(wrappers.FILTER_LIKE,
|
||||
wrappers.FILTER_EQ,
|
||||
wrappers.FILTER_NEQ,
|
||||
wrappers.FILTER_IN)),
|
||||
'display_type_name': Field(fields.StringField,
|
||||
description="Display name of "
|
||||
"artifact type.",
|
||||
sortable=True,
|
||||
filter_ops=(wrappers.FILTER_LIKE,
|
||||
wrappers.FILTER_EQ,
|
||||
wrappers.FILTER_NEQ,
|
||||
wrappers.FILTER_IN))
|
||||
wrappers.FILTER_IN))
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
@ -137,7 +137,15 @@ class BaseArtifact(base.VersionedObject):
|
||||
'version': Field(glare_fields.VersionField, required_on_activate=False,
|
||||
default=DEFAULT_ARTIFACT_VERSION, nullable=False,
|
||||
sortable=True, validators=[validators.Version()],
|
||||
description="Artifact version(semver).")
|
||||
description="Artifact version(semver)."),
|
||||
'display_type_name': Field(fields.StringField, system=True,
|
||||
description="Display name of "
|
||||
"artifact type.",
|
||||
sortable=True,
|
||||
filter_ops=(wrappers.FILTER_LIKE,
|
||||
wrappers.FILTER_EQ,
|
||||
wrappers.FILTER_NEQ,
|
||||
wrappers.FILTER_IN))
|
||||
}
|
||||
|
||||
common_artifact_type_opts = [
|
||||
|
@ -45,8 +45,7 @@ default_store = database
|
||||
'artifacts': [],
|
||||
'schema': '/schemas/sample_artifact',
|
||||
'type_name': 'sample_artifact',
|
||||
'total_count': 0,
|
||||
'display_type_name': 'Sample Artifact'}
|
||||
'total_count': 0}
|
||||
self.assertEqual(expected, response)
|
||||
|
||||
# Create a test artifact
|
||||
|
@ -667,7 +667,6 @@ class TestList(base.TestArtifact):
|
||||
url = '/sample_artifact'
|
||||
res = self.get(url=url, status=200)
|
||||
self.assertEqual(res['total_count'], 0)
|
||||
self.assertEqual(res['display_type_name'], "Sample Artifact")
|
||||
|
||||
def test_list_artifact_with_filter_query_combiner(self):
|
||||
# Create artifact
|
||||
@ -730,6 +729,28 @@ class TestList(base.TestArtifact):
|
||||
self.assertEqual(art_list[2], result[0])
|
||||
self.assertEqual(public_art, result[1])
|
||||
|
||||
def test_list_display_type_name_attribute(self):
|
||||
|
||||
[self.create_artifact({'name': 'name%s' % i,
|
||||
'version': '2.0',
|
||||
'tags': ['tag%s' % i],
|
||||
'int1': 1024,
|
||||
'float1': 123.456,
|
||||
'str1': 'bugaga',
|
||||
'bool1': True})
|
||||
for i in range(5)]
|
||||
|
||||
url = '/sample_artifact'
|
||||
result = self.get(url)['artifacts']
|
||||
self.assertEqual(True, len(result) > 0)
|
||||
for artifact in result:
|
||||
self.assertEqual('Sample Artifact', artifact['display_type_name'])
|
||||
|
||||
# validate for show artifact API
|
||||
url = '/sample_artifact/%s' % result[0]['id']
|
||||
result = self.get(url)
|
||||
self.assertEqual('Sample Artifact', result['display_type_name'])
|
||||
|
||||
|
||||
class TestBlobs(base.TestArtifact):
|
||||
def test_blob_dicts(self):
|
||||
@ -740,8 +761,7 @@ class TestBlobs(base.TestArtifact):
|
||||
'artifacts': [],
|
||||
'schema': '/schemas/sample_artifact',
|
||||
'type_name': 'sample_artifact',
|
||||
'total_count': 0,
|
||||
'display_type_name': 'Sample Artifact'}
|
||||
'total_count': 0}
|
||||
self.assertEqual(expected, response)
|
||||
|
||||
# Create a test artifact
|
||||
|
@ -149,7 +149,12 @@ fixture_base_props = {
|
||||
u'glareType': u'String',
|
||||
u'mutable': True,
|
||||
u'sortable': True,
|
||||
u'type': u'string'}
|
||||
u'type': u'string'},
|
||||
u'display_type_name': {u'description': u'Display name of artifact type.',
|
||||
u'filter_ops': [u'like', u'eq', u'neq', u'in'],
|
||||
u'glareType': u'String', u'maxLength': 255,
|
||||
u'readOnly': True, u'sortable': True,
|
||||
u'type': [u'string', u'null']}
|
||||
}
|
||||
|
||||
|
||||
@ -932,13 +937,7 @@ fixtures = {
|
||||
u'glareType': u'String',
|
||||
u'maxLength': 255,
|
||||
u'sortable': True,
|
||||
u'type': [u'string', u'null']},
|
||||
u'display_type_name': {
|
||||
u'description': u'Display name of artifact type.',
|
||||
u'filter_ops': [u'like', u'eq', u'neq', u'in'],
|
||||
u'glareType': u'String', u'maxLength': 255,
|
||||
u'sortable': True, u'type': [u'string', u'null']}
|
||||
|
||||
u'type': [u'string', u'null']}
|
||||
}),
|
||||
u'required': [u'name'],
|
||||
u'version': u'1.0',
|
||||
|
Loading…
x
Reference in New Issue
Block a user