updates
This commit is contained in:
parent
9111a1def8
commit
aedf36cda2
@ -1906,15 +1906,13 @@ class Tox:
|
|||||||
c_size_t(len(group_name)),
|
c_size_t(len(group_name)),
|
||||||
peer_info, byref(error))
|
peer_info, byref(error))
|
||||||
else:
|
else:
|
||||||
nick_length = len(nick)
|
|
||||||
cnick = c_char_p(nick)
|
|
||||||
cgroup_name = c_char_p(group_name)
|
cgroup_name = c_char_p(group_name)
|
||||||
result = Tox.libtoxcore.tox_group_new(self._tox_pointer,
|
result = Tox.libtoxcore.tox_group_new(self._tox_pointer,
|
||||||
privacy_state,
|
privacy_state,
|
||||||
cgroup_name,
|
cgroup_name,
|
||||||
c_size_t(len(group_name)),
|
c_size_t(len(group_name)),
|
||||||
cnick,
|
c_char_p(nick),
|
||||||
c_size_t(nick_length),
|
c_size_t(len(nick)),
|
||||||
byref(error))
|
byref(error))
|
||||||
|
|
||||||
if error.value:
|
if error.value:
|
||||||
@ -1961,8 +1959,7 @@ class Tox:
|
|||||||
byref(error))
|
byref(error))
|
||||||
else:
|
else:
|
||||||
if not password:
|
if not password:
|
||||||
# dunno
|
cpassword = None
|
||||||
cpassword = POINTER(None)()
|
|
||||||
else:
|
else:
|
||||||
cpassword = c_char_p(password)
|
cpassword = c_char_p(password)
|
||||||
result = Tox.libtoxcore.tox_group_join(self._tox_pointer,
|
result = Tox.libtoxcore.tox_group_join(self._tox_pointer,
|
||||||
@ -1996,7 +1993,9 @@ class Tox:
|
|||||||
raise ToxError(f"tox_group_ group_number < 0 {group_number}")
|
raise ToxError(f"tox_group_ group_number < 0 {group_number}")
|
||||||
error = c_int()
|
error = c_int()
|
||||||
LOG_DEBUG(f"tox.group_reconnect")
|
LOG_DEBUG(f"tox.group_reconnect")
|
||||||
result = Tox.libtoxcore.tox_group_reconnect(self._tox_pointer, c_uint32(group_number), byref(error))
|
result = Tox.libtoxcore.tox_group_reconnect(self._tox_pointer,
|
||||||
|
c_uint32(group_number),
|
||||||
|
byref(error))
|
||||||
if error.value:
|
if error.value:
|
||||||
s = sGetError(error.value, TOX_ERR_GROUP_RECONNECT)
|
s = sGetError(error.value, TOX_ERR_GROUP_RECONNECT)
|
||||||
LOG_ERROR(f"group_new {error.value} {s}")
|
LOG_ERROR(f"group_new {error.value} {s}")
|
||||||
@ -2543,13 +2542,11 @@ class Tox:
|
|||||||
# QObject::installEventFilter(): Cannot filter events for objects in a different thread.
|
# QObject::installEventFilter(): Cannot filter events for objects in a different thread.
|
||||||
# QBasicTimer::start: Timers cannot be started from another thread
|
# QBasicTimer::start: Timers cannot be started from another thread
|
||||||
result = bin_to_string(buff, TOX_GROUP_CHAT_ID_SIZE)
|
result = bin_to_string(buff, TOX_GROUP_CHAT_ID_SIZE)
|
||||||
LOG_INFO(f"tox.group_get_chat_id group_number={group_number} result={result}")
|
LOG_DEBUG(f"tox.group_get_chat_id group_number={group_number} result={result}")
|
||||||
|
|
||||||
LOG_TRACE(f"tox_group_get_chat_id")
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def group_get_number_groups(self):
|
def group_get_number_groups(self):
|
||||||
#? 0 based or 1 based
|
|
||||||
"""
|
"""
|
||||||
Return the number of groups in the Tox chats array.
|
Return the number of groups in the Tox chats array.
|
||||||
"""
|
"""
|
||||||
@ -2559,7 +2556,7 @@ class Tox:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG_WARN(f"tox.group_get_number_groups EXCEPTION {e}")
|
LOG_WARN(f"tox.group_get_number_groups EXCEPTION {e}")
|
||||||
result = 0
|
result = 0
|
||||||
LOG_DEBUG(f"tox.group_get_number_groups returning {result}")
|
LOG_INFO(f"tox.group_get_number_groups returning {result}")
|
||||||
return int(result)
|
return int(result)
|
||||||
|
|
||||||
def groups_get_list(self):
|
def groups_get_list(self):
|
||||||
|
@ -423,12 +423,12 @@ class ToxSuite(unittest.TestCase):
|
|||||||
LOG.debug(f"call_bootstrap ts.bootstrap_tcp {len(lElts)}")
|
LOG.debug(f"call_bootstrap ts.bootstrap_tcp {len(lElts)}")
|
||||||
ts.bootstrap_tcp(lElts, lToxes)
|
ts.bootstrap_tcp(lElts, lToxes)
|
||||||
|
|
||||||
def group_until_connected(self, group_number):
|
def group_until_connected(self, group_number, num=None, iMax=THRESHOLD):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
i = 0
|
i = 0
|
||||||
bRet = None
|
bRet = None
|
||||||
while i <= THRESHOLD :
|
while i <= iMax :
|
||||||
iRet = self.bob.group_is_connected(group_number)
|
iRet = self.bob.group_is_connected(group_number)
|
||||||
if iRet == True or iRet == 0:
|
if iRet == True or iRet == 0:
|
||||||
bRet = True
|
bRet = True
|
||||||
@ -450,13 +450,15 @@ class ToxSuite(unittest.TestCase):
|
|||||||
|
|
||||||
if bRet:
|
if bRet:
|
||||||
LOG.info(f"group_until_connected returning True {i}" \
|
LOG.info(f"group_until_connected returning True {i}" \
|
||||||
|
+f"iMax={iMax}" \
|
||||||
+f" BOB={self.bob.self_get_connection_status()}" \
|
+f" BOB={self.bob.self_get_connection_status()}" \
|
||||||
+f" last={int(self.bob.mycon_time)}" )
|
+f" last={int(self.bob.mycon_time)}" )
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
LOG.warning(f"group_until_connected returning False {i}" \
|
LOG.warning(f"group_until_connected returning False {i}" \
|
||||||
+f" BOB={self.bob.self_get_connection_status()}" \
|
+f"iMax={iMax}" \
|
||||||
+f" last={int(self.bob.mycon_time)}" )
|
+f" BOB={self.bob.self_get_connection_status()}" \
|
||||||
|
+f" last={int(self.bob.mycon_time)}" )
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def loop_until_connected(self, num=None):
|
def loop_until_connected(self, num=None):
|
||||||
@ -532,7 +534,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
return all([getattr(obj, attr) is not None for obj in objs])
|
return all([getattr(obj, attr) is not None for obj in objs])
|
||||||
|
|
||||||
def wait_otox_attrs(self, obj, attrs):
|
def wait_otox_attrs(self, obj, attrs):
|
||||||
assert all(attrs)
|
assert all(attrs), f"wait_otox_attrs {attrs}"
|
||||||
i = 0
|
i = 0
|
||||||
while i <= THRESHOLD:
|
while i <= THRESHOLD:
|
||||||
if i % 5 == 0:
|
if i % 5 == 0:
|
||||||
@ -550,7 +552,7 @@ class ToxSuite(unittest.TestCase):
|
|||||||
self.loop(100)
|
self.loop(100)
|
||||||
i += 1
|
i += 1
|
||||||
else:
|
else:
|
||||||
LOG.warning(f"wait_otox_attrs i >= {THRESHOLD} {[getattr(obj, attr) for attr in attrs]}")
|
LOG.warning(f"wait_otox_attrs i >= {THRESHOLD} results={[getattr(obj, attr) for attr in attrs]}")
|
||||||
|
|
||||||
return all([getattr(obj, attr) for attr in attrs])
|
return all([getattr(obj, attr) for attr in attrs])
|
||||||
|
|
||||||
@ -838,14 +840,16 @@ class ToxSuite(unittest.TestCase):
|
|||||||
assert otox.group_get_privacy_state(iGrp) == privacy_state
|
assert otox.group_get_privacy_state(iGrp) == privacy_state
|
||||||
|
|
||||||
assert otox.group_get_number_groups() > 0
|
assert otox.group_get_number_groups() > 0
|
||||||
LOG.info(f"group pK={sPk} iGrp={iGrp}")
|
LOG.info(f"group pK={sPk} iGrp={iGrp} n={otox.group_get_number_groups()}")
|
||||||
return iGrp
|
return iGrp
|
||||||
|
|
||||||
|
# 360497DA684BCE2A500C1AF9B3A5CE949BBB9F6FB1F91589806FB04CA039E313
|
||||||
|
# 75D2163C19FEFFE51508046398202DDC321E6F9B6654E99BAE45FFEC134F05DE
|
||||||
def otox_test_groups_join(self, otox,
|
def otox_test_groups_join(self, otox,
|
||||||
chat_id="360497DA684BCE2A500C1AF9B3A5CE949BBB9F6FB1F91589806FB04CA039E313",
|
chat_id="75d2163c19feffe51508046398202ddc321e6f9b6654e99bae45ffec134f05de",
|
||||||
nick='nick',
|
nick='nick',
|
||||||
topic='Test Topic', # str
|
topic='Test Topic', # str
|
||||||
):
|
):
|
||||||
status = ''
|
status = ''
|
||||||
password = ''
|
password = ''
|
||||||
LOG.debug(f"group_join nick={nick} chat_id={chat_id}")
|
LOG.debug(f"group_join nick={nick} chat_id={chat_id}")
|
||||||
@ -855,6 +859,10 @@ class ToxSuite(unittest.TestCase):
|
|||||||
assert type(group_number) == int, "otox_test_groups_join group_number not an int"
|
assert type(group_number) == int, "otox_test_groups_join group_number not an int"
|
||||||
assert group_number < UINT32_MAX, "otox_test_groups_join group_number failure UINT32_MAX"
|
assert group_number < UINT32_MAX, "otox_test_groups_join group_number failure UINT32_MAX"
|
||||||
assert group_number >= 0, f"otox_test_groups_join group_number={group_number} < 0"
|
assert group_number >= 0, f"otox_test_groups_join group_number={group_number} < 0"
|
||||||
|
iGrp = group_number
|
||||||
|
sPk = otox.group_self_get_public_key(iGrp)
|
||||||
|
LOG.info(f"otox_test_groups_join pK={sPk} iGrp={iGrp} n={otox.group_get_number_groups()}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# gui
|
# gui
|
||||||
LOG.error(f"otox_test_groups_join EXCEPTION {e}")
|
LOG.error(f"otox_test_groups_join EXCEPTION {e}")
|
||||||
@ -865,12 +873,22 @@ class ToxSuite(unittest.TestCase):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error(f"group_is_connected EXCEPTION {e}")
|
LOG.error(f"group_is_connected EXCEPTION {e}")
|
||||||
return -1
|
return -1
|
||||||
LOG.debug(f"group_is_connected group_number={group_number} bRet={bRet}")
|
|
||||||
# chat->connection_state == CS_CONNECTED || chat->connection_state == CS_CONNECTING;
|
# chat->connection_state == CS_CONNECTED || chat->connection_state == CS_CONNECTING;
|
||||||
if bRet:
|
if bRet:
|
||||||
LOG.warn(f"group_is_connected WARN group_number={group_number} ")
|
LOG.warn(f"group_is_connected WARN not connected group_number={group_number} n={otox.group_get_number_groups()}")
|
||||||
else:
|
else:
|
||||||
LOG.info(f"group_is_connected SUCCESS group_number={group_number} ")
|
LOG.info(f"group_is_connected SUCCESS connected group_number={group_number} n={otox.group_get_number_groups()}")
|
||||||
|
|
||||||
|
try:
|
||||||
|
bRet = self.group_until_connected(group_number, iMax=2*THRESHOLD)
|
||||||
|
except Exception as e:
|
||||||
|
LOG.error(f"group_until_connected EXCEPTION {e}")
|
||||||
|
return -1
|
||||||
|
# chat->connection_state == CS_CONNECTED || chat->connection_state == CS_CONNECTING;
|
||||||
|
if bRet:
|
||||||
|
LOG.warn(f"group_until_connected WARN not connected group_number={group_number} n={otox.group_get_number_groups()}")
|
||||||
|
else:
|
||||||
|
LOG.info(f"group_until_connected SUCCESS connected group_number={group_number} n={otox.group_get_number_groups()}")
|
||||||
|
|
||||||
return group_number
|
return group_number
|
||||||
|
|
||||||
@ -908,6 +926,17 @@ class ToxSuite(unittest.TestCase):
|
|||||||
LOG.error(f"group_is_connected ERROR {e}")
|
LOG.error(f"group_is_connected ERROR {e}")
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
try:
|
||||||
|
bRet = self.group_until_connected(group_number, iMax=2*THRESHOLD)
|
||||||
|
except Exception as e:
|
||||||
|
LOG.error(f"group_until_connected EXCEPTION {e}")
|
||||||
|
return -1
|
||||||
|
# chat->connection_state == CS_CONNECTED || chat->connection_state == CS_CONNECTING;
|
||||||
|
if bRet:
|
||||||
|
LOG.warn(f"group_until_connected WARN not connected group_number={group_number} n={otox.group_get_number_groups()}")
|
||||||
|
else:
|
||||||
|
LOG.info(f"group_until_connected SUCCESS connected group_number={group_number} n={otox.group_get_number_groups()}")
|
||||||
|
|
||||||
message = bytes('hello', 'utf-8')
|
message = bytes('hello', 'utf-8')
|
||||||
try:
|
try:
|
||||||
bRet = otox.group_send_message(group_number, TOX_MESSAGE_TYPE['NORMAL'], 'hello')
|
bRet = otox.group_send_message(group_number, TOX_MESSAGE_TYPE['NORMAL'], 'hello')
|
||||||
@ -1359,6 +1388,10 @@ class ToxSuite(unittest.TestCase):
|
|||||||
t:group_disconnect
|
t:group_disconnect
|
||||||
t:group_leave
|
t:group_leave
|
||||||
"""
|
"""
|
||||||
|
if not self.get_connection_status():
|
||||||
|
LOG.warning(f"test_groups_join NOT CONNECTED")
|
||||||
|
self.loop_until_connected()
|
||||||
|
|
||||||
iGrp = self.otox_test_groups_join(self.bob)
|
iGrp = self.otox_test_groups_join(self.bob)
|
||||||
LOG.info(f"test_groups_join iGrp={iGrp}")
|
LOG.info(f"test_groups_join iGrp={iGrp}")
|
||||||
assert iGrp >= 0, f"test_groups_join iGrp={iGrp}"
|
assert iGrp >= 0, f"test_groups_join iGrp={iGrp}"
|
||||||
|
Loading…
Reference in New Issue
Block a user