diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-05-19 18:13:27 +0800 |
---|---|---|
committer | SerenaFeng <feng.xiaowei@zte.com.cn> | 2016-05-19 18:18:07 +0800 |
commit | f25ad4e8a7e4bd6505b2144494da81fbcad40b7d (patch) | |
tree | c811d7b15048680d7d6717beb02bfbfa75aea717 /utils/test/result_collection_api/resources/project_models.py | |
parent | 598be795dec8fa11bee7b6e140b33947ab35b8f0 (diff) |
add unittests of project & refactor response
post body: {'href':'<http://ip:8000/pods/pod_name >'}
get body: Pod/Project
list body: list of Pod/Project
update body: Pod/Project
delete: no body
JIRA: FUNCTEST-253
Change-Id: I28c6f5b35d8909d827f2f803197d95be4abd44bb
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'utils/test/result_collection_api/resources/project_models.py')
-rw-r--r-- | utils/test/result_collection_api/resources/project_models.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/utils/test/result_collection_api/resources/project_models.py b/utils/test/result_collection_api/resources/project_models.py new file mode 100644 index 000000000..895fc3e5e --- /dev/null +++ b/utils/test/result_collection_api/resources/project_models.py @@ -0,0 +1,67 @@ +__author__ = '__serena__' + + +class ProjectCreateRequest(object): + def __init__(self, name='', description=''): + self.name = name + self.description = description + + def format(self): + return { + "name": self.name, + "description": self.description, + } + + +class Project: + """ Describes a test project""" + + def __init__(self): + self._id = None + self.name = None + self.description = None + self.creation_date = None + + @staticmethod + def from_dict(res_dict): + + if res_dict is None: + return None + + t = Project() + t._id = res_dict.get('_id') + t.creation_date = res_dict.get('creation_date') + t.name = res_dict.get('name') + t.description = res_dict.get('description') + + return t + + def format(self): + return { + "name": self.name, + "description": self.description, + "creation_date": str(self.creation_date) + } + + def format_http(self): + return { + "_id": str(self._id), + "name": self.name, + "description": self.description, + "creation_date": str(self.creation_date), + } + + +class Projects(object): + def __init__(self, projects=list()): + self.projects = projects + + @staticmethod + def from_dict(res_dict): + if res_dict is None: + return None + + res = Projects() + for project in res_dict.get('projects'): + res.projects.append(Project.from_dict(project)) + return res |