str to bytes convert moved to wrapper
This commit is contained in:
parent
7e08be71e0
commit
e15620c3ad
@ -6,13 +6,13 @@ from toxygen.middleware.tox_factory import *
|
|||||||
class TestTox:
|
class TestTox:
|
||||||
|
|
||||||
def test_creation(self):
|
def test_creation(self):
|
||||||
name = b'Toxygen User'
|
name = 'Toxygen User'
|
||||||
status_message = b'Toxing on Toxygen'
|
status_message = 'Toxing on Toxygen'
|
||||||
tox = tox_factory()
|
tox = tox_factory()
|
||||||
tox.self_set_name(name)
|
tox.self_set_name(name)
|
||||||
tox.self_set_status_message(status_message)
|
tox.self_set_status_message(status_message)
|
||||||
data = tox.get_savedata()
|
data = tox.get_savedata()
|
||||||
del tox
|
del tox
|
||||||
tox = tox_factory(data)
|
tox = tox_factory(data)
|
||||||
assert tox.self_get_name() == str(name, 'utf-8')
|
assert tox.self_get_name() == name
|
||||||
assert tox.self_get_status_message() == str(status_message, 'utf-8')
|
assert tox.self_get_status_message() == status_message
|
||||||
|
@ -251,8 +251,8 @@ class App:
|
|||||||
return False
|
return False
|
||||||
name = profile_name or 'toxygen_user'
|
name = profile_name or 'toxygen_user'
|
||||||
self._tox = tox_factory()
|
self._tox = tox_factory()
|
||||||
self._tox.self_set_name(bytes(name, 'utf-8') if name else b'Toxygen User')
|
self._tox.self_set_name(name if name else 'Toxygen User')
|
||||||
self._tox.self_set_status_message(b'Toxing on Toxygen')
|
self._tox.self_set_status_message('Toxing on Toxygen')
|
||||||
self._path = profile_path
|
self._path = profile_path
|
||||||
if result.password:
|
if result.password:
|
||||||
self._toxes.set_password(result.password)
|
self._toxes.set_password(result.password)
|
||||||
|
@ -51,11 +51,11 @@ class Profile(basecontact.BaseContact, tox_save.ToxSave):
|
|||||||
if self.name == value:
|
if self.name == value:
|
||||||
return
|
return
|
||||||
super().set_name(value)
|
super().set_name(value)
|
||||||
self._tox.self_set_name(self._name.encode('utf-8'))
|
self._tox.self_set_name(self._name)
|
||||||
|
|
||||||
def set_status_message(self, value):
|
def set_status_message(self, value):
|
||||||
super().set_status_message(value)
|
super().set_status_message(value)
|
||||||
self._tox.self_set_status_message(self._status_message.encode('utf-8'))
|
self._tox.self_set_status_message(self._status_message)
|
||||||
|
|
||||||
def set_new_nospam(self):
|
def set_new_nospam(self):
|
||||||
"""Sets new nospam part of tox id"""
|
"""Sets new nospam part of tox id"""
|
||||||
|
@ -375,6 +375,7 @@ class Tox:
|
|||||||
:return: True on success.
|
:return: True on success.
|
||||||
"""
|
"""
|
||||||
tox_err_set_info = c_int()
|
tox_err_set_info = c_int()
|
||||||
|
name = bytes(name, 'utf-8')
|
||||||
result = Tox.libtoxcore.tox_self_set_name(self._tox_pointer, c_char_p(name),
|
result = Tox.libtoxcore.tox_self_set_name(self._tox_pointer, c_char_p(name),
|
||||||
c_size_t(len(name)), byref(tox_err_set_info))
|
c_size_t(len(name)), byref(tox_err_set_info))
|
||||||
tox_err_set_info = tox_err_set_info.value
|
tox_err_set_info = tox_err_set_info.value
|
||||||
@ -423,6 +424,7 @@ class Tox:
|
|||||||
:return: True on success.
|
:return: True on success.
|
||||||
"""
|
"""
|
||||||
tox_err_set_info = c_int()
|
tox_err_set_info = c_int()
|
||||||
|
status_message = bytes(status_message, 'utf-8')
|
||||||
result = Tox.libtoxcore.tox_self_set_status_message(self._tox_pointer, c_char_p(status_message),
|
result = Tox.libtoxcore.tox_self_set_status_message(self._tox_pointer, c_char_p(status_message),
|
||||||
c_size_t(len(status_message)), byref(tox_err_set_info))
|
c_size_t(len(status_message)), byref(tox_err_set_info))
|
||||||
tox_err_set_info = tox_err_set_info.value
|
tox_err_set_info = tox_err_set_info.value
|
||||||
|
Loading…
Reference in New Issue
Block a user