-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtest_relation.py
79 lines (66 loc) · 2.53 KB
/
test_relation.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
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(
'insert_relation',
origin_id=actor.id,
type_='actor_relation'))
assert b'Actor relation' in rv.data
relation = get_hierarchy('Actor relation')
sub_id = relation.subs[0]
data = {
'actor': str([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(
'insert_relation',
origin_id=actor.id,
type_='actor_relation'),
data=data,
follow_redirects=True)
assert b'The Kurgan' in rv.data
rv = c.get(url_for('view', id_=sub_id))
assert b'Connor' in rv.data
rv = c.get(url_for('type_move_entities', 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('type_move_entities', 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('type_move_entities', 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))
assert b'Connor' in rv.data
rv = c.post(
url_for('link_update', id_=link_.id, origin_id=actor.id),
data={'description': 'There can be only one', 'inverse': True},
follow_redirects=True)
assert b'only one' in rv.data