{{ message }}
Enhance the client to support uploading an attachment to a ticket#735
Merged
Conversation
| if name is None: | ||
| name = os.path.basename(file) | ||
|
|
||
| bytes = None |
Member
There was a problem hiding this comment.
bytes is a type, so this is shadowing it. You'll want to change this to file_bytes or something similar.
Contributor
Author
There was a problem hiding this comment.
thanks for the comment, will fix
Contributor
Author
|
Any update on this? Thanks. |
Contributor
|
It looks like these comments haven't been addressed yet: #735 (comment) |
Contributor
Author
|
Code updated upon the comments. But for |
Member
|
LGTM, though it'd be nice to see the upload stuff have tests. Here's some that should work: diff --git a/SoftLayer/fixtures/SoftLayer_Ticket.py b/SoftLayer/fixtures/SoftLayer_Ticket.py
index c85deda..ea230f9 100644
--- a/SoftLayer/fixtures/SoftLayer_Ticket.py
+++ b/SoftLayer/fixtures/SoftLayer_Ticket.py
@@ -48,5 +48,17 @@ addAttachedVirtualGuest = {
"ticketId": 100
}
+addAttachedFile = {
+ "id": 123,
+ "fileName": "a_file_name",
+ "fileSize": "100",
+ "ticketId": 100,
+ "updateId": 200,
+ "createDate": "2013-08-01T14:14:04-07:00",
+ "modifyDate": "2013-08-01T14:14:04-07:00",
+ "uploaderType": "USER",
+ "uploaderId": "300"
+}
+
removeAttachedHardware = True
removeAttachedVirtualGuest = True
diff --git a/tests/CLI/modules/ticket_tests.py b/tests/CLI/modules/ticket_tests.py
index 69674c6..c43f46e 100644
--- a/tests/CLI/modules/ticket_tests.py
+++ b/tests/CLI/modules/ticket_tests.py
@@ -167,3 +167,40 @@ class TicketTests(testing.TestCase):
'removeAttachedVirtualGuest',
args=(100,),
identifier=1)
+
+ def test_ticket_upload_no_path(self):
+ result = self.run_command(['ticket', 'upload', '1'])
+
+ self.assertEqual(result.exit_code, 2)
+ self.assertIsInstance(result.exception, exceptions.ArgumentError)
+
+ def test_ticket_upload_invalid_path(self):
+ result = self.run_command(['ticket', 'upload', '1',
+ '--path=tests/resources/nonexistent_file',
+ '--name=a_file_name'])
+
+ self.assertEqual(result.exit_code, 2)
+ self.assertIsInstance(result.exception, exceptions.ArgumentError)
+
+ def test_ticket_upload_no_name(self):
+ result = self.run_command(['ticket', 'upload', '1',
+ '--path=tests/resources/ticket_upload'])
+
+ self.assert_no_fail(result)
+ self.assert_called_with('SoftLayer_Ticket',
+ 'addAttachedFile',
+ args=({"filename": "ticket_upload",
+ "data": b"ticket upload data"},),
+ identifier=1)
+
+ def test_ticket_upload(self):
+ result = self.run_command(['ticket', 'upload', '1',
+ '--path=tests/resources/ticket_upload',
+ '--name=a_file_name'])
+
+ self.assert_no_fail(result)
+ self.assert_called_with('SoftLayer_Ticket',
+ 'addAttachedFile',
+ args=({"filename": "a_file_name",
+ "data": b"ticket upload data"},),
+ identifier=1)
diff --git a/tests/resources/ticket_upload b/tests/resources/ticket_upload
new file mode 100644
index 0000000..d2e3a7c
--- /dev/null
+++ b/tests/resources/ticket_upload
@@ -0,0 +1 @@
+ticket upload data
\ No newline at end of fileSomeone might have a differing opinion about where to put the test upload file though. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Please review, comment and merge