Пример #1
0
def test_project_from_json():
    json_ = json.loads(
        '{"id":42,"name":"The Bat","color":"black","code":null,"notes":null,"start_date":"2017-05-29",'
        '"end_date":"2018-08-31","harvest_id":null,"archived":false,"updated_at":"2018-05-28T14:48:39.048Z",'
        '"updated_by_id":3,"client_id":123,"tags":["secret"]}')
    project = Project.from_dict(json_)
    assert isinstance(project, Project)
    assert project.name == "The Bat"
    assert project.color == "black"  # of course :)
    assert project.tags == ["secret"]
    assert project.code == None
    assert not project.archived
Пример #2
0
 def get_project(self, project_id) -> Project:
     data = self._requestor.get("projects/{}".format(project_id))
     return Project.from_dict(data['project'])
Пример #3
0
 def get_client(self, client_id) -> Client:
     data = self._requestor.get("clients/{}".format(client_id))
     return Project.from_dict(data['client'])
Пример #4
0
 def get_projects(self) -> List[Project]:
     data = self._requestor.get("projects")
     return [Project.from_dict(project) for project in data['projects']]