예제 #1
0
 def sync_choice(self, e):
     if e.local_task:
         self.iom.send_message("Task Description: " +
                               e.local_task.tw_task['description'])
         self.iom.send_message("ArenaTaskID     : " +
                               e.local_task.ArenaTaskID)
         if e.remote_task:
             self.iom.send_message("Task exists in both repositories.", 1,
                                   1)
             self.iom.send_message("Last modified (local) : " +
                                   e.local_last_modified)
             self.iom.send_message("Last modified (remote): " +
                                   e.remote_last_modified)
             self.iom.send_message("Suggesting to " + e.suggestion + ".", 1,
                                   1)
             self.iom.send_message(
                 "This would cause the following modifications:", 0, 1)
             for field in e.fields:
                 local_field = str(e.local_task.tw_task[field]) \
                     if e.local_task.tw_task[field] else '(empty)'
                 remote_field = str(e.remote_task.tw_task[field]) \
                     if e.remote_task.tw_task[field] else '(empty)'
                 self.iom.send_message(field + ": " + local_field + (
                     " -> " if e.suggestion == 'UPLOAD' else ' <- ') +
                                       remote_field)
             result = IOManager.get_input(
                 "Do you want to (u)pload, (d)ownload, (s)kip or (c)ancel sync? (u/d/s/c) ",
                 1)
         else:
             self.iom.send_message(
                 "This task does not yet exist on remote. Suggestion: " +
                 e.suggestion, 1)
             result = IOManager.get_input(
                 "Do you want to (u)pload, (s)kip or (c)ancel sync? (u/s/c) ",
                 1)
     elif e.remote_task:
         self.iom.print_separator()
         self.iom.send_message("Description: " +
                               e.remote_task.tw_task['description'])
         self.iom.send_message("ArenaTaskID: " + e.remote_task.ArenaTaskID)
         self.iom.send_message("This task does not yet exist on local.", 1)
         result = IOManager.get_input(
             "Do you want to (d)ownload, (s)kip or (c)ancel sync? (d/s/c) ",
             1)
     else:
         result = None
     return result
예제 #2
0
 def sync_preview(self, synclist):
     self.iom.print_separator()
     IOManager.formatted_print(('', 'Task', 'LastModified', 'Suggestion'))
     self.iom.print_separator()
     for e in synclist:
         IOManager.formatted_print(
             ('Local', e.local_description, e.local_last_modified, ''))
         IOManager.formatted_print(('Remote', e.remote_description,
                                    e.remote_last_modified, e.suggestion))
         self.iom.print_separator()
     return IOManager.get_input(
         "Do you want to sync (a)ll, sync (m)anually or (c)ancel? (a/m/c) ",
         1)
예제 #3
0
 def test_get_input(self, mock_input):
     result = IOManager.get_input('test', 1, 2)
     self.assertEqual(result, 'foo')
예제 #4
0
 def test_get_input(self, mock_input):
     result = IOManager.get_input('test', 1, 2)
     self.assertEqual(result, 'foo')