Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
6e1b928d
Commit
6e1b928d
authored
2 years ago
by
Daniel Brötzmann
Browse files
Options
Downloads
Patches
Plain Diff
chore: Fix test for GroupChatNickCompletion
parent
6cd4bf4a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gajim/gtk/groupchat_nick_completion.py
+5
-6
5 additions, 6 deletions
gajim/gtk/groupchat_nick_completion.py
test/no_gui/test_nick_completion.py
+27
-15
27 additions, 15 deletions
test/no_gui/test_nick_completion.py
with
32 additions
and
21 deletions
gajim/gtk/groupchat_nick_completion.py
+
5
−
6
View file @
6e1b928d
...
...
@@ -39,14 +39,12 @@ def __init__(self,
message_input
:
MessageInputTextView
)
->
None
:
self
.
_account
=
account
self
.
_client
=
app
.
get_client
(
account
)
self
.
_contact
=
contact
self
.
_contact
.
connect
(
'
user-nickname-changed
'
,
self
.
_on_user_nickname_changed
)
self
.
_message_input
=
message_input
self
.
_message_input
.
connect
(
'
key-press-event
'
,
self
.
_on_key_press
)
message_input
.
connect
(
'
key-press-event
'
,
self
.
_on_key_press
)
self
.
_sender_list
:
list
[
str
]
=
[]
self
.
_attention_list
:
list
[
str
]
=
[]
...
...
@@ -174,7 +172,7 @@ def _on_key_press(self,
text
.
endswith
(
gc_refer_to_nick_char
+
'
'
)):
with_refer_to_nick_char
=
True
after_nick_len
=
len
(
gc_refer_to_nick_char
+
'
'
)
if
(
self
.
_nick_hits
and
self
.
_last_key_tab
and
if
(
self
.
_nick_hits
and
self
.
_last_key_tab
and
text
[:
-
after_nick_len
].
endswith
(
self
.
_nick_hits
[
0
])):
# we should cycle
# Previous nick in list may had a space inside, so we check text
...
...
@@ -219,7 +217,8 @@ def _on_key_press(self,
else
:
start_iter
.
backward_chars
(
len
(
begin
))
self
.
_client
.
get_module
(
'
Chatstate
'
).
block_chatstates
(
client
=
app
.
get_client
(
self
.
_account
)
client
.
get_module
(
'
Chatstate
'
).
block_chatstates
(
self
.
_contact
,
True
)
message_buffer
.
delete
(
start_iter
,
end_iter
)
...
...
@@ -252,7 +251,7 @@ def _on_key_press(self,
completion
=
self
.
_nick_hits
[
0
]
message_buffer
.
insert_at_cursor
(
completion
+
add
)
self
.
_
client
.
get_module
(
'
Chatstate
'
).
block_chatstates
(
client
.
get_module
(
'
Chatstate
'
).
block_chatstates
(
self
.
_contact
,
False
)
self
.
_last_key_tab
=
True
...
...
This diff is collapsed.
Click to expand it.
test/no_gui/test_nick_completion.py
+
27
−
15
View file @
6e1b928d
import
unittest
from
unittest.mock
import
MagicMock
from
gajim
import
gui
gui
.
init
(
'
gtk
'
)
from
gajim.gui.util
import
NickCompletionGenerator
from
gajim.gui.groupchat_nick_completion
import
GroupChatNickCompletion
class
Test
(
unittest
.
TestCase
):
def
test_generate_suggestions
(
self
):
gen
=
NickCompletionGenerator
(
'
meeeee
'
)
contact
=
MagicMock
()
message_input
=
MagicMock
()
gen
=
GroupChatNickCompletion
(
'
testacc
'
,
contact
,
message_input
)
l
=
[
'
aaaa
'
,
'
meeeee
'
,
'
fooo
'
,
'
xxxxz
'
,
'
xaaaz
'
]
l
=
[
'
aaaa
'
,
'
fooo
'
,
'
xxxxz
'
,
'
xaaaz
'
]
for
n
in
l
:
gen
.
record_message
(
n
,
False
)
l2
=
[
'
xxx
'
]
+
l
r
=
gen
.
generate_suggestions
(
nicks
=
l2
,
beginning
=
'
x
'
)
r
=
gen
.
_
generate_suggestions
(
nicks
=
l2
,
beginning
=
'
x
'
)
self
.
assertEqual
(
r
,
[
'
xaaaz
'
,
'
xxxxz
'
,
'
xxx
'
])
r
=
gen
.
generate_suggestions
(
r
=
gen
.
_
generate_suggestions
(
nicks
=
l2
,
beginning
=
'
m
'
)
)
self
.
assertEqual
(
r
,
[])
for
n
in
[
'
xaaaz
'
,
'
xxxxz
'
]:
gen
.
record_message
(
n
,
True
)
r
=
gen
.
generate_suggestions
(
r
=
gen
.
_
generate_suggestions
(
nicks
=
l2
,
beginning
=
'
x
'
)
)
self
.
assertEqual
(
r
,
[
'
xxxxz
'
,
'
xaaaz
'
,
'
xxx
'
])
r
=
gen
.
generate_suggestions
(
r
=
gen
.
_
generate_suggestions
(
nicks
=
l2
,
beginning
=
''
)
)
self
.
assertEqual
(
r
,
[
'
xxxxz
'
,
'
xaaaz
'
,
'
aaaa
'
,
'
fooo
'
,
'
xxx
'
])
l2
[
1
]
=
'
bbbb
'
gen
.
contact_renamed
(
'
aaaa
'
,
'
bbbb
'
)
r
=
gen
.
generate_suggestions
(
old_name
=
'
aaaa
'
new_name
=
'
bbbb
'
for
lst
in
(
gen
.
_attention_list
,
gen
.
_sender_list
):
for
idx
,
contact
in
enumerate
(
lst
):
if
contact
==
old_name
:
lst
[
idx
]
=
new_name
r
=
gen
.
_generate_suggestions
(
nicks
=
l2
,
beginning
=
''
)
)
self
.
assertEqual
(
r
,
[
'
xxxxz
'
,
'
xaaaz
'
,
'
bbbb
'
,
'
fooo
'
,
'
xxx
'
])
if
__name__
==
"
__main__
"
:
if
__name__
==
'
__main__
'
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment