-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathtest_source.py
106 lines (87 loc) · 3.68 KB
/
test_source.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
from flask import url_for
from openatlas import app
from tests.base import TestBaseCase, insert
class SourceTest(TestBaseCase):
def test_source(self) -> None:
c = self.client
with app.test_request_context():
app.preprocess_request()
gillian = insert('person', 'Gillian Anderson Gillian Anderson')
artifact = insert('artifact', 'Artifact with inscription')
reference = insert('external_reference', 'https://d-nb.info')
rv = c.post(
url_for('insert', class_='source'),
data={
'name': 'Necronomicon',
'description': (
'The <mark meta="{"annotationId":"c27",'
f'"entityId":{artifact.id},'
'"comment":"asdf"}">Necronomicon</mark>,'
' also referred to as the Book of the Dead')})
source_id = rv.location.split('/')[-1]
rv = c.get(url_for('insert', class_='source', origin_id=artifact.id))
assert b'Artifact with inscription' in rv.data
rv = c.get(url_for('link_insert', id_=source_id, view='actor'))
assert b'Gillian' in rv.data
rv = c.post(
url_for('link_insert', id_=source_id, view='actor'),
data={'checkbox_values': [gillian.id]},
follow_redirects=True)
assert b'Gillian' in rv.data
rv = c.get(url_for('update', id_=source_id))
assert b'Necronomicon' in rv.data
rv = c.post(
url_for('update', id_=source_id),
data={
'name': 'Source updated',
'description': (
'The <mark meta="{"annotationId":"c27",'
'"comment":"asdf"}">Necronomicon</mark>,'
' also referred to as the Book of the Dead'),
'artifact': [artifact.id]},
follow_redirects=True)
assert b'Source updated' in rv.data
rv = c.get(url_for('entity_add_reference', id_=source_id))
assert b'link reference' in rv.data
rv = c.post(
url_for('entity_add_reference', id_=source_id),
data={'reference': reference.id, 'page': '777'},
follow_redirects=True)
assert b'777' in rv.data
rv = c.get(
url_for(
'insert',
class_='source_translation',
origin_id=source_id))
assert b'+ Source translation' in rv.data
rv = c.post(
url_for(
'insert',
class_='source_translation',
origin_id=source_id),
data={'name': 'Translation continued', 'continue_': 'yes'},
follow_redirects=True)
assert b'+' in rv.data
rv = c.post(
url_for(
'insert',
class_='source_translation',
origin_id=source_id),
data={'name': 'Test translation'})
translation_id = rv.location.split('/')[-1]
rv = c.get(url_for('update', id_=translation_id))
assert b'Test translation' in rv.data
rv = c.post(
url_for('update', id_=translation_id),
data={'name': 'Translation updated', 'opened': '9999999999'},
follow_redirects=True)
assert b'Translation updated' in rv.data
rv = c.post(
url_for('update', id_=translation_id),
data={'name': 'Translation updated', 'opened': '1000000000'},
follow_redirects=True)
assert b'because it has been modified' in rv.data
rv = c.get(
url_for('delete', id_=translation_id),
follow_redirects=True)
assert b'The entry has been deleted' in rv.data