diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2018-01-03 16:03:33 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2018-01-04 16:54:26 +0800 |
commit | 6d98b992423084dd737e80322c9360e0712368a2 (patch) | |
tree | 29368af0fbc43cfdf078ed524aa4a446a604ab7b /testapi/opnfv_testapi/models | |
parent | 4bef7e27562d23c0cbdd56adf1cdc419f55e6aa4 (diff) |
simplify test_testcase.py using eq and templates
Change-Id: If1d1e3e22be0ddbb92f0e3b927ea4e376f0a8c89
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi/models')
-rw-r--r-- | testapi/opnfv_testapi/models/base_models.py | 3 | ||||
-rw-r--r-- | testapi/opnfv_testapi/models/testcase_models.py | 69 |
2 files changed, 24 insertions, 48 deletions
diff --git a/testapi/opnfv_testapi/models/base_models.py b/testapi/opnfv_testapi/models/base_models.py index cd437d9..5017e85 100644 --- a/testapi/opnfv_testapi/models/base_models.py +++ b/testapi/opnfv_testapi/models/base_models.py @@ -24,7 +24,8 @@ class ModelBase(object): def __eq__(self, other): res = all(getattr(self, k) == getattr(other, k) - for k in self.format().keys() if k != '_id') + for k in self.format().keys() + if k not in ['_id', 'creation_date']) return res def format(self): diff --git a/testapi/opnfv_testapi/models/testcase_models.py b/testapi/opnfv_testapi/models/testcase_models.py index d1b8877..1a55cf7 100644 --- a/testapi/opnfv_testapi/models/testcase_models.py +++ b/testapi/opnfv_testapi/models/testcase_models.py @@ -12,10 +12,20 @@ from opnfv_testapi.tornado_swagger import swagger @swagger.model() class TestcaseCreateRequest(base_models.ModelBase): - def __init__(self, name, url=None, description=None, - catalog_description=None, tier=None, ci_loop=None, - criteria=None, blocking=None, dependencies=None, run=None, - domains=None, tags=None, version=None): + def __init__(self, name=None, + url=None, + description=None, + catalog_description=None, + tier=None, + ci_loop=None, + criteria=None, + blocking=None, + dependencies=None, + run=None, + domains=None, + tags=None, + version=None, + trust='Silver'): self.name = name self.url = url self.description = description @@ -29,56 +39,21 @@ class TestcaseCreateRequest(base_models.ModelBase): self.domains = domains self.tags = tags self.version = version - self.trust = "Silver" + self.trust = trust @swagger.model() -class TestcaseUpdateRequest(base_models.ModelBase): - def __init__(self, name=None, description=None, project_name=None, - catalog_description=None, tier=None, ci_loop=None, - criteria=None, blocking=None, dependencies=None, run=None, - domains=None, tags=None, version=None, trust=None): - self.name = name - self.description = description - self.catalog_description = catalog_description - self.project_name = project_name - self.tier = tier - self.ci_loop = ci_loop - self.criteria = criteria - self.blocking = blocking - self.dependencies = dependencies - self.run = run - self.domains = domains - self.tags = tags - self.version = version - self.trust = trust +class TestcaseUpdateRequest(TestcaseCreateRequest): + def __init__(self, **kwargs): + self.project_name = kwargs.pop('project_name', '') + super(TestcaseUpdateRequest, self).__init__(**kwargs) @swagger.model() -class Testcase(base_models.ModelBase): - def __init__(self, _id=None, name=None, project_name=None, - description=None, url=None, creation_date=None, - catalog_description=None, tier=None, ci_loop=None, - criteria=None, blocking=None, dependencies=None, run=None, - domains=None, tags=None, version=None, - trust=None): +class Testcase(TestcaseCreateRequest): + def __init__(self, _id=None, **kwargs): self._id = None - self.name = None - self.project_name = None - self.description = None - self.catalog_description = None - self.url = None - self.creation_date = None - self.tier = None - self.ci_loop = None - self.criteria = None - self.blocking = None - self.dependencies = None - self.run = None - self.domains = None - self.tags = None - self.version = None - self.trust = None + super(Testcase, self).__init__(**kwargs) @swagger.model() |