1. Mark Edgington
  2. michel-orgmode
  3. Pull requests

Pull requests

#1 Declined

Leave task's title as a unicode, not a str, then encode when printing.

  1. Brian Gainor

Previously, title was being encoded right away, which meant that printing the list worked correctly, but writing to a file gave a UnicodeDecodeError.

Comments (5)

  1. Mark Edgington repo owner

    I'm assuming that this doesn't cause any trouble if one calls get_gtask_list_as_tasktree() and then pushes the tasktree back to a different gtask list -- I mean, no information is lost (i.e. if you do List A -> Tree A -> List B -> Tree B, are the contents of Tree A and Tree B identical?)? Would you be able to add a test case to run_tests.py that checks for the UnicodeDecodeError you got?

  2. Brian Gainor author

    I hadn't considered that case; I assume it wouldn't be a problem because the service object is already using unicode objects, but I'll explicitly check that case. I should be able to do that and add the test case over the weekend.

  3. Brian Gainor author

    I manually tested the case where you pull from one list and push to another, the following way:

      $ michel --pull --listname list1 --orgfile list1.org
      $ michel --push --listname list2 --orgfile list1.org
      $ michel --pull --listname list2 --orgfile list2.org
      $ diff list1.org list2.org # No output

    I was going to add a test for the UnicodeDecodeError, but based on how the functions are currently set up, I'd have to actually connect to the Google Tasks service to do the test. The code that was causing the error for me was in get_gtask_list_as_tasktree(), when it's calling tasks_tree.add_subtask(). The existing test didn't catch the error, because it calls this method directly (and gives unicodes as arguments). I could try refactoring get_gtask_list_as_tasktree() to make it take the output from the service as an argument, instead of connecting to the service, or I could somehow create a mock of the GTasks service to give fake output, but I don't have as much experience with Python's unit testing library, so I'm not sure of the best way to do that.