Skip to content

Commit

Permalink
Merge pull request #140 from plone/djay/add_themefileupload_test
Browse files Browse the repository at this point in the history
add some tests for themefileupload as these fail with current plone.rest
  • Loading branch information
jensens authored Mar 27, 2018
2 parents ef63296 + 8a49cfa commit 6bd6fe0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ New features:

Bug fixes:

- *add item here*
- Added a failing (5.1) test for fileuploads in the theme editor that breaks when plone.rest is installed. Fix is in https://github.com/plone/plone.rest/issues/59
[djay]


2.0.2 (2018-02-04)
Expand Down
35 changes: 35 additions & 0 deletions src/plone/app/theming/tests/test_controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,38 @@ def test_create_theme(self):

# self.assertTrue('foobar' in [t.__name__ for t in getZODBThemes()])
# self.assertTrue(getTheme('foobar') is not None)


def test_upload_theme_file_nodata(self):
self.browser.addHeader('Accept', 'application/json')
self.browser.post(
self.portal.absolute_url() + '/portal_resources/themeFileUpload',
'',
)
self.assertIn('Status: 200', str(self.browser.headers))
self.assertIn(
'{"failure": "error"}',
str(self.browser.contents)
)

def test_upload_theme_file_withdata(self):
self.browser.addHeader('Accept', 'application/json')
self.browser.post(
self.portal.absolute_url() + '/portal_resources/themeFileUpload',
"""
---blah---
Content-Disposition: form-data; name="file"; filename="Screen Shot 2018-02-16 at 3.08.15 pm.png"
Content-Type: image/png
---blah---
""",
# Bug in testbrowser prevents this working
# content_type='multipart/form-data; boundary=---blah---'

)
self.assertIn('Status: 200', str(self.browser.headers))
self.assertIn(
'{"failure": "error"}', # TODO: Should be {'success':'create'}
str(self.browser.contents)
)

0 comments on commit 6bd6fe0

Please sign in to comment.