Revision aec5c9ae
Added by koszko about 1 year ago
test/haketilo_test/unit/test_indexeddb.py | ||
---|---|---|
50 | 50 |
'identifier': 'helloapple' |
51 | 51 |
} |
52 | 52 |
|
53 |
@pytest.mark.get_page('https://gotmyowndoma.in') |
|
54 |
def test_haketilodb_update_1_0_1(driver, execute_in_page): |
|
55 |
""" |
|
56 |
indexeddb.js modifies data when updating to database version 1.0.1. Verify |
|
57 |
the update procedure works properly. |
|
58 |
""" |
|
59 |
execute_in_page(load_script('common/indexeddb.js')) |
|
60 |
execute_in_page('db_version_nr = version_nr([1, 0, 0]);') |
|
61 |
mock_broadcast(execute_in_page) |
|
62 |
|
|
63 |
# Start with no database. |
|
64 |
clear_indexeddb(execute_in_page) |
|
65 |
|
|
66 |
v1_url = 'https://hydrilla.koszko.org/api_v1/' |
|
67 |
v2_url = 'https://hydrilla.koszko.org/api_v2/' |
|
68 |
urls_v1 = {'https://sample.url/abc/', v1_url} |
|
69 |
urls_v2 = {'https://sample.url/abc/', v2_url} |
|
70 |
|
|
71 |
for url in urls_v1: |
|
72 |
execute_in_page('returnval(set_repo(arguments[0]));', url) |
|
73 |
|
|
74 |
assert urls_v1 == set(execute_in_page('returnval(get_repos());')) |
|
75 |
|
|
76 |
# Verify that url gets updated to v2 upon database update. |
|
77 |
driver.get(driver.execute_script('return window.location.href;')) |
|
78 |
execute_in_page(load_script('common/indexeddb.js')) |
|
79 |
mock_broadcast(execute_in_page) |
|
80 |
|
|
81 |
database_contents = get_db_contents(execute_in_page) |
|
82 |
|
|
83 |
assert set(execute_in_page('returnval(get_repos());')) == urls_v2 |
|
84 |
|
|
85 |
# Verify that url does not get updated when there is no database update. |
|
86 |
execute_in_page('returnval(del_repo(arguments[0]));', v2_url) |
|
87 |
execute_in_page('returnval(set_repo(arguments[0]));', v1_url) |
|
88 |
|
|
89 |
driver.get(driver.execute_script('return window.location.href;')) |
|
90 |
execute_in_page(load_script('common/indexeddb.js')) |
|
91 |
mock_broadcast(execute_in_page) |
|
92 |
|
|
93 |
database_contents = get_db_contents(execute_in_page) |
|
94 |
|
|
95 |
assert set(execute_in_page('returnval(get_repos());')) == urls_v1 |
|
96 |
|
|
53 | 97 |
@pytest.mark.get_page('https://gotmyowndoma.in') |
54 | 98 |
def test_haketilodb_item_modifications(driver, execute_in_page): |
55 | 99 |
""" |
Also available in: Unified diff
automatically change repo url to point to api v2 endpoint