def load_phases(self): project = self.project phases = {} resources = self.source.findall('./tasks/task[task]') for resource in resources: phase = Phase(project) phase_id = int(resource.attrib['id']) phase._id = phase_id name = resource.attrib['name'] key, description = name.split('. ') key = key.strip() description = description.strip() phase.key = key phase.description = description start_date = datetime.datetime.strptime( resource.attrib['start'], '%Y-%m-%d').date() phase.due_date = project.calendar.get_end_date( start_date, int(resource.attrib['duration']) ) phases[phase_id] = phase phase._snap() project.phases = phases
def load_phases(self): versions = self.source.version.filter(project_id=self.project._id) for version in versions.values(): phase = Phase(self.project) # pdb.set_trace() version = ResourceWrapper(version, 'version') phase._id = version.id phase.description = "{}. {}".format( version.name, version.description ) phase.due_date = version.due_date self.project.phases[phase._id] = phase
def get_fake_repo(): repo = Mock() repo.project = Project('example', repo) project = repo.project for i in range(0, 3): member = Member(project, "key_{}".format(i), "fakeRole") member._id = i member.id = i member.save() phase = Phase(project, 'phase key 1') phase._id = 1 phase.save() for i in range(0, 5): task = Task(project) task._id = i task.description = 'Task {}'.format(i) task.save() for i in range(0, 3): task = project.tasks[i] task.phase = phase task.assigned_to = project.members[i] task.save() project.tasks[3].assigned_to = project.members[0] project.tasks[4].assigned_to = project.members[1] for i in range(1, 3): project.tasks[i].parent = project.tasks[0] project.tasks[3].relations.add_next(project.tasks[4]) node_1 = project.tokens.add_node(['1', '2', '3']) node_2 = project.tokens.add_node(['1', '2', '4']) node_3 = project.tokens.add_node(['3', '4', '5']) node_4 = project.tokens.add_node(['3', '6', '7']) project.tasks[0].inputs = [node_1, node_2] project.tasks[0].outputs = [node_3, node_4] return repo
def get_basic_frame(project): mock_repository = Mock() project.repository = mock_repository phase = Phase(project) phase._id = 2 phase.save() member = Member(project, 'member_key') member._id = 5 member.save() main_task = Task(project) main_task.description = 'Initial description' main_task.start_date = datetime.date(2016, 1, 4) main_task.duration = 2 main_task.complete = 75 main_task._id = 1 main_task.save() parent = Task(project) parent.description = 'parent description' parent.start_date = datetime.date(2016, 1, 4) parent.duration = 1 parent.complete = 100 parent._id = 2 parent.save() next_task = Task(project) next_task.description = 'next_task description' next_task.start_date = datetime.date(2016, 1, 4) next_task.duration = 1 next_task.complete = 100 next_task._id = 3 next_task.save() return (phase, member, parent, main_task, next_task)