devopshq / youtrack

YouTrack Python 3 Client Library
https://devopshq.github.io/youtrack/
MIT License
27 stars 14 forks source link

bundle.to_xml() works wrong #10

Open allburov opened 7 years ago

allburov commented 7 years ago

1 - problems with encoding

# python 3.4
bundle = connection.get_enum_bundle('70-756-1479473044676')
bundle.to_xml() # raise

  File "E:/GITHUB/dohq_youtrack\youtrack\youtrack.py", line 635, in to_xml
    result += ">%s</%s>" % (escape(self.name.encode('utf-8')), self.element_name)
  File "C:\Python34\lib\xml\sax\saxutils.py", line 27, in escape
    data = data.replace("&", "&amp;")
TypeError: 'str' does not support the buffer interface

and from https://github.com/devopshq/youtrack/issues/9

# python 3.6.3
ipdb> str(bundle_value)
''
ipdb> bundle_value.to_xml()
*** TypeError: a bytes-like object is required, not 'str'

2 - problem with attribute When I GET /rest/admin/customfield/bundle/70-756-1479473044676 xml is:

<enumeration name="70-756-1479473044676">
<value colorIndex="1">Non-default Container</value>
<value colorIndex="3">Default Container</value>
<value colorIndex="2">11</value>
</enumeration>

After, i try bundle.to_xml() and get this, without colorIndex

<enumeration name="70-756-1479473044676">
  <value>Non-default Container</value>
  <value>Default Container</value>
  <value>11</value>
</enumeration>
allburov commented 7 years ago

First problem - we must remove encode , like this: https://github.com/devopshq/youtrack/commit/ae66bd0a82505b67621ad7223d1d2af099e6aa6d

I fix it only un bundle