Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
mantidproject
mantid
Commits
9aca0f56
Commit
9aca0f56
authored
5 years ago
by
Matthew Andrew
Browse files
Options
Downloads
Patches
Plain Diff
Corrected failing unit tests
parent
ac1711bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/Kernel/test/ErrorReporterTest.h
+6
-6
6 additions, 6 deletions
Framework/Kernel/test/ErrorReporterTest.h
scripts/test/ErrorReportPresenterTest.py
+3
-19
3 additions, 19 deletions
scripts/test/ErrorReportPresenterTest.py
with
9 additions
and
25 deletions
Framework/Kernel/test/ErrorReporterTest.h
+
6
−
6
View file @
9aca0f56
...
...
@@ -100,7 +100,7 @@ public:
const
std
::
string
name
=
"My testing application name"
;
const
Mantid
::
Types
::
Core
::
time_duration
upTime
(
5
,
0
,
7
,
0
);
TestableErrorReporter
errorService
(
name
,
upTime
,
"0"
,
true
,
"name"
,
"email"
,
"textBox"
,
"
fileHash
"
);
"textBox"
,
"
stacktrace
"
);
const
std
::
string
message
=
errorService
.
generateErrorMessage
();
::
Json
::
Reader
reader
;
...
...
@@ -111,7 +111,7 @@ public:
"ParaView"
,
"application"
,
"host"
,
"mantidSha1"
,
"mantidVersion"
,
"osArch"
,
"osName"
,
"osReadable"
,
"osVersion"
,
"uid"
,
"facility"
,
"upTime"
,
"exitCode"
,
"textBox"
,
"name"
,
"email"
,
"
fileHash
"
};
"email"
,
"
stacktrace
"
};
for
(
auto
expectedMember
:
expectedMembers
)
{
TSM_ASSERT
(
expectedMember
+
" not found"
,
std
::
find
(
members
.
begin
(),
members
.
end
(),
expectedMember
)
!=
...
...
@@ -124,14 +124,14 @@ public:
TS_ASSERT_EQUALS
(
root
[
"name"
].
asString
(),
"name"
);
TS_ASSERT_EQUALS
(
root
[
"email"
].
asString
(),
"email"
);
TS_ASSERT_EQUALS
(
root
[
"textBox"
].
asString
(),
"textBox"
);
TS_ASSERT_EQUALS
(
root
[
"
fileHash
"
].
asString
(),
"
fileHash
"
);
TS_ASSERT_EQUALS
(
root
[
"
stacktrace
"
].
asString
(),
"
stacktrace
"
);
}
void
test_errorMessageWithNoShareAndRecoveryFileHash
()
{
const
std
::
string
name
=
"My testing application name"
;
const
Mantid
::
Types
::
Core
::
time_duration
upTime
(
5
,
0
,
7
,
0
);
TestableErrorReporter
errorService
(
name
,
upTime
,
"0"
,
false
,
"name"
,
"email"
,
"textBox"
,
"
fileHash
"
);
"email"
,
"textBox"
,
"
stacktrace
"
);
const
std
::
string
message
=
errorService
.
generateErrorMessage
();
::
Json
::
Reader
reader
;
...
...
@@ -142,7 +142,7 @@ public:
"ParaView"
,
"application"
,
"host"
,
"mantidSha1"
,
"mantidVersion"
,
"osArch"
,
"osName"
,
"osReadable"
,
"osVersion"
,
"uid"
,
"facility"
,
"upTime"
,
"exitCode"
,
"textBox"
,
"name"
,
"email"
,
"
fileHash
"
};
"email"
,
"
stacktrace
"
};
for
(
auto
expectedMember
:
expectedMembers
)
{
TSM_ASSERT
(
expectedMember
+
" not found"
,
std
::
find
(
members
.
begin
(),
members
.
end
(),
expectedMember
)
!=
...
...
@@ -155,7 +155,7 @@ public:
TS_ASSERT_EQUALS
(
root
[
"name"
].
asString
(),
""
);
TS_ASSERT_EQUALS
(
root
[
"email"
].
asString
(),
""
);
TS_ASSERT_EQUALS
(
root
[
"textBox"
].
asString
(),
""
);
TS_ASSERT_EQUALS
(
root
[
"
fileHash
"
].
asString
(),
""
);
TS_ASSERT_EQUALS
(
root
[
"
stacktrace
"
].
asString
(),
""
);
}
};
...
...
This diff is collapsed.
Click to expand it.
scripts/test/ErrorReportPresenterTest.py
+
3
−
19
View file @
9aca0f56
...
...
@@ -24,11 +24,6 @@ class ErrorReportPresenterTest(unittest.TestCase):
self
.
errorreport_mock
=
errorreport_patcher
.
start
()
self
.
errorreport_mock
.
return_value
=
self
.
errorreport_mock_instance
zip_recovery_patcher
=
mock
.
patch
(
'
ErrorReporter.error_report_presenter.zip_recovery_directory
'
)
self
.
addCleanup
(
zip_recovery_patcher
.
stop
)
self
.
zip_recovery_mock
=
zip_recovery_patcher
.
start
()
self
.
zip_recovery_mock
.
return_value
=
(
'
zipped_file
'
,
'
file_hash
'
)
self
.
view
=
mock
.
MagicMock
()
self
.
exit_code
=
255
self
.
error_report_presenter
=
ErrorReporterPresenter
(
self
.
view
,
self
.
exit_code
)
...
...
@@ -55,32 +50,28 @@ class ErrorReportPresenterTest(unittest.TestCase):
def
test_send_error_report_to_server_calls_ErrorReport_correctly
(
self
):
name
=
'
John Smith
'
email
=
'
john.smith@email.com
'
file_hash
=
'
91df56ab7a2de7264052a7a7125dcfa18b4f59de
'
text_box
=
'
details of error
'
uptime
=
'
time_string
'
self
.
errorreport_mock_instance
.
sendErrorReport
.
return_value
=
201
self
.
error_report_presenter
.
_send_report_to_server
(
False
,
name
=
name
,
email
=
email
,
file_hash
=
file_hash
,
uptime
=
uptime
,
text_box
=
text_box
)
self
.
errorreport_mock
.
assert_called_once_with
(
'
mantidplot
'
,
uptime
,
self
.
exit_code
,
False
,
name
,
email
,
text_box
,
file_hash
)
email
,
text_box
,
''
)
self
.
errorreport_mock_instance
.
sendErrorReport
.
assert_called_once_with
()
def
test_send_error_report_to_server_calls_ErrorReport_correctly_and_triggers_view_upon_failure
(
self
):
name
=
'
John Smith
'
email
=
'
john.smith@email.com
'
file_hash
=
'
91df56ab7a2de7264052a7a7125dcfa18b4f59de
'
uptime
=
'
time_string
'
text_box
=
'
details of error
'
self
.
errorreport_mock_instance
.
sendErrorReport
.
return_value
=
500
self
.
error_report_presenter
.
_send_report_to_server
(
True
,
name
=
name
,
email
=
email
,
file_hash
=
file_hash
,
uptime
=
uptime
,
text_box
=
text_box
)
self
.
errorreport_mock
.
assert_called_once_with
(
'
mantidplot
'
,
uptime
,
self
.
exit_code
,
True
,
name
,
email
,
text_box
,
file_hash
)
email
,
text_box
,
''
)
self
.
errorreport_mock_instance
.
sendErrorReport
.
assert_called_once_with
()
self
.
view
.
display_message_box
.
assert_called_once_with
(
'
Error contacting server
'
,
ErrorReporterPresenter
.
SENDING_ERROR_MESSAGE
,
...
...
@@ -93,16 +84,13 @@ class ErrorReportPresenterTest(unittest.TestCase):
continue_working
=
False
share
=
0
self
.
error_report_presenter
.
_send_report_to_server
=
mock
.
MagicMock
(
return_value
=
201
)
self
.
error_report_presenter
.
_upload_recovery_file
=
mock
.
MagicMock
()
self
.
error_report_presenter
.
_handle_exit
=
mock
.
MagicMock
()
self
.
error_report_presenter
.
error_handler
(
continue_working
,
share
,
name
,
email
,
text_box
)
self
.
error_report_presenter
.
_send_report_to_server
.
called_once_with
(
share_identifiable
=
True
,
name
=
name
,
email
=
email
,
file_hash
=
mock
.
ANY
,
uptime
=
mock
.
ANY
,
email
=
email
,
uptime
=
mock
.
ANY
,
text_box
=
text_box
)
self
.
assertEqual
(
self
.
error_report_presenter
.
_upload_recovery_file
.
call_count
,
1
)
self
.
error_report_presenter
.
_handle_exit
.
assert_called_once_with
(
False
)
def
test_error_handler_share_non_id_sunny_day_case
(
self
):
...
...
@@ -112,13 +100,11 @@ class ErrorReportPresenterTest(unittest.TestCase):
continue_working
=
True
share
=
1
self
.
error_report_presenter
.
_send_report_to_server
=
mock
.
MagicMock
()
self
.
error_report_presenter
.
_upload_recovery_file
=
mock
.
MagicMock
()
self
.
error_report_presenter
.
_handle_exit
=
mock
.
MagicMock
()
self
.
error_report_presenter
.
error_handler
(
continue_working
,
share
,
name
,
email
,
text_box
)
self
.
error_report_presenter
.
_send_report_to_server
.
called_once_with
(
share_identifiable
=
False
,
uptime
=
mock
.
ANY
)
self
.
assertEqual
(
self
.
error_report_presenter
.
_upload_recovery_file
.
call_count
,
0
)
self
.
error_report_presenter
.
_handle_exit
.
assert_called_once_with
(
True
)
def
test_error_handler_share_nothing_sunny_day_case
(
self
):
...
...
@@ -128,13 +114,11 @@ class ErrorReportPresenterTest(unittest.TestCase):
continue_working
=
True
share
=
2
self
.
error_report_presenter
.
_send_report_to_server
=
mock
.
MagicMock
()
self
.
error_report_presenter
.
_upload_recovery_file
=
mock
.
MagicMock
()
self
.
error_report_presenter
.
_handle_exit
=
mock
.
MagicMock
()
self
.
error_report_presenter
.
error_handler
(
continue_working
,
share
,
name
,
email
,
text_box
)
self
.
assertEqual
(
self
.
error_report_presenter
.
_send_report_to_server
.
call_count
,
0
)
self
.
assertEqual
(
self
.
error_report_presenter
.
_upload_recovery_file
.
call_count
,
0
)
self
.
error_report_presenter
.
_handle_exit
.
assert_called_once_with
(
True
)
...
...
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