Skip to content

Commit 0f1d610

Browse files
committed
test image selection
1 parent 6f00b0a commit 0f1d610

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

tests/onegov/org/test_views_photoalbum.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from __future__ import annotations
22

3+
import os
34
import re
45

6+
from onegov.org.models import ImageFileCollection
7+
58
from tests.shared.utils import create_image
69
from webtest import Upload
710

8-
911
from typing import TYPE_CHECKING
12+
1013
if TYPE_CHECKING:
1114
from .conftest import Client
1215

@@ -54,3 +57,44 @@ def test_manage_album(client: Client) -> None:
5457

5558
album = albums.click("Comicon 2016")
5659
assert "This is an alt text" in album
60+
61+
62+
def test_image_selection(client: Client) -> None:
63+
client.login_admin()
64+
65+
number_of_images = 3
66+
67+
albums = client.get('/photoalbums')
68+
new = albums.click('Fotoalbum')
69+
new.form['title'] = "Vacation Destinations 2026"
70+
new.form.submit()
71+
72+
album = client.get('/photoalbums').click("Vacation Destinations 2026")
73+
for i in range(number_of_images):
74+
images = albums.click("Bilder verwalten")
75+
images.form['file'] = [Upload(f'image_{i}.jpg', create_image().read())]
76+
images.form.submit()
77+
78+
# select all images
79+
select = album.click("Bilder auswählen")
80+
select.form[tuple(select.form.fields.keys())[1]] = True
81+
select.form[tuple(select.form.fields.keys())[2]] = True
82+
select.form[tuple(select.form.fields.keys())[3]] = True
83+
select.form.submit()
84+
85+
images = ImageFileCollection(client.app.session()).query().all()
86+
assert len(images) == number_of_images
87+
images = {(i.id, i.name) for i in images}
88+
print(images)
89+
album = client.get('/photoalbums').click("Vacation Destinations 2026")
90+
for i in images:
91+
assert i[0] in album, '{} not found in album'.format(i)
92+
93+
# switch to grid mode
94+
settings = album.click("Bearbeiten")
95+
settings.form['view'] = 'grid'
96+
settings.form.submit()
97+
98+
album = client.get('/photoalbums').click("Vacation Destinations 2026")
99+
for i in images:
100+
assert i[0] in album, '{} not found in album'.format(i)

0 commit comments

Comments
 (0)