예제 #1
0
 def get(self, uid: str) -> Task:
     with open(self.filename) as f:
         data = json.load(f)
         tasks = data.get('tasks', {})
     task_dict = tasks.get(uid)
     if not task_dict:
         raise EntityNotFoundError("The task was not found in file.")
     return Task(**task_dict)
예제 #2
0
 def get(self, uid: str) -> Project:
     with open(self.filename) as f:
         data = json.load(f)
         projects = data.get('projects', {})
     project_dict = projects.get(uid)
     if not project_dict:
         raise EntityNotFoundError("The project was not found in file.")
     return Project(**project_dict)
예제 #3
0
 def delete(self, task: Task) -> None:
     uid = task.uid
     with open(self.filename) as f:
         data = json.load(f)
         tasks = data.get('tasks', {})
     old_task = tasks.get(uid)
     if not old_task:
         raise EntityNotFoundError("Task not found.")
     del data['tasks'][task.uid]
     with open(self.filename, 'w') as f:
         json.dump(data, f, default=json_serialize)
예제 #4
0
 def delete(self, project: Project) -> None:
     uid = project.uid
     with open(self.filename) as f:
         data = json.load(f)
         projects = data.get('projects', {})
     old_project = projects.get(uid)
     if not old_project:
         raise EntityNotFoundError("Project not found.")
     del data['projects'][project.uid]
     with open(self.filename, 'w') as f:
         json.dump(data, f, default=json_serialize)
 def delete(self, task: Task) -> None:
     uid = task.uid
     old_task = self.tasks.get(uid)
     if not old_task:
         raise EntityNotFoundError("Task not found.")
     del self.tasks[uid]
 def get(self, uid: str) -> Task:
     task = self.tasks.get(uid)
     if not task:
         raise EntityNotFoundError("Task not found.")
     return task
예제 #7
0
def test_entity_not_found_error() -> None:
    with raises(EntityNotFoundError):
        raise EntityNotFoundError("Entity not found in repository!")
 def delete(self, project: Project) -> None:
     uid = project.uid
     old_project = self.projects.get(uid)
     if not old_project:
         raise EntityNotFoundError("Project not found.")
     del self.projects[uid]
 def get(self, uid: str) -> Project:
     project = self.projects.get(uid)
     if not project:
         raise EntityNotFoundError("Project not found.")
     return project