def _make_update(self, data): u = Update(str(data['id'])) if 'created_at' in data: u.date = parse_date(data['created_at']) u.message = '%s: %s' % (data['type'], data['text']) if 'created_by' in data: u.author = self._make_user(data['created_by']) return u
def _make_update(self, data): u = Update(str(data['id'])) if 'created_at' in data: u.date = parse_date(data['created_at']) u.message = '%s: %s' % (data['type'], data['text']) if 'created_by' in data: u.author = self._make_user(data['created_by']) return u
def _make_comment(self, d, project): u = Update(d['id']) u.message = d['message'] u.author = project.find_user(d['author'], None) if not u.author: # may duplicate users u.author = User(d['author'], d['author']) u.date = d['date'] u.changes = [] u.attachments = [self._make_attachment(dattach) for dattach in d['attachments']] return u
def test_post_comment(self): issue = self.backend.get_issue('weboobie/testing/26') assert issue ts = str(int(time())) update = Update(0) update.message = "Yes! It's now %s" % ts self.backend.update_issue(issue, update) new = self.backend.get_issue('weboobie/testing/26') assert any(ts in upd.message for upd in new.history)
def test_post_comment(self): issue = self.backend.get_issue('weboobie/testing/26') assert issue ts = str(int(time())) update = Update(0) update.message = "Yes! It's now %s" % ts self.backend.update_issue(issue, update) new = self.backend.get_issue('weboobie/testing/26') assert any(ts in upd.message for upd in new.history)
def get_issue(self, issue): if isinstance(issue, Issue): id = issue.id else: id = issue issue = Issue(issue) try: with self.browser: params = self.browser.get_issue(id) except BrowserHTTPNotFound: return None issue.project = self._build_project(params['project']) issue.title = params['subject'] issue.body = params['body'] issue.creation = params['created_on'] issue.updated = params['updated_on'] issue.start = params['start_date'] issue.due = params['due_date'] issue.fields = {} for key, value in params['fields'].iteritems(): issue.fields[key] = value issue.attachments = [] for a in params['attachments']: attachment = Attachment(a['id']) attachment.filename = a['filename'] attachment.url = a['url'] issue.attachments.append(attachment) issue.history = [] for u in params['updates']: update = Update(u['id']) update.author = issue.project.find_user(*u['author']) update.date = u['date'] update.message = u['message'] update.changes = [] for i, (field, last, new) in enumerate(u['changes']): change = Change(i) change.field = field change.last = last change.new = new update.changes.append(change) issue.history.append(update) issue.author = issue.project.find_user(*params['author']) issue.assignee = issue.project.find_user(*params['assignee']) issue.tracker = params['tracker'][1] issue.category = params['category'][1] issue.version = issue.project.find_version(*params['version']) issue.status = issue.project.find_status(params['status'][1]) issue.priority = params['priority'][1] return issue
def _make_comment(self, d, project): u = Update(d['id']) u.message = d['message'] u.author = project.find_user(d['author'], None) if not u.author: # may duplicate users u.author = User(d['author'], d['author']) u.date = d['date'] u.changes = [] u.attachments = [ self._make_attachment(dattach) for dattach in d['attachments'] ] return u
def do_comment(self, line): """ comment ISSUE [TEXT] Comment an issue. If no text is given, enter it in standard input. """ id, text = self.parse_command_args(line, 2, 1) if text is None: text = self.acquire_input() id, backend_name = self.parse_id(id, unique_backend=True) update = Update(0) update.message = text self.do('update_issue', id, update, backends=backend_name).wait()
def do_comment(self, line): """ comment ISSUE [TEXT] Comment an issue. If no text is given, enter it in standard input. """ id, text = self.parse_command_args(line, 2, 1) if text is None: text = self.acquire_input() id, backend_name = self.parse_id(id, unique_backend=True) update = Update(0) update.message = text self.do('update_issue', id, update, backends=backend_name).wait()
def do_logtime(self, line): """ logtime ISSUE HOURS [TEXT] Log spent time on an issue. """ id, hours, text = self.parse_command_args(line, 3, 2) if text is None: text = self.acquire_input() try: hours = float(hours) except ValueError: print('Error: HOURS parameter may be a float', file=self.stderr) return 1 id, backend_name = self.parse_id(id, unique_backend=True) update = Update(0) update.message = text update.hours = timedelta(hours=hours) self.do('update_issue', id, update, backends=backend_name).wait()
def do_logtime(self, line): """ logtime ISSUE HOURS [TEXT] Log spent time on an issue. """ id, hours, text = self.parse_command_args(line, 3, 2) if text is None: text = self.acquire_input() try: hours = float(hours) except ValueError: print('Error: HOURS parameter may be a float', file=self.stderr) return 1 id, backend_name = self.parse_id(id, unique_backend=True) update = Update(0) update.message = text update.hours = timedelta(hours=hours) self.do('update_issue', id, update, backends=backend_name).wait()