Skip to content

Commit 1e0f942

Browse files
authored
Merge pull request #1392 from OpenDataServices/update-requirements
Update requirements
2 parents d6824f8 + c03e994 commit 1e0f942

10 files changed

+344
-266
lines changed

cove_iati/lib/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
from libcove.lib.exceptions import CoveInputDataError
3-
from django.utils.translation import ugettext_lazy as _
3+
from django.utils.translation import gettext_lazy as _
44

55

66
class UnrecognisedFileTypeXML(CoveInputDataError):

cove_iati/lib/iati.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import requests
88
from bdd_tester import bdd_tester
99
from django.utils.html import format_html
10-
from django.utils.translation import ugettext_lazy as _
10+
from django.utils.translation import gettext_lazy as _
1111
from libcove.lib.exceptions import CoveInputDataError
1212
from libcove.lib.tools import ignore_errors
1313

cove_iati/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ def test_participating_org():
742742
"codeforiati:registry-identifier": "psi",
743743
"count": 2,
744744
"name": "Population Service " "International",
745-
"status": "active",
745+
"status": "withdrawn",
746746
"type_count": {
747747
"Participating Org": 0,
748748
"Transaction Provider": 0,

cove_iati/tests_functional.py

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
import requests
55
from selenium import webdriver
66
from selenium.common.exceptions import NoSuchElementException
7+
from selenium.webdriver.common.by import By
78
from selenium.webdriver.chrome.options import Options
89

910
BROWSER = os.environ.get('BROWSER', 'ChromeHeadless')
11+
CHROME_SNAP = bool(os.environ.get('CHROME_SNAP', False))
1012

1113

1214
@pytest.fixture(scope="module")
1315
def browser(request):
1416
if BROWSER == 'ChromeHeadless':
15-
chrome_options = Options()
16-
chrome_options.add_argument("--headless")
17-
browser = webdriver.Chrome(chrome_options=chrome_options)
17+
options = Options()
18+
options.add_argument("--headless")
19+
if CHROME_SNAP:
20+
options.add_argument("--remote-debugging-port=9222")
21+
browser = webdriver.Chrome(options=options)
1822
else:
1923
browser = getattr(webdriver, BROWSER)()
2024
browser.implicitly_wait(3)
@@ -34,56 +38,56 @@ def test_accordion(server_url, browser):
3438
browser.get(server_url)
3539

3640
def buttons():
37-
return [b.is_displayed() for b in browser.find_elements_by_tag_name('button')]
41+
return [b.is_displayed() for b in browser.find_elements(By.TAG_NAME, 'button')]
3842

3943
time.sleep(0.5)
4044
assert buttons() == [True, False, False]
41-
assert 'Upload a file (.csv, .xlsx, .xml)' in browser.find_elements_by_tag_name('label')[0].text
42-
browser.find_element_by_partial_link_text('Link').click()
45+
assert 'Upload a file (.csv, .xlsx, .xml)' in browser.find_elements(By.TAG_NAME, 'label')[0].text
46+
browser.find_element(By.PARTIAL_LINK_TEXT, 'Link').click()
4347
browser.implicitly_wait(1)
4448
time.sleep(0.5)
4549
assert buttons() == [False, True, False]
46-
browser.find_element_by_partial_link_text('Paste').click()
50+
browser.find_element(By.PARTIAL_LINK_TEXT, 'Paste').click()
4751
time.sleep(0.5)
4852
assert buttons() == [False, False, True]
49-
assert 'Paste (XML only)' in browser.find_elements_by_tag_name('label')[2].text
53+
assert 'Paste (XML only)' in browser.find_elements(By.TAG_NAME, 'label')[2].text
5054

5155
# Now test that the whole banner is clickable
52-
browser.find_element_by_id('headingOne').click()
56+
browser.find_element(By.ID, 'headingOne').click()
5357
time.sleep(0.5)
5458
assert buttons() == [True, False, False]
55-
browser.find_element_by_id('headingTwo').click()
59+
browser.find_element(By.ID, 'headingTwo').click()
5660
time.sleep(0.5)
5761
assert buttons() == [False, True, False]
58-
browser.find_element_by_id('headingThree').click()
62+
browser.find_element(By.ID, 'headingThree').click()
5963
time.sleep(0.5)
6064
assert buttons() == [False, False, True]
6165

6266

6367
def test_index_page_iati(server_url, browser):
6468
browser.get(server_url)
65-
assert 'How to use IATI CoVE' in browser.find_element_by_tag_name('body').text
66-
assert 'XML - according to version 2.03 of the IATI schema' in browser.find_element_by_tag_name('body').text
67-
assert 'Spreadsheet - Excel, CSV (UTF-8, Windows-1252 and ISO-8859-1 encodings supported) - see sample data' in browser.find_element_by_tag_name('body').text
69+
assert 'How to use IATI CoVE' in browser.find_element(By.TAG_NAME, 'body').text
70+
assert 'XML - according to version 2.03 of the IATI schema' in browser.find_element(By.TAG_NAME, 'body').text
71+
assert 'Spreadsheet - Excel, CSV (UTF-8, Windows-1252 and ISO-8859-1 encodings supported) - see sample data' in browser.find_element(By.TAG_NAME, 'body').text
6872

6973

7074
@pytest.mark.parametrize(('link_text', 'url'), [
7175
('IATI schema', 'http://reference.iatistandard.org/203/schema/')
7276
])
7377
def test_index_page_iati_links(server_url, browser, link_text, url):
7478
browser.get(server_url)
75-
link = browser.find_element_by_link_text(link_text)
79+
link = browser.find_element(By.LINK_TEXT, link_text)
7680
href = link.get_attribute("href")
7781
assert url in href
7882

7983

8084
def test_common_index_elements(server_url, browser):
8185
browser.get(server_url)
82-
browser.find_element_by_css_selector('#more-information .panel-title').click()
86+
browser.find_element(By.CSS_SELECTOR, '#more-information .panel-title').click()
8387
time.sleep(0.5)
84-
assert 'What happens to the data I provide to this site?' in browser.find_element_by_tag_name('body').text
85-
assert 'Why do you delete data after seven days?' in browser.find_element_by_tag_name('body').text
86-
assert 'Why provide converted versions?' in browser.find_element_by_tag_name('body').text
88+
assert 'What happens to the data I provide to this site?' in browser.find_element(By.TAG_NAME, 'body').text
89+
assert 'Why do you delete data after seven days?' in browser.find_element(By.TAG_NAME, 'body').text
90+
assert 'Why provide converted versions?' in browser.find_element(By.TAG_NAME, 'body').text
8791

8892

8993
@pytest.mark.parametrize(('source_filename', 'expected_text', 'conversion_successful'), [
@@ -118,15 +122,15 @@ def test_explore_iati_url_input(server_url, browser, httpserver, source_filename
118122
source_url = httpserver.url + '/' + source_filename
119123

120124
browser.get(server_url)
121-
browser.find_element_by_partial_link_text('Link').click()
125+
browser.find_element(By.PARTIAL_LINK_TEXT, 'Link').click()
122126
time.sleep(0.5)
123-
browser.find_element_by_id('id_source_url').send_keys(source_url)
124-
browser.find_element_by_css_selector("#fetchURL > div.form-group > button.btn.btn-primary").click()
127+
browser.find_element(By.ID, 'id_source_url').send_keys(source_url)
128+
browser.find_element(By.CSS_SELECTOR, "#fetchURL > div.form-group > button.btn.btn-primary").click()
125129

126130
data_url = browser.current_url
127131

128132
# Click and un-collapse all explore sections
129-
all_sections = browser.find_elements_by_class_name('panel-heading')
133+
all_sections = browser.find_elements(By.CLASS_NAME, 'panel-heading')
130134
for section in all_sections:
131135
if section.get_attribute('data-toggle') == "collapse" and section.get_attribute('aria-expanded') != 'true':
132136
browser.execute_script("arguments[0].scrollIntoView();", section)
@@ -141,7 +145,7 @@ def test_explore_iati_url_input(server_url, browser, httpserver, source_filename
141145

142146
# Expand all sections with the expand all button this time
143147
try:
144-
browser.find_element_by_link_text('Expand all').click()
148+
browser.find_element(By.LINK_TEXT, 'Expand all').click()
145149
time.sleep(0.5)
146150
except NoSuchElementException:
147151
pass
@@ -151,7 +155,7 @@ def test_explore_iati_url_input(server_url, browser, httpserver, source_filename
151155

152156

153157
def check_url_input_result_page(server_url, browser, httpserver, source_filename, expected_text, conversion_successful):
154-
body_text = browser.find_element_by_tag_name('body').text
158+
body_text = browser.find_element(By.TAG_NAME, 'body').text
155159
if isinstance(expected_text, str):
156160
expected_text = [expected_text]
157161

@@ -162,7 +166,7 @@ def check_url_input_result_page(server_url, browser, httpserver, source_filename
162166
assert 'Converted to XML' in body_text
163167

164168
if source_filename == 'namespace_good.xlsx':
165-
converted_file = browser.find_element_by_link_text("XML (Converted from Original)").get_attribute("href")
169+
converted_file = browser.find_element(By.LINK_TEXT, "XML (Converted from Original)").get_attribute("href")
166170
assert requests.get(converted_file).text == '''<?xml version='1.0' encoding='utf-8'?>
167171
<iati-activities>
168172
<!--Data generated by IATI CoVE. Built by Open Data Services Co-operative: http://iati.cove.opendataservices.coop/-->
@@ -174,7 +178,7 @@ def check_url_input_result_page(server_url, browser, httpserver, source_filename
174178
'''
175179

176180
if source_filename == 'basic_iati_org_valid.xlsx':
177-
converted_file = browser.find_element_by_link_text("XML (Converted from Original)").get_attribute("href")
181+
converted_file = browser.find_element(By.LINK_TEXT, "XML (Converted from Original)").get_attribute("href")
178182
assert requests.get(converted_file).text == '''<?xml version='1.0' encoding='utf-8'?>
179183
<iati-organisations version="2.03">
180184
<!--Data generated by IATI CoVE. Built by Open Data Services Co-operative: http://iati.cove.opendataservices.coop/-->
@@ -220,36 +224,36 @@ def test_rulesets_table_toggle(server_url, browser, httpserver):
220224
source_url = httpserver.url + '/basic_iati_ruleset_errors.xml'
221225

222226
browser.get(server_url)
223-
browser.find_element_by_partial_link_text('Link').click()
227+
browser.find_element(By.PARTIAL_LINK_TEXT, 'Link').click()
224228
time.sleep(0.5)
225-
browser.find_element_by_id('id_source_url').send_keys(source_url)
226-
browser.find_element_by_css_selector('#fetchURL > div.form-group > button.btn.btn-primary').click()
229+
browser.find_element(By.ID, 'id_source_url').send_keys(source_url)
230+
browser.find_element(By.CSS_SELECTOR, '#fetchURL > div.form-group > button.btn.btn-primary').click()
227231

228232
# Click and un-collapse all explore sections
229-
all_sections = browser.find_elements_by_class_name('panel-heading')
233+
all_sections = browser.find_elements(By.CLASS_NAME, 'panel-heading')
230234
for section in all_sections:
231235
if section.get_attribute('data-toggle') == 'collapse':
232236
if section.get_attribute('aria-expanded') != 'true':
233237
browser.execute_script('arguments[0].scrollIntoView();', section)
234238
section.click()
235239
time.sleep(0.5)
236240

237-
toggle_button = browser.find_element_by_name('ruleset-table-toggle')
238-
table_header = browser.find_element_by_css_selector('table#ruleset-by-rule thead tr')
241+
toggle_button = browser.find_element(By.NAME, 'ruleset-table-toggle')
242+
table_header = browser.find_element(By.CSS_SELECTOR, 'table#ruleset-by-rule thead tr')
239243
header_html = ''.join(table_header.get_attribute('innerHTML').strip().split())
240244

241245
assert toggle_button.text == 'See same results by activity'
242-
assert browser.find_element_by_id('ruleset-by-rule').is_displayed()
243-
assert not browser.find_element_by_id('ruleset-by-activity').is_displayed()
246+
assert browser.find_element(By.ID, 'ruleset-by-rule').is_displayed()
247+
assert not browser.find_element(By.ID, 'ruleset-by-activity').is_displayed()
244248
assert header_html == '<th>Ruleset</th><th>Rule</th><th>Activity</th><th>Explanation</th><th>Path</th>'
245249

246250
toggle_button.click()
247251
time.sleep(0.5)
248-
toggle_button = browser.find_element_by_name('ruleset-table-toggle')
249-
table_header = browser.find_element_by_css_selector('table#ruleset-by-activity thead tr')
252+
toggle_button = browser.find_element(By.NAME, 'ruleset-table-toggle')
253+
table_header = browser.find_element(By.CSS_SELECTOR, 'table#ruleset-by-activity thead tr')
250254
header_html = ''.join(table_header.get_attribute('innerHTML').strip().split())
251255

252256
assert toggle_button.text == 'See same results by ruleset'
253-
assert browser.find_element_by_id('ruleset-by-activity').is_displayed()
254-
assert not browser.find_element_by_id('ruleset-by-rule').is_displayed()
257+
assert browser.find_element(By.ID, 'ruleset-by-activity').is_displayed()
258+
assert not browser.find_element(By.ID, 'ruleset-by-rule').is_displayed()
255259
assert header_html == '<th>Activity</th><th>Ruleset</th><th>Rule</th><th>Explanation</th><th>Path</th>'

cove_iati/urls.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.conf.urls import url
1+
from django.urls import re_path
22

33
from cove.urls import urlpatterns, handler500 # noqa: F401
44
from django.conf.urls.static import static
@@ -7,10 +7,10 @@
77
import cove_iati.views
88

99
urlpatterns = [
10-
url(r'^$', cove_iati.views.data_input_iati, name='index'),
11-
url(r'^data/(.+)/(.+)$', cove_iati.views.explore_iati, name='explore_suffix'),
12-
url(r'^data/(.+)$', cove_iati.views.explore_iati, name='explore'),
13-
url(r'^api_test', cove_iati.views.api_test, name='api_test'),
10+
re_path(r'^$', cove_iati.views.data_input_iati, name='index'),
11+
re_path(r'^data/(.+)/(.+)$', cove_iati.views.explore_iati, name='explore_suffix'),
12+
re_path(r'^data/(.+)$', cove_iati.views.explore_iati, name='explore'),
13+
re_path(r'^api_test', cove_iati.views.api_test, name='api_test'),
1414
] + urlpatterns
1515

1616
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

cove_iati/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from django.conf import settings
1111
from django.http import HttpResponse, HttpResponseBadRequest
1212
from django.shortcuts import render
13-
from django.utils.translation import ugettext_lazy as _
13+
from django.utils.translation import gettext_lazy as _
1414
from django.views.decorators.csrf import csrf_exempt
1515
from django.views.decorators.http import require_POST
1616
import iatiutils.merge_indicator

requirements.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Django>3.2,<3.3
1+
Django>4.2,<4.3
22
#^^ rq.filter: <1.12
33
flattentool>=0.17.2
44
libcove
@@ -23,6 +23,7 @@ xmltodict
2323
rangedict
2424
openpyxl
2525
gunicorn
26+
lxml<5
2627

2728
# We have a fork of the bdd-tester repo, in order to add a single commit that
2829
# fixes the previous commit we were using, to work with the new pip resolver.

0 commit comments

Comments
 (0)