-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtest_event.py
176 lines (137 loc) · 6.11 KB
/
test_event.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
from flask import g, url_for
from openatlas import app
from tests.base import TestBaseCase, insert
class EventTest(TestBaseCase):
def test_event(self) -> None:
c = self.client
with app.test_request_context():
app.preprocess_request()
actor = insert('person', 'Captain Miller')
file = insert('file', 'X-Files')
artifact = insert('artifact', 'artifact')
residence = insert('place', 'Lewis and Clark')
reference = insert('external_reference', 'https://d-nb.info')
data = {'name': 'Event Horizon', 'location': residence.id}
rv = c.post(url_for('insert', class_='activity'), data=data)
activity_id = rv.location.split('/')[-1]
rv = c.post(
url_for('insert', class_='activity', origin_id=actor.id),
data=data,
follow_redirects=True)
assert b'An entry has been created' in rv.data
rv = c.post(
url_for('insert', class_='activity', origin_id=file.id),
data=data,
follow_redirects=True)
assert b'An entry has been created' in rv.data
rv = c.get(
url_for('insert', class_='activity', origin_id=residence.id))
assert b'location' in rv.data
rv = c.get(url_for('insert', class_='move', origin_id=residence.id))
assert b'Moved artifact' in rv.data
data = {
'name': 'Second event',
'given_place': [residence.id],
'given_artifact': '',
'location': residence.id,
'sub_event_of': activity_id,
'begin_year_from': '1949',
'begin_month_from': '10',
'begin_day_from': '8',
'end_year_from': '1951',
'preceding_event': '',
f'reference_system_id_{g.wikidata.id}':
['Q123', self.precision_type.subs[0]]}
rv = c.post(url_for('insert', class_='acquisition'), data=data)
event_id = rv.location.split('/')[-1]
data['end_year_from'] = '7'
rv = c.post(url_for('insert', class_='acquisition'), data=data)
assert b'Begin dates cannot start after end dates' in rv.data
rv = c.post(
url_for('insert', class_='move'),
data={
'name': 'Keep it moving',
'place_to': residence.id,
'place_from': residence.id,
'moved_artifact': artifact.id,
'moved_person': actor.id})
move_id = rv.location.split('/')[-1]
rv = c.get(url_for('view', id_=move_id))
assert b'Keep it moving' in rv.data
rv = c.get(url_for('view', id_=artifact.id))
assert b'Keep it moving' in rv.data
rv = c.get(url_for('update', id_=move_id))
assert b'Keep it moving' in rv.data
rv = c.get(url_for('insert', class_='creation', origin_id=file.id))
assert b'+ Creation' in rv.data
rv = c.post(
url_for('insert', class_='creation'),
data={'name': 'A creation event', 'file': file.id})
creation_id = rv.location.split('/')[-1]
rv = c.get(url_for('view', id_=creation_id, origin_id=file.id))
assert b'File' in rv.data
rv = c.get(url_for('update', id_=creation_id))
assert b'A creation event' in rv.data
rv = c.post(
url_for('insert', class_='modification'),
data={
'name': 'A modification event',
'artifact': artifact.id,
'modified_place': residence.id})
modification_id = rv.location.split('/')[-1]
rv = c.get(url_for('view', id_=modification_id))
assert b'A modification event' in rv.data
rv = c.get(url_for('update', id_=modification_id))
assert b'A modification event' in rv.data
rv = c.post(
url_for('insert', class_='production'),
data={'name': 'A productive event', 'artifact': artifact.id})
production_id = rv.location.split('/')[-1]
rv = c.get(url_for('view', id_=production_id))
assert b'artifact' in rv.data
rv = c.get(url_for('view', id_=artifact.id))
assert b'A productive event' in rv.data
rv = c.get(url_for('update', id_=production_id))
assert b'A productive event' in rv.data
rv = c.post(
url_for('insert', class_='acquisition'),
data={'name': 'Third event', 'given_place': [residence.id]},
follow_redirects=True)
assert b'An entry has been created' in rv.data
rv = c.get(url_for('view', id_=residence.id))
assert bytes('Lewis and Clark', 'utf-8') in rv.data
rv = c.get(url_for('view', id_=actor.id))
assert bytes('Captain Miller', 'utf-8') in rv.data
rv = c.post(
url_for('insert', class_='acquisition'),
data={'name': 'Event Horizon', 'continue_': 'yes'},
follow_redirects=True)
assert b'An entry has been created' in rv.data
rv = c.get(url_for('view', id_=activity_id))
assert b'1949' in rv.data
rv = c.get(url_for('entity_add_file', id_=event_id))
assert b'link file' in rv.data
rv = c.post(
url_for('entity_add_file', id_=event_id),
data={'checkbox_values': str([file.id])},
follow_redirects=True)
assert b'X-Files' in rv.data
rv = c.post(
url_for('entity_add_reference', id_=event_id),
data={'reference': reference.id, 'page': '777'},
follow_redirects=True)
assert b'777' in rv.data
rv = c.get(url_for('update', id_=activity_id))
assert b'Event Horizon' in rv.data
rv = c.get(url_for('update', id_=event_id))
assert b'Event Horizon' in rv.data
rv = c.post(
url_for('update', id_=event_id),
data={
'name': 'Event with preceding',
'preceding_event': activity_id,
'event_id': event_id},
follow_redirects=True)
assert b'Event with preceding' in rv.data
rv = c.get(url_for('update', id_=event_id))
assert b'Event with preceding' in rv.data