Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
bbb0aec6
Commit
bbb0aec6
authored
Jul 17, 2015
by
carlosperate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Force normalised file/dir addressed in the server file/dir browser.
parent
529e9151
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
ardublocklyserver/gui.py
ardublocklyserver/gui.py
+10
-3
ardublocklyserver/tests/gui_test.py
ardublocklyserver/tests/gui_test.py
+7
-7
No files found.
ardublocklyserver/gui.py
View file @
bbb0aec6
...
...
@@ -7,6 +7,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
from
__future__
import
unicode_literals
,
absolute_import
import
os
try
:
# 2.x name
import
Tkinter
...
...
@@ -37,6 +38,9 @@ def browse_file_dialog():
root
.
update
()
file_path
=
tkFileDialog
.
askopenfilename
()
root
.
destroy
()
if
file_path
:
return
os
.
path
.
normpath
(
file_path
)
else
:
return
file_path
...
...
@@ -54,7 +58,10 @@ def browse_dir_dialog():
root
.
deiconify
()
root
.
lift
()
root
.
focus_force
()
file
_path
=
tkFileDialog
.
askdirectory
(
dir
_path
=
tkFileDialog
.
askdirectory
(
parent
=
root
,
initialdir
=
"/"
,
title
=
'Please select a directory'
)
root
.
destroy
()
return
file_path
if
dir_path
:
return
os
.
path
.
normpath
(
dir_path
)
else
:
return
dir_path
ardublocklyserver/tests/gui_test.py
View file @
bbb0aec6
...
...
@@ -29,10 +29,10 @@ class GuiTestCase(unittest.TestCase):
#
# Tests for checking browsing for paths and files
#
@
mock
.
patch
(
'ardublocklyserver.gui.tkFileDialog'
)
@
mock
.
patch
(
'ardublocklyserver.gui.tkFileDialog
.askopenfilename
'
)
def
test_browse_file
(
self
,
mock_file_select
):
test_file
=
'test_file'
mock_file_select
.
askopenfilename
.
return_value
=
test_file
test_file
=
os
.
path
.
join
(
os
.
getcwd
(),
'test_file'
)
mock_file_select
.
return_value
=
test_file
new_file
=
gui
.
browse_file_dialog
()
self
.
assertEqual
(
new_file
,
test_file
)
...
...
@@ -44,11 +44,11 @@ class GuiTestCase(unittest.TestCase):
function_file
=
gui
.
browse_file_dialog
()
self
.
assertEqual
(
canceled_file
,
function_file
)
@
mock
.
patch
(
'ardublocklyserver.gui.tkFileDialog'
)
@
mock
.
patch
(
'ardublocklyserver.gui.tkFileDialog
.askdirectory
'
)
def
test_browse_path
(
self
,
mock_path_select
):
test_path
=
'test_path'
mock_path_select
.
askopenfilename
.
return_value
=
test_path
new_path
=
gui
.
browse_
file
_dialog
()
test_path
=
os
.
path
.
join
(
os
.
getcwd
(),
'test_path'
)
mock_path_select
.
return_value
=
test_path
new_path
=
gui
.
browse_
dir
_dialog
()
self
.
assertEqual
(
new_path
,
test_path
)
def
test_browse_path_cancel
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment