Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
f3dc1a1b
Commit
f3dc1a1b
authored
9 years ago
by
inso
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev' of
https://github.com/ucoin-io/cutecoin
into dev
parents
2bd18eac
7dac5cd2
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
src/cutecoin/gui/process_cfg_community.py
+6
-2
6 additions, 2 deletions
src/cutecoin/gui/process_cfg_community.py
src/cutecoin/tests/process_cfg_community/test_add_community.py
+101
-2
101 additions, 2 deletions
...utecoin/tests/process_cfg_community/test_add_community.py
with
107 additions
and
4 deletions
src/cutecoin/gui/process_cfg_community.py
+
6
−
2
View file @
f3dc1a1b
...
@@ -61,11 +61,15 @@ class StepPageInit(Step):
...
@@ -61,11 +61,15 @@ class StepPageInit(Step):
logging
.
debug
(
"
Is valid ?
"
)
logging
.
debug
(
"
Is valid ?
"
)
self
.
node
=
yield
from
Node
.
from_address
(
self
.
config_dialog
.
app
.
network_manager
,
None
,
server
,
port
)
self
.
node
=
yield
from
Node
.
from_address
(
self
.
config_dialog
.
app
.
network_manager
,
None
,
server
,
port
)
if
self
.
node
:
if
self
.
node
:
identity
=
yield
from
self
.
app
.
identities_registry
.
future_find
(
self
.
account
.
pubkey
,
self
.
community
)
community
=
Community
.
create
(
self
.
app
.
network_manager
,
self
.
node
)
identity
=
yield
from
self
.
app
.
identities_registry
.
future_find
(
self
.
account
.
pubkey
,
community
)
if
identity
.
blockchain_state
==
BlockchainState
.
NOT_FOUND
:
if
identity
.
blockchain_state
==
BlockchainState
.
NOT_FOUND
:
self
.
config_dialog
.
label_error
.
setText
(
self
.
tr
(
"
Could not find your identity on the network.
"
))
self
.
config_dialog
.
label_error
.
setText
(
self
.
tr
(
"
Could not find your identity on the network.
"
))
else
:
self
.
config_dialog
.
community
=
community
self
.
config_dialog
.
next
()
else
:
else
:
self
.
next
(
)
self
.
config_dialog
.
label_error
.
setText
(
self
.
tr
(
"
Could not connect.
"
)
)
@pyqtSlot
()
@pyqtSlot
()
def
check_connect
(
self
):
def
check_connect
(
self
):
...
...
This diff is collapsed.
Click to expand it.
src/cutecoin/tests/process_cfg_community/test_add_community.py
+
101
−
2
View file @
f3dc1a1b
...
@@ -7,7 +7,7 @@ import time
...
@@ -7,7 +7,7 @@ import time
from
PyQt5.QtWidgets
import
QDialog
from
PyQt5.QtWidgets
import
QDialog
from
PyQt5.QtCore
import
QLocale
,
Qt
from
PyQt5.QtCore
import
QLocale
,
Qt
from
PyQt5.QtTest
import
QTest
from
PyQt5.QtTest
import
QTest
from
cutecoin.tests.mocks.bma
import
new_blockchain
from
cutecoin.tests.mocks.bma
import
new_blockchain
,
nice_blockchain
from
cutecoin.tests.mocks.access_manager
import
MockNetworkAccessManager
from
cutecoin.tests.mocks.access_manager
import
MockNetworkAccessManager
from
cutecoin.core.registry.identities
import
IdentitiesRegistry
from
cutecoin.core.registry.identities
import
IdentitiesRegistry
from
cutecoin.gui.process_cfg_community
import
ProcessConfigureCommunity
from
cutecoin.gui.process_cfg_community
import
ProcessConfigureCommunity
...
@@ -42,7 +42,7 @@ class ProcessAddCommunity(unittest.TestCase):
...
@@ -42,7 +42,7 @@ class ProcessAddCommunity(unittest.TestCase):
finally
:
finally
:
asyncio
.
set_event_loop
(
None
)
asyncio
.
set_event_loop
(
None
)
def
test_
add
_community_empty_blockchain
(
self
):
def
test_
register
_community_empty_blockchain
(
self
):
mock
=
new_blockchain
.
get_mock
()
mock
=
new_blockchain
.
get_mock
()
time
.
sleep
(
2
)
time
.
sleep
(
2
)
logging
.
debug
(
mock
.
pretend_url
)
logging
.
debug
(
mock
.
pretend_url
)
...
@@ -99,6 +99,105 @@ class ProcessAddCommunity(unittest.TestCase):
...
@@ -99,6 +99,105 @@ class ProcessAddCommunity(unittest.TestCase):
self
.
lp
.
run_until_complete
(
open_dialog
(
process_community
))
self
.
lp
.
run_until_complete
(
open_dialog
(
process_community
))
mock
.
delete_mock
()
mock
.
delete_mock
()
def
test_connect_community_empty_blockchain
(
self
):
mock
=
new_blockchain
.
get_mock
()
time
.
sleep
(
2
)
logging
.
debug
(
mock
.
pretend_url
)
self
.
network_manager
.
set_mock_path
(
mock
.
pretend_url
)
process_community
=
ProcessConfigureCommunity
(
self
.
application
,
self
.
account
,
None
,
self
.
password_asker
)
@asyncio.coroutine
def
open_dialog
(
process_community
):
result
=
yield
from
process_community
.
async_exec
()
self
.
assertEqual
(
result
,
QDialog
.
Rejected
)
def
close_dialog
():
if
process_community
.
isVisible
():
process_community
.
close
()
@asyncio.coroutine
def
exec_test
():
yield
from
asyncio
.
sleep
(
1
)
QTest
.
mouseClick
(
process_community
.
lineedit_server
,
Qt
.
LeftButton
)
QTest
.
keyClicks
(
process_community
.
lineedit_server
,
"
127.0.0.1
"
)
QTest
.
mouseDClick
(
process_community
.
spinbox_port
,
Qt
.
LeftButton
)
process_community
.
spinbox_port
.
setValue
(
50000
)
self
.
assertEqual
(
process_community
.
stacked_pages
.
currentWidget
(),
process_community
.
page_node
,
msg
=
"
Current widget : {0}
"
.
format
(
process_community
.
stacked_pages
.
currentWidget
().
objectName
()))
self
.
assertEqual
(
process_community
.
lineedit_server
.
text
(),
"
127.0.0.1
"
)
self
.
assertEqual
(
process_community
.
spinbox_port
.
value
(),
50000
)
QTest
.
mouseClick
(
process_community
.
button_connect
,
Qt
.
LeftButton
)
yield
from
asyncio
.
sleep
(
1
)
self
.
assertEqual
(
mock
.
get_request
(
0
).
method
,
'
GET
'
)
self
.
assertEqual
(
mock
.
get_request
(
0
).
url
,
'
/network/peering
'
)
self
.
assertEqual
(
mock
.
get_request
(
1
).
method
,
'
GET
'
)
self
.
assertEqual
(
mock
.
get_request
(
1
).
url
,
'
/wot/certifiers-of/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ
'
)
for
i
in
range
(
2
,
5
):
self
.
assertEqual
(
mock
.
get_request
(
i
).
method
,
'
GET
'
)
self
.
assertEqual
(
mock
.
get_request
(
i
).
url
,
'
/wot/lookup/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ
'
)
self
.
assertEqual
(
process_community
.
stacked_pages
.
currentWidget
(),
process_community
.
page_node
,
msg
=
"
Current widget : {0}
"
.
format
(
process_community
.
stacked_pages
.
currentWidget
().
objectName
()))
self
.
assertEqual
(
process_community
.
label_error
.
text
(),
"
Could not find your identity on the network.
"
)
process_community
.
close
()
self
.
lp
.
call_later
(
15
,
close_dialog
)
asyncio
.
async
(
exec_test
())
self
.
lp
.
run_until_complete
(
open_dialog
(
process_community
))
mock
.
delete_mock
()
def
test_connect_community_nice_blockchain
(
self
):
mock
=
nice_blockchain
.
get_mock
()
time
.
sleep
(
2
)
logging
.
debug
(
mock
.
pretend_url
)
self
.
network_manager
.
set_mock_path
(
mock
.
pretend_url
)
process_community
=
ProcessConfigureCommunity
(
self
.
application
,
self
.
account
,
None
,
self
.
password_asker
)
@asyncio.coroutine
def
open_dialog
(
process_community
):
result
=
yield
from
process_community
.
async_exec
()
self
.
assertEqual
(
result
,
QDialog
.
Accepted
)
def
close_dialog
():
if
process_community
.
isVisible
():
process_community
.
close
()
@asyncio.coroutine
def
exec_test
():
yield
from
asyncio
.
sleep
(
1
)
QTest
.
mouseClick
(
process_community
.
lineedit_server
,
Qt
.
LeftButton
)
QTest
.
keyClicks
(
process_community
.
lineedit_server
,
"
127.0.0.1
"
)
QTest
.
mouseDClick
(
process_community
.
spinbox_port
,
Qt
.
LeftButton
)
process_community
.
spinbox_port
.
setValue
(
50000
)
self
.
assertEqual
(
process_community
.
stacked_pages
.
currentWidget
(),
process_community
.
page_node
,
msg
=
"
Current widget : {0}
"
.
format
(
process_community
.
stacked_pages
.
currentWidget
().
objectName
()))
self
.
assertEqual
(
process_community
.
lineedit_server
.
text
(),
"
127.0.0.1
"
)
self
.
assertEqual
(
process_community
.
spinbox_port
.
value
(),
50000
)
QTest
.
mouseClick
(
process_community
.
button_connect
,
Qt
.
LeftButton
)
yield
from
asyncio
.
sleep
(
1
)
self
.
assertEqual
(
mock
.
get_request
(
0
).
method
,
'
GET
'
)
self
.
assertEqual
(
mock
.
get_request
(
0
).
url
,
'
/network/peering
'
)
self
.
assertEqual
(
mock
.
get_request
(
1
).
method
,
'
GET
'
)
self
.
assertEqual
(
mock
.
get_request
(
1
).
url
,
'
/wot/certifiers-of/7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ
'
)
self
.
assertEqual
(
process_community
.
stacked_pages
.
currentWidget
(),
process_community
.
page_add_nodes
,
msg
=
"
Current widget : {0}
"
.
format
(
process_community
.
stacked_pages
.
currentWidget
().
objectName
()))
QTest
.
mouseClick
(
process_community
.
button_next
,
Qt
.
LeftButton
)
self
.
lp
.
call_later
(
15
,
close_dialog
)
asyncio
.
async
(
exec_test
())
self
.
lp
.
run_until_complete
(
open_dialog
(
process_community
))
mock
.
delete_mock
()
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
logging
.
basicConfig
(
stream
=
sys
.
stderr
)
logging
.
basicConfig
(
stream
=
sys
.
stderr
)
logging
.
getLogger
().
setLevel
(
logging
.
DEBUG
)
logging
.
getLogger
().
setLevel
(
logging
.
DEBUG
)
...
...
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