-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathtest_relation.py
More file actions
104 lines (90 loc) · 3.23 KB
/
test_relation.py
File metadata and controls
104 lines (90 loc) · 3.23 KB
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
from flask import url_for
from openatlas import app
from tests.base import TestBaseCase, get_hierarchy, insert
class RelationTests(TestBaseCase):
def test_relation(self) -> None:
c = self.client
with app.test_request_context():
app.preprocess_request()
actor = insert('person', 'Connor MacLeod')
related = insert('person', 'The Kurgan')
rv = c.get(
url_for('link_insert_detail', origin_id=actor.id, name='relative'))
assert b'Actor relation' in rv.data
relation = get_hierarchy('Actor relation')
sub_id = relation.subs[0]
data = {
'actor': actor.id,
'relative': related.id,
relation.id: sub_id,
'inverse': None,
'begin_year_from': '-1949',
'begin_month_from': '10',
'begin_day_from': '8',
'begin_year_to': '-1948',
'end_year_from': '2049',
'end_year_to': '2050'}
rv = c.post(
url_for('link_insert_detail', origin_id=actor.id, name='relative'),
data=data,
follow_redirects=True)
assert b'The Kurgan' in rv.data
data['relative'] = actor.id
data['actor'] = related.id
rv = c.post(
url_for(
'link_insert_detail',
origin_id=related.id,
name='relative'),
data=data,
follow_redirects=True)
assert b'Connor' in rv.data
rv = c.get(url_for('view', id_=sub_id))
assert b'Connor' in rv.data
rv = c.get(url_for('change_type', id_=sub_id))
assert b'The Kurgan' in rv.data
with app.test_request_context():
app.preprocess_request()
link_ = actor.get_links('OA7')[0]
rv = c.post(
url_for('change_type', id_=sub_id),
data={
relation.id: relation.subs[1],
'selection': [link_.id],
'checkbox_values': str([link_.id])},
follow_redirects=True)
assert b'Entities were updated' in rv.data
rv = c.post(
url_for('change_type', id_=relation.subs[1]),
data={
relation.id: '',
'selection': [link_.id],
'checkbox_values': str([link_.id])},
follow_redirects=True)
assert b'Entities were updated' in rv.data
rv = c.get(
url_for(
'link_update',
id_=link_.id,
origin_id=related.id,
name='relative'))
assert b'Connor' in rv.data
rv = c.post(
url_for(
'link_update',
id_=link_.id,
origin_id=actor.id,
name='relative'),
data={'description': 'There can be only one', 'inverse': True},
follow_redirects=True)
assert b'only one' in rv.data
data['relative'] = actor.id
data['actor'] = actor.id
rv = c.post(
url_for(
'link_insert_detail',
origin_id=actor.id,
name='relative'),
data=data,
follow_redirects=True)
assert b'link to itself' in rv.data