Skip to content

Directory: Fixes UploadMultipleField not working in request changes #1803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cyrillkuettel
Copy link
Contributor

@cyrillkuettel cyrillkuettel commented May 1, 2025

Commit message

TYPE: Bugfix
LINK: OGC-2234

Checklist

  • I considered adding a reviewer
  • I have tested my code thoroughly by hand
  • I have added tests for my changes/features

Copy link

linear bot commented May 1, 2025

Copy link

codecov bot commented May 1, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2541 1 2540 23
View the top 1 failed test(s) by shortest run time
tests/onegov/town6/test_views_directory.py::test_directory_change_request_with_multiple_uploads
Stack Traces | 4.01s run time
client = <tests.onegov.town6.conftest.Client object at 0x7f7db1cea210>

    def test_directory_change_request_with_multiple_uploads(client):
        client.login_admin()
    
        # Create a directory with multiple file upload field
        page = client.get('/directories').click('Verzeichnis')
        page.form['title'] = "Contacts"
        page.form['structure'] = """
            E-Mail *= @@@
            Telefon *= ___
            Downloads = *.pdf (multiple)
        """
        page.form['title_format'] = '[E-Mail]'
        page.form['enable_change_requests'] = True
        page.form['content_fields'] = 'E-Mail\nTelefon\nDownloads'
        page = page.form.submit().follow()
    
        # Create an initial entry
        page = page.click('Eintrag', index=0)
        page.form['e_mail'] = '[email protected]'
        page.form['telefon'] = '123456'
        path = module_path('tests.onegov.town6', 'fixtures/sample.pdf')
        with open(path, 'rb') as f:
            page.form['downloads'] = [
                Upload('Sample.pdf', f.read(), 'application/pdf')
            ]
    
        entry_page = page.form.submit().follow()
        entry_url = entry_page.request.url
    
        # Spawn anonymous user to suggest a change
        anon_client = client.spawn()
        page = anon_client.get(entry_url)
        change_page = page.click('Änderung für diesen Eintrag vorschlagen')
    
        # Fill change request form
        change_page.form['submitter'] = '[email protected]'
        # Submit to preview - this triggers render_original for diff
        try:
            preview_page = change_page.form.submit().follow()
        except AttributeError as e:
            # property 'data' of 'UploadMultipleField' object has no setter
            fail('Got AttributeError!')
    
>       assert 'Vorschau' in preview_page
E       AssertionError: assert 'Vorschau' in <200 OK text/html body=b'<!DOCTYP...\n\n'/35639>

.../onegov/town6/test_views_directory.py:264: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant