Nir Soffer has posted comments on this change.

Change subject: schema: verification of API.py and schema during UT
......................................................................


Patch Set 1:

(3 comments)

http://gerrit.ovirt.org/#/c/35557/1/tests/schemaValidationTest.py
File tests/schemaValidationTest.py:

Line 76:     setattr(storage, 'sd', sd)
Line 77:     sys.modules['storage.volume'] = volume
Line 78:     sys.modules['storage.image'] = image
Line 79:     sys.modules['storage.sd'] = sd
Line 80:     sys.modules['storage'] = storage
You cannot touch global state like this - use monkeypatch module for such 
changes, so after your test, sys.modules is restored to previous value.
Line 81: 
Line 82:     virt = MOCK_MOD
Line 83:     setattr(virt, 'vm', MOCK_MOD)
Line 84:     setattr(virt, 'vmstatus', MOCK_MOD)


Line 95:         apiobj = validator.get_api('API')
Line 96:         try:
Line 97:             validator.validate(apiobj)
Line 98:         except _ValidationError as e:
Line 99:             self.fail(e)
You don't need this - simply raise AssetionError in validate()
Line 100: 
Line 101: 
Line 102: class SchemaValidator():
Line 103:     # verbs not used in the engine and lacking definition in schema


Line 113:                                                         
inspect.isclass):
Line 114:             classes = list(class_obj.__bases__)
Line 115:             for clazz in classes:
Line 116:                 # All API classes need to extend APIBase
Line 117:                 if 'APIBase' in clazz.__name__:
> So you just want to iterate on classes which inherit from APIBase, right?
Possible implementation of the function Francesco suggests:

    for cls in inspect.getmembers(api_mod, inspect.isclass):
        if issubclass(cls, APIBase):
            yield cls
Line 118:                     apiObj = getattr(api_mod, class_name)
Line 119:                     ctorArgs = apiObj.ctorArgs
Line 120:                     ctor_defaults = []
Line 121: 


-- 
To view, visit http://gerrit.ovirt.org/35557
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If81cff3c988e00c8c4eda1809f481e1ae19398dd
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <piotr.kliczew...@gmail.com>
Gerrit-Reviewer: Francesco Romani <from...@redhat.com>
Gerrit-Reviewer: Nir Soffer <nsof...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to