Skip to content

Commit

Permalink
Update code that uses yaml and XML functions
Browse files Browse the repository at this point in the history
  • Loading branch information
willemarcel committed Oct 16, 2023
1 parent 0641209 commit 07009f0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
6 changes: 5 additions & 1 deletion osmchadjango/changeset/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
from os.path import join
from urllib.parse import quote
import yaml
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader

from django.conf import settings

Expand Down Expand Up @@ -74,7 +78,7 @@ def get_last_replication_id():
state = requests.get(
'{}state.yaml'.format(settings.OSM_PLANET_BASE_URL)
).content
state = yaml.load(state)
state = yaml.load(state, Loader)
return state.get('sequence')


Expand Down
6 changes: 3 additions & 3 deletions osmchadjango/changeset/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_creation(self):
self.assertEqual(Changeset.objects.count(), 1)
self.assertEqual(
changeset.bbox.wkt,
'POLYGON ((-34.9230192 -8.219786900000001, -34.855581 -8.219786900000001, -34.855581 -8.0335263, -34.9230192 -8.0335263, -34.9230192 -8.219786900000001))'
'POLYGON ((-34.9230192 -8.2197869, -34.855581 -8.2197869, -34.855581 -8.0335263, -34.9230192 -8.0335263, -34.9230192 -8.2197869))'
)
self.assertIsInstance(changeset.area, float)

Expand Down Expand Up @@ -62,8 +62,8 @@ class TestCreateChangesetWithoutBBOX(TestCase):
def test_creation(self):
changeset = create_changeset(47052680)
self.assertEqual(Changeset.objects.count(), 1)
self.assertIsNone(changeset.bbox)
self.assertEqual(changeset.area, None)
self.assertTrue(changeset.bbox.empty)
self.assertEqual(changeset.area, 0.0)


class TestChangesetCommentAPI(TestCase):
Expand Down
10 changes: 5 additions & 5 deletions osmchadjango/supervise/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,10 +859,10 @@ def test_aoi_changesets_feed_view(self):
reverse('supervise:aoi-changesets-feed', args=[self.aoi.pk])
)
self.assertEqual(response.status_code, 200)
rss_data = ET.fromstring(response.content).getchildren()[0].getchildren()
rss_data = ET.fromstring(response.content)[0]
title = [i for i in rss_data if i.tag == 'title'][0]
items = [i for i in rss_data if i.tag == 'item']
link = [i for i in items[0].getchildren() if i.tag == 'link'][0]
link = [i for i in items[0] if i.tag == 'link'][0]
self.assertIn(
"?aoi=",
link.text
Expand Down Expand Up @@ -893,7 +893,7 @@ def test_feed_view_of_unnamed_aoi_and_zero_changesets(self):
reverse('supervise:aoi-changesets-feed', args=[self.aoi.pk])
)
self.assertEqual(response.status_code, 200)
rss_data = ET.fromstring(response.content).getchildren()[0].getchildren()
rss_data = ET.fromstring(response.content)[0]
title = [i for i in rss_data if i.tag == 'title'][0]
items = [i for i in rss_data if i.tag == 'item']
self.assertEqual(
Expand Down Expand Up @@ -931,7 +931,7 @@ def test_feed_view_of_aoi_with_blacklist_filter(self):
reverse('supervise:aoi-changesets-feed', args=[self.aoi.pk])
)
self.assertEqual(response.status_code, 200)
rss_data = ET.fromstring(response.content).getchildren()[0].getchildren()
rss_data = ET.fromstring(response.content)[0]
title = [i for i in rss_data if i.tag == 'title'][0]
items = [i for i in rss_data if i.tag == 'item']
self.assertEqual(
Expand Down Expand Up @@ -961,7 +961,7 @@ def test_feed_view_of_aoi_with_hide_whitelist_filter(self):
reverse('supervise:aoi-changesets-feed', args=[aoi.pk])
)
self.assertEqual(response.status_code, 200)
rss_data = ET.fromstring(response.content).getchildren()[0].getchildren()
rss_data = ET.fromstring(response.content)[0]
title = [i for i in rss_data if i.tag == 'title'][0]
items = [i for i in rss_data if i.tag == 'item']
self.assertEqual(
Expand Down
6 changes: 3 additions & 3 deletions osmchadjango/users/tests/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class TestUpdateUserNameCommand(TestCase):
def setUp(self):
self.user = User.objects.create_user(
username='WilleMarcel',
username='rosrever',
email='[email protected]',
password='password'
)
Expand All @@ -37,14 +37,14 @@ def test_command(self):
call_command('update_user_names')
self.user.refresh_from_db()
self.user_2.refresh_from_db()
self.assertEqual(self.user.name, 'Wille Marcel')
self.assertEqual(self.user.name, 'rosrever')
self.assertEqual(self.user_2.name, 'narceliodesa')


class TestClearTokensCommand(TestCase):
def setUp(self):
self.user = User.objects.create_user(
username='WilleMarcel',
username='rosrever',
email='[email protected]',
password='password'
)
Expand Down
4 changes: 2 additions & 2 deletions osmchadjango/users/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class TestUpdateUserName(TestCase):
def setUp(self):
self.user = User.objects.create_user(
username='WilleMarcel',
username='rosrever',
email='[email protected]',
password='password'
)
Expand All @@ -35,7 +35,7 @@ def setUp(self):
def test_update_user_name(self):
update_user_name(self.user)
update_user_name(self.user_2)
self.assertEqual(self.user.name, 'Wille Marcel')
self.assertEqual(self.user.name, 'rosrever')
self.assertEqual(self.user_2.name, 'narceliodesa')

def test_user_with_wrong_uid(self):
Expand Down

0 comments on commit 07009f0

Please sign in to comment.