Refactored tests

This commit is contained in:
emdee 2023-07-14 14:07:08 +00:00
parent ad59434927
commit 1aa831cbd6
5 changed files with 992 additions and 669 deletions

View file

@ -1,80 +0,0 @@
tox_version_major
tox_version_minor
tox_version_patch
tox_version_is_compatible
tox_public_key_size
tox_secret_key_size
tox_conference_uid_size
tox_conference_id_size
tox_nospam_size
tox_address_size
tox_max_name_length
tox_max_status_message_length
tox_max_friend_request_length
tox_max_message_length
tox_max_custom_packet_size
tox_hash_length
tox_file_id_length
tox_max_filename_length
tox_max_hostname_length
tox_options_get_ipv6_enabled
tox_options_get_udp_enabled
tox_options_get_local_discovery_enabled
tox_options_get_dht_announcements_enabled
tox_options_get_proxy_type
tox_options_get_proxy_port
tox_options_get_start_port
tox_options_get_end_port
tox_options_get_tcp_port
tox_options_get_hole_punching_enabled
tox_options_get_savedata_type
tox_options_get_savedata_length
tox_options_get_experimental_thread_safety
tox_file_seek
tox_callback_conference_connected
tox_callback_conference_message
tox_callback_conference_title
tox_callback_conference_peer_list_changed
tox_conference_new
tox_conference_delete
tox_conference_peer_count
tox_conference_peer_get_name_size
tox_conference_peer_get_name
tox_conference_peer_get_public_key
tox_conference_peer_number_is_ours
tox_conference_offline_peer_count
tox_conference_offline_peer_get_name_size
tox_conference_offline_peer_get_name
tox_conference_offline_peer_get_public_key
tox_conference_offline_peer_get_last_active
tox_conference_set_max_offline
tox_conference_invite
tox_conference_join
tox_conference_send_message
tox_conference_get_title_size
tox_conference_get_title
tox_conference_set_title
tox_conference_get_chatlist_size
tox_conference_get_chatlist
tox_conference_get_type
tox_conference_get_id
tox_conference_by_id
tox_conference_get_uid
tox_conference_by_uid
tox_group_max_topic_length
tox_group_max_part_length
tox_group_max_group_name_length
tox_group_max_password_size
tox_group_chat_id_size
tox_group_peer_public_key_size
tox_group_peer_get_connection_status
tox_group_get_voice_state
tox_callback_group_voice_state
tox_group_get_topic_lock
tox_callback_group_topic_lock
tox_group_send_custom_private_packet
tox_callback_group_custom_private_packet
tox_group_founder_set_topic_lock
tox_group_founder_set_voice_state
tox_group_set_ignore
tox_group_mod_kick_peer

View file

@ -175,7 +175,7 @@ class Tox:
def kill(self):
if hasattr(self, 'AV'): del self.AV
LOG_DEBUG(f"tox_kill")
LOG_INFO(f"tox_kill")
try:
Tox.libtoxcore.tox_kill(self._tox_pointer)
except Exception as e:
@ -305,7 +305,7 @@ class Tox:
raise ArgumentError('One of the arguments to the function was NULL when it was not expected.')
if tox_err_bootstrap == TOX_ERR_BOOTSTRAP['BAD_HOST']:
raise ArgumentError('The address could not be resolved to an IP '
'address, or the IP address passed was invalid.')
'address, or the address passed was invalid.')
if tox_err_bootstrap == TOX_ERR_BOOTSTRAP['BAD_PORT']:
raise ArgumentError('The port passed was invalid. The valid port range is (1, 65535).')
# me - this seems wrong - should be False
@ -763,7 +763,8 @@ class Tox:
"""
Checks if a friend with the given friend number exists and returns true if it does.
"""
return bool(Tox.libtoxcore.tox_friend_exists(self._tox_pointer, c_uint32(friend_number)))
# bool() -> TypeError: 'str' object cannot be interpreted as an integer
return Tox.libtoxcore.tox_friend_exists(self._tox_pointer, c_uint32(friend_number))
def self_get_friend_list_size(self):
"""
@ -1154,24 +1155,28 @@ class Tox:
raise ToxError('The function did not return OK for set typing.')
def friend_send_message(self, friend_number, message_type, message):
"""
Send a text chat message to an online friend.
"""Send a text chat message to an online friend.
This function creates a chat message packet and pushes it into the send queue.
The message length may not exceed TOX_MAX_MESSAGE_LENGTH. Larger messages must be split by the client and sent
as separate messages. Other clients can then reassemble the fragments. Messages may not be empty.
The message length may not exceed
TOX_MAX_MESSAGE_LENGTH. Larger messages must be split by the
client and sent as separate messages. Other clients can then
reassemble the fragments. Messages may not be empty.
The return value of this function is the message ID. If a read receipt is received, the triggered
`friend_read_receipt` event will be passed this message ID.
The return value of this function is the message ID. If a read
receipt is received, the triggered `friend_read_receipt` event
will be passed this message ID.
Message IDs are unique per friend. The first message ID is 0. Message IDs are incremented by 1 each time a
message is sent. If UINT32_MAX messages were sent, the next message ID is 0.
Message IDs are unique per friend. The first message ID is 0.
Message IDs are incremented by 1 each time a message is sent.
If UINT32_MAX messages were sent, the next message ID is 0.
:param friend_number: The friend number of the friend to send the message to.
:param message_type: Message type (TOX_MESSAGE_TYPE).
:param message: A non-None message text.
:return: message ID
"""
tox_err_friend_send_message = c_int()
LOG_DEBUG(f"tox_friend_send_message")
@ -1938,8 +1943,8 @@ class Tox:
byref(error))
if error.value:
LOG_ERROR(f"group_join {error.value}")
raise ToxError(f"group_join {error.value}")
LOG_ERROR(f"group_join {error.value} {TOX_ERR_GROUP_JOIN[error.value]}")
raise ToxError(f"group_join {error.value} {TOX_ERR_GROUP_JOIN[error.value]}")
return result
def group_reconnect(self, group_number):
@ -2438,12 +2443,12 @@ class Tox:
def groups_get_list(self):
raise NotImplementedError('tox_groups_get_list')
groups_list_size = self.group_get_number_groups()
groups_list = create_string_buffer(sizeof(c_uint32) * groups_list_size)
groups_list = POINTER(c_uint32)(groups_list)
LOG_DEBUG(f"tox_groups_get_list")
Tox.libtoxcore.tox_groups_get_list(self._tox_pointer, groups_list)
return groups_list[0:groups_list_size]
# groups_list_size = self.group_get_number_groups()
# groups_list = create_string_buffer(sizeof(c_uint32) * groups_list_size)
# groups_list = POINTER(c_uint32)(groups_list)
# LOG_DEBUG(f"tox_groups_get_list")
# Tox.libtoxcore.tox_groups_get_list(self._tox_pointer, groups_list)
# return groups_list[0:groups_list_size]
def group_get_privacy_state(self, group_number):
"""
@ -3105,6 +3110,9 @@ class Tox:
LOG_DEBUG(f"tox_callback_group_moderation")
def group_toggle_set_ignore(self, group_number, peer_id, ignore):
return group_set_ignore(self, group_number, peer_id, ignore)
def group_set_ignore(self, group_number, peer_id, ignore):
"""
Ignore or unignore a peer.
@ -3116,10 +3124,9 @@ class Tox:
"""
error = c_int()
LOG_DEBUG(f"tox_group_toggle_set_ignore")
result = Tox.libtoxcore.tox_group_toggle_set_ignore(self._tox_pointer, group_number, peer_id, ignore, byref(error))
LOG_DEBUG(f"tox_group_set_ignore")
result = Tox.libtoxcore.tox_group_set_ignore(self._tox_pointer, group_number, peer_id, ignore, byref(error))
if error.value:
LOG_ERROR(f"tox_group_toggle_set_ignore {error.value}")
raise ToxError("tox_group_toggle_set_ignore {error.value}")
LOG_ERROR(f"tox_group_set_ignore {error.value}")
raise ToxError("tox_group_set_ignore {error.value}")
return result