Merge lp:~ricardokirkner/click-toolbelt/fix-storeapi-upload-missing-config into lp:click-toolbelt

Proposed by Ricardo Kirkner on 2016-01-08
Status: Merged
Approved by: Ricardo Kirkner on 2016-01-08
Approved revision: 54
Merged at revision: 54
Proposed branch: lp:~ricardokirkner/click-toolbelt/fix-storeapi-upload-missing-config
Merge into: lp:click-toolbelt
Diff against target: 145 lines (+20/-18)
2 files modified
click_toolbelt/tests/test_upload.py (+13/-11)
storeapi/_upload.py (+7/-7)
To merge this branch: bzr merge lp:~ricardokirkner/click-toolbelt/fix-storeapi-upload-missing-config
Reviewer Review Type Date Requested Status
Fabián Ezequiel Gallina (community) 2016-01-08 Approve on 2016-01-08
Review via email: mp+282049@code.launchpad.net

Commit message

fix storeapi upload functions invalid calls to get_oauth_session without config

To post a comment you must log in.
Fabián Ezequiel Gallina (fgallina) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'click_toolbelt/tests/test_upload.py'
2--- click_toolbelt/tests/test_upload.py 2016-01-08 14:20:13 +0000
3+++ click_toolbelt/tests/test_upload.py 2016-01-08 19:30:10 +0000
4@@ -62,10 +62,11 @@
5
6 self.command.take_action(self.args)
7
8- self.mock_upload_files.assert_called_once_with(binary_filename)
9+ self.mock_upload_files.assert_called_once_with(
10+ binary_filename, config=None)
11 self.mock_upload_app.assert_called_once_with(
12 self.package_name, self.mock_upload_files.return_value,
13- metadata={})
14+ metadata={}, config=None)
15 self.mock_logger.info.assert_any_call(
16 'Application uploaded successfully.'
17 )
18@@ -76,10 +77,11 @@
19
20 self.command.take_action(args)
21
22- self.mock_upload_files.assert_called_once_with(binary_filename)
23+ self.mock_upload_files.assert_called_once_with(
24+ binary_filename, config=None)
25 self.mock_upload_app.assert_called_once_with(
26 self.package_name, self.mock_upload_files.return_value,
27- metadata={})
28+ metadata={}, config=None)
29 self.mock_logger.info.assert_any_call(
30 'Application uploaded successfully.'
31 )
32@@ -96,10 +98,10 @@
33 self.command.take_action(args)
34
35 self.mock_upload_files.assert_called_once_with(
36- self.binary_filename)
37+ self.binary_filename, config=None)
38 self.mock_upload_app.assert_called_once_with(
39 self.package_name, self.mock_upload_files.return_value,
40- metadata={'changelog': 'some changes'})
41+ metadata={'changelog': 'some changes'}, config=None)
42 self.mock_logger.info.assert_any_call(
43 'Application uploaded successfully.'
44 )
45@@ -116,10 +118,10 @@
46 self.command.take_action(args)
47
48 self.mock_upload_files.assert_called_once_with(
49- self.binary_filename)
50+ self.binary_filename, config=None)
51 self.mock_upload_app.assert_called_once_with(
52 self.package_name, self.mock_upload_files.return_value,
53- metadata={'changelog': 'some changes'})
54+ metadata={'changelog': 'some changes'}, config=None)
55 self.mock_logger.info.assert_any_call(
56 'Application uploaded successfully.'
57 )
58@@ -136,7 +138,7 @@
59 self.command.take_action(self.args)
60
61 self.mock_upload_files.assert_called_once_with(
62- binary_filename)
63+ binary_filename, config=None)
64 self.assertFalse(self.mock_upload_app.called)
65 self.mock_logger.info.assert_any_call(
66 'Upload failed:\n\n%s\n', 'some error')
67@@ -153,10 +155,10 @@
68 self.command.take_action(self.args)
69
70 self.mock_upload_files.assert_called_once_with(
71- binary_filename)
72+ binary_filename, config=None)
73 self.mock_upload_app.assert_called_once_with(
74 self.package_name, self.mock_upload_files.return_value,
75- metadata={})
76+ metadata={}, config=None)
77 self.mock_logger.info.assert_any_call(
78 'Upload did not complete.')
79 self.mock_logger.info.assert_any_call(
80
81=== modified file 'storeapi/_upload.py'
82--- storeapi/_upload.py 2016-01-08 14:20:09 +0000
83+++ storeapi/_upload.py 2016-01-08 19:30:10 +0000
84@@ -23,7 +23,7 @@
85 logger = logging.getLogger(__name__)
86
87
88-def upload(binary_filename, metadata_filename='', metadata=None):
89+def upload(binary_filename, metadata_filename='', metadata=None, config=None):
90 """Create a new upload based on a click/snap package."""
91
92 # validate package filename
93@@ -36,7 +36,7 @@
94 name = match.groupdict()['name']
95
96 logger.info('Uploading files...')
97- data = upload_files(binary_filename)
98+ data = upload_files(binary_filename, config=config)
99 success = data.get('success', False)
100 errors = data.get('errors', [])
101 if not success:
102@@ -46,7 +46,7 @@
103 logger.info('Uploading new version...')
104 meta = read_metadata(metadata_filename)
105 meta.update(metadata or {})
106- result = upload_app(name, data, metadata=meta)
107+ result = upload_app(name, data, metadata=meta, config=config)
108 success = result.get('success', False)
109 errors = result.get('errors', [])
110 app_url = result.get('application_url', '')
111@@ -70,7 +70,7 @@
112 return success
113
114
115-def upload_files(binary_filename):
116+def upload_files(binary_filename, config=None):
117 """Upload a binary file to the Store.
118
119 Submit a file to the click-updown service and return the
120@@ -83,7 +83,7 @@
121
122 result = {'success': False, 'errors': []}
123
124- session = get_oauth_session()
125+ session = get_oauth_session(config)
126 if session is None:
127 result['errors'] = ['No valid credentials found.']
128 return result
129@@ -131,14 +131,14 @@
130 return metadata
131
132
133-def upload_app(name, upload_data, metadata=None):
134+def upload_app(name, upload_data, metadata=None, config=None):
135 """Request a new upload to be created for a given upload_id."""
136 upload_url = get_upload_url(name)
137
138 result = {'success': False, 'errors': [],
139 'application_url': '', 'revision': None}
140
141- session = get_oauth_session()
142+ session = get_oauth_session(config)
143 if session is None:
144 result['errors'] = ['No valid credentials found.']
145 return result

Subscribers

People subscribed via source and target branches