Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# end of emulating code
# allSchemas.add(schema)
assert(schema.name == 'Job')
assert(schema.category == 'jobs')
assert(schema.allItems() == list(dd.items()))
cc = (schema.componentItems() + schema.simpleItems()).sort()
cc2 = list(dd.items()).sort()
assert(cc == cc2)
for i in schema.allItems():
assert(schema[i[0]] == schema.getItem(i[0]))
assert(schema['id'].isA(SimpleItem))
assert(schema['application'].isA(ComponentItem))
assert(schema['inputbox'].isA(ComponentItem))
assert(schema['inputbox'].isA(FileItem))
assert(schema['id']['protected'])
assert(not schema['id']['comparable'])
assert(schema['id']['type'] == 'string')
logger.info(schema['application']['category'] + ' ' + schema['application']['defvalue'])
schema2 = copy.deepcopy(schema)
assert(schema2 is not schema)
assert(schema.datadict is not schema2.datadict)
assert(schema._pluginclass is schema2._pluginclass)
def _describe(self):
return "'gangafiles' object," + Item._describe(self)
if __name__ == '__main__':
# a simple test
dd = {
'application': ComponentItem(category='applications'),
'backend': ComponentItem(category='backends'),
'name': SimpleItem('', comparable=0),
'workdir': SimpleItem(defvalue=None, type='string', transient=1, protected=1, comparable=0),
'status': SimpleItem(defvalue='new', protected=1, comparable=0),
'id': SimpleItem(defvalue=None, type='string', protected=1, comparable=0),
'inputbox': FileItem(defvalue=[], sequence=1),
'outputbox': FileItem(defvalue=[], sequence=1),
'overriden_copyable': SimpleItem(defvalue=None, protected=1, copyable=1),
'plain_copyable': SimpleItem(defvalue=None, copyable=0)
}
schema = Schema(Version(1, 0), dd)
# NOT a public interface: emulate the Ganga Plugin object for test purposes
# Note that pclass MUST be a new-style class in order to support deepcopy
class pclass(object):
_category = 'jobs'
_name = 'Job'
schema._pluginclass = pclass
# end of emulating code
# allSchemas.add(schema)
super(GangaFileItem, self).__init__('gangafiles')
self._update(kwds)
def _describe(self):
return "'gangafiles' object," + Item._describe(self)
if __name__ == '__main__':
# a simple test
dd = {
'application': ComponentItem(category='applications'),
'backend': ComponentItem(category='backends'),
'name': SimpleItem('', comparable=0),
'workdir': SimpleItem(defvalue=None, type='string', transient=1, protected=1, comparable=0),
'status': SimpleItem(defvalue='new', protected=1, comparable=0),
'id': SimpleItem(defvalue=None, type='string', protected=1, comparable=0),
'inputbox': FileItem(defvalue=[], sequence=1),
'outputbox': FileItem(defvalue=[], sequence=1),
'overriden_copyable': SimpleItem(defvalue=None, protected=1, copyable=1),
'plain_copyable': SimpleItem(defvalue=None, copyable=0)
}
schema = Schema(Version(1, 0), dd)
# NOT a public interface: emulate the Ganga Plugin object for test purposes
# Note that pclass MUST be a new-style class in order to support deepcopy
class pclass(object):
_category = 'jobs'
_name = 'Job'
schema._pluginclass = pclass
self._update(kwds)
def _describe(self):
return "'gangafiles' object," + Item._describe(self)
if __name__ == '__main__':
# a simple test
dd = {
'application': ComponentItem(category='applications'),
'backend': ComponentItem(category='backends'),
'name': SimpleItem('', comparable=0),
'workdir': SimpleItem(defvalue=None, type='string', transient=1, protected=1, comparable=0),
'status': SimpleItem(defvalue='new', protected=1, comparable=0),
'id': SimpleItem(defvalue=None, type='string', protected=1, comparable=0),
'inputbox': FileItem(defvalue=[], sequence=1),
'outputbox': FileItem(defvalue=[], sequence=1),
'overriden_copyable': SimpleItem(defvalue=None, protected=1, copyable=1),
'plain_copyable': SimpleItem(defvalue=None, copyable=0)
}
schema = Schema(Version(1, 0), dd)
# NOT a public interface: emulate the Ganga Plugin object for test purposes
# Note that pclass MUST be a new-style class in order to support deepcopy
class pclass(object):
_category = 'jobs'
_name = 'Job'
schema._pluginclass = pclass
# end of emulating code
def __init__(self, **kwds):
super(GangaFileItem, self).__init__('gangafiles')
self._update(kwds)
def _describe(self):
return "'gangafiles' object," + Item._describe(self)
if __name__ == '__main__':
# a simple test
dd = {
'application': ComponentItem(category='applications'),
'backend': ComponentItem(category='backends'),
'name': SimpleItem('', comparable=0),
'workdir': SimpleItem(defvalue=None, type='string', transient=1, protected=1, comparable=0),
'status': SimpleItem(defvalue='new', protected=1, comparable=0),
'id': SimpleItem(defvalue=None, type='string', protected=1, comparable=0),
'inputbox': FileItem(defvalue=[], sequence=1),
'outputbox': FileItem(defvalue=[], sequence=1),
'overriden_copyable': SimpleItem(defvalue=None, protected=1, copyable=1),
'plain_copyable': SimpleItem(defvalue=None, copyable=0)
}
schema = Schema(Version(1, 0), dd)
# NOT a public interface: emulate the Ganga Plugin object for test purposes
# Note that pclass MUST be a new-style class in order to support deepcopy
class pclass(object):
_category = 'jobs'
_name = 'Job'
def simpleItems(self):
return self._filter(SimpleItem)
def __init__(self, defvalue, typelist=defaultValue, **kwds):
super(SimpleItem, self).__init__()
if typelist == defaultValue:
if type(defvalue) == dict:
typelist = []
else:
typelist = [type(defvalue)]
kwds['defvalue'] = defvalue
kwds['typelist'] = typelist
self._update(kwds)
if __name__ == '__main__':
# a simple test
dd = {
'application': ComponentItem(category='applications'),
'backend': ComponentItem(category='backends'),
'name': SimpleItem('', comparable=0),
'workdir': SimpleItem(defvalue=None, type='string', transient=1, protected=1, comparable=0),
'status': SimpleItem(defvalue='new', protected=1, comparable=0),
'id': SimpleItem(defvalue=None, type='string', protected=1, comparable=0),
'inputbox': FileItem(defvalue=[], sequence=1),
'outputbox': FileItem(defvalue=[], sequence=1),
'overriden_copyable': SimpleItem(defvalue=None, protected=1, copyable=1),
'plain_copyable': SimpleItem(defvalue=None, copyable=0)
}
schema = Schema(Version(1, 0), dd)
# NOT a public interface: emulate the Ganga Plugin object for test purposes
# Note that pclass MUST be a new-style class in order to support deepcopy
class pclass(object):
_category = 'jobs'
_name = 'Job'
schema._pluginclass = pclass
# end of emulating code
# allSchemas.add(schema)
assert(schema.name == 'Job')
assert(schema.category == 'jobs')
if __name__ == '__main__':
# a simple test
dd = {
'application': ComponentItem(category='applications'),
'backend': ComponentItem(category='backends'),
'name': SimpleItem('', comparable=0),
'workdir': SimpleItem(defvalue=None, type='string', transient=1, protected=1, comparable=0),
'status': SimpleItem(defvalue='new', protected=1, comparable=0),
'id': SimpleItem(defvalue=None, type='string', protected=1, comparable=0),
'inputbox': FileItem(defvalue=[], sequence=1),
'outputbox': FileItem(defvalue=[], sequence=1),
'overriden_copyable': SimpleItem(defvalue=None, protected=1, copyable=1),
'plain_copyable': SimpleItem(defvalue=None, copyable=0)
}
schema = Schema(Version(1, 0), dd)
# NOT a public interface: emulate the Ganga Plugin object for test purposes
# Note that pclass MUST be a new-style class in order to support deepcopy
class pclass(object):
_category = 'jobs'
_name = 'Job'
schema._pluginclass = pclass
# end of emulating code
# allSchemas.add(schema)
assert(schema.name == 'Job')
assert(schema.category == 'jobs')