Commit 877b3223 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

encoding attribute have been removed in python 3.9

parent af2b521b
......@@ -1168,13 +1168,13 @@ class SearchTestCase(ViewTestCase):
url = reverse('viralhostrangedb-api:search')
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertIn("err", json.loads(response.content, encoding='utf8'))
self.assertIn("err", json.loads(response.content))
def test_works_no_auth(self):
url = reverse('viralhostrangedb-api:search') + "?search=privateprivateprivate"
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
self.assertEqual(response["data_source"]["count"], 0)
......@@ -1184,7 +1184,7 @@ class SearchTestCase(ViewTestCase):
self.client.force_login(self.user)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertGreater(response["data_source"]["count"], 0)
def test_works_ui_help(self):
......@@ -1192,7 +1192,7 @@ class SearchTestCase(ViewTestCase):
self.client.force_login(self.user)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertGreater(response["data_source"]["count"], 0)
def test_privacy_cross_auth(self):
......@@ -1200,7 +1200,7 @@ class SearchTestCase(ViewTestCase):
self.client.force_login(self.toto)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["data_source"]["count"], 0)
def test_advanced(self):
......@@ -1209,36 +1209,36 @@ class SearchTestCase(ViewTestCase):
self.client.force_login(self.toto)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["data_source"]["count"], 1)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
self.client.logout()
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
url = reverse('viralhostrangedb-api:search') + "?search=" + ds.virus_set.first().name
self.client.force_login(self.toto)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 1)
self.assertEqual(response["host"]["count"], 0)
self.client.logout()
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["virus"]["count"], 0)
url = reverse('viralhostrangedb-api:search') + "?search=" + ds.host_set.first().name
self.client.force_login(self.toto)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 1)
self.client.logout()
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["host"]["count"], 0)
def test_only_identifier_virus(self):
......@@ -1247,13 +1247,13 @@ class SearchTestCase(ViewTestCase):
self.r1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 1)
self.assertEqual(response["host"]["count"], 0)
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1262,7 +1262,7 @@ class SearchTestCase(ViewTestCase):
self.r1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1271,7 +1271,7 @@ class SearchTestCase(ViewTestCase):
self.r1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 1)
self.assertEqual(response["host"]["count"], 0)
......@@ -1282,13 +1282,13 @@ class SearchTestCase(ViewTestCase):
self.C1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 1)
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1297,7 +1297,7 @@ class SearchTestCase(ViewTestCase):
self.C1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1306,7 +1306,7 @@ class SearchTestCase(ViewTestCase):
self.C1.save()
url = reverse('viralhostrangedb-api:search') + "?search=" + search + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 1)
......@@ -1317,13 +1317,13 @@ class SearchTestCase(ViewTestCase):
self.private_data_source_of_toto_with_no_virus_or_host_shared.name + "\""
url = base_url
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 1)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
url = base_url + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1332,7 +1332,7 @@ class SearchTestCase(ViewTestCase):
self.Cx.save()
url = base_url + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1341,13 +1341,13 @@ class SearchTestCase(ViewTestCase):
self.Cx.save()
url = base_url + "&only_host_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 1)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
url = base_url + "&only_host_ncbi_id=on" + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1356,7 +1356,7 @@ class SearchTestCase(ViewTestCase):
self.rx.save()
url = base_url + "&only_host_ncbi_id=on" + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1365,7 +1365,7 @@ class SearchTestCase(ViewTestCase):
self.rx.save()
url = base_url + "&only_host_ncbi_id=on" + "&only_virus_ncbi_id=on"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 1)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1378,13 +1378,13 @@ class SearchTestCase(ViewTestCase):
self.r2.her_identifier = her
self.r2.save()
url = reverse('viralhostrangedb-api:search') + "?search=%i" % her
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertSetEqual(set([o["id"] for o in response["virus"]["sample"]]), {self.r1.id, self.r2.id})
url = reverse('viralhostrangedb-api:search') + "?search=her:%i" % her
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertSetEqual(set([o["id"] for o in response["virus"]["sample"]]), {self.r2.id})
url = reverse('viralhostrangedb-api:search') + "?search=her:ZZ"
response = json.loads(self.client.get(url).content, encoding='utf8')
response = json.loads(self.client.get(url).content)
self.assertEqual(response["data_source"]["count"], 0)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
......@@ -1396,16 +1396,16 @@ class SearchTestCase(ViewTestCase):
# I could have use unidecode but I did not
url = reverse('viralhostrangedb-api:search') + "?search=%s" % "Herelle"
self.assertEqual(json.loads(self.client.get(url).content, encoding='utf8')["data_source"]["count"], 0)
self.assertEqual(json.loads(self.client.get(url).content)["data_source"]["count"], 0)
models.DataSource.objects.filter(pk=self.public_data_source_of_user.pk).update(description=text)
self.assertEqual(json.loads(self.client.get(url).content, encoding='utf8')["data_source"]["count"], 1)
self.assertEqual(json.loads(self.client.get(url).content)["data_source"]["count"], 1)
models.DataSource.objects.filter(pk=self.public_data_source_of_user.pk).update(name=text)
self.assertEqual(json.loads(self.client.get(url).content, encoding='utf8')["data_source"]["count"], 1)
self.assertEqual(json.loads(self.client.get(url).content)["data_source"]["count"], 1)
models.DataSource.objects.filter(pk=self.public_data_source_with_ids_of_toto.pk).update(description=text)
self.assertEqual(json.loads(self.client.get(url).content, encoding='utf8')["data_source"]["count"], 2)
self.assertEqual(json.loads(self.client.get(url).content)["data_source"]["count"], 2)
def test_data_source_searched(self):
base_url = reverse('viralhostrangedb-api:search') + "?search="
......@@ -1416,7 +1416,7 @@ class SearchTestCase(ViewTestCase):
self.public_data_source_of_user.owner.last_name[3:-3],
self.public_data_source_of_user.owner.first_name[:-3],
]:
response = json.loads(self.client.get(base_url + searched).content, encoding='utf8')
response = json.loads(self.client.get(base_url + searched).content)
self.assertEqual(
response['data_source']['sample'][0]['provider'],
self.user.last_name.upper() + " " + self.user.first_name.title()
......@@ -1431,7 +1431,7 @@ class SearchTestCase(ViewTestCase):
self.public_data_source_of_user.provider_first_name[2:],
self.public_data_source_of_user.provider_last_name[2:],
]:
response = json.loads(self.client.get(base_url + searched).content, encoding='utf8')
response = json.loads(self.client.get(base_url + searched).content)
self.assertEqual(
response['data_source']['sample'][0]['provider'],
self.public_data_source_of_user.provider_last_name.upper() + " " +
......@@ -1445,7 +1445,7 @@ class SearchTestCase(ViewTestCase):
self.public_data_source_of_user.owner.first_name,
self.public_data_source_of_user.owner.last_name[3:-3],
]:
response = json.loads(self.client.get(base_url + searched).content, encoding='utf8')
response = json.loads(self.client.get(base_url + searched).content)
pks = {d['id'] for d in response['data_source']['sample']}
self.assertNotIn(self.public_data_source_of_user.pk, pks)
......@@ -1456,7 +1456,7 @@ class SearchTestCase(ViewTestCase):
d.save()
base_url = reverse('viralhostrangedb-api:search') + "?search=azerty&str_max_length=%i"
for str_max_length in [10, 50, 100, 200]:
response = json.loads(self.client.get(base_url % str_max_length).content, encoding='utf8')
response = json.loads(self.client.get(base_url % str_max_length).content)
for d in response["data_source"]["sample"]:
self.assertLessEqual(len(d["description"]), str_max_length)
self.assertTrue(models.DataSource.objects.filter(name=d["name"], id=d["id"]).exists())
......@@ -1607,7 +1607,7 @@ class GreekLettersTest(TestCase):
]:
response = self.client.get(url + urllib.parse.urlencode(dict(search=s)))
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["virus"]["count"], cpt, "For %s expected %i" % (s, cpt))
self.assertEqual(response["host"]["count"], 0)
self.assertEqual(response["data_source"]["count"], 0)
......@@ -1620,7 +1620,7 @@ class GreekLettersTest(TestCase):
("ξ", "xi"),
]:
response = self.client.get(url + "&search=" + name)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertIn(letter, response["query"]["alternative_searched_texts"])
......@@ -1672,7 +1672,7 @@ class SearchSpaceSplitTest(TestCase):
]:
response = self.client.get(url + "&search=" + s)
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["virus"]["count"], 0)
self.assertEqual(response["host"]["count"], 0)
self.assertEqual(response["data_source"]["count"], cpt, "For <i>%s</i> expected %i" % (s, cpt))
......@@ -1689,7 +1689,7 @@ class SearchSpaceSplitTest(TestCase):
]:
response = self.client.get(url + urllib.parse.urlencode(dict(search=s)))
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
self.assertEqual(response["virus"]["count"], cpt, "For <i>%s</i> expected %i" % (s, cpt))
self.assertEqual(response["host"]["count"], 0)
self.assertEqual(response["data_source"]["count"], 0)
......@@ -1770,7 +1770,7 @@ class SearchMatchCountTest(TestCase):
d["sorting"] = sorting
if kind:
d["kind"] = kind
return json.loads(self.client.get(self.url + urllib.parse.urlencode(d)).content, encoding='utf8')
return json.loads(self.client.get(self.url + urllib.parse.urlencode(d)).content)
def test_sorting_pk(self):
# don't care of the number of hit, just return them, by pk probably
......@@ -1912,7 +1912,7 @@ class SearchMatchCountTest(TestCase):
d["sorting"] = sorting
response = self.client.get(self.url + urllib.parse.urlencode(d))
self.assertEqual(response.status_code, 200)
response = json.loads(response.content, encoding='utf8')
response = json.loads(response.content)
if 'app_error_code' in response:
ids = []
else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment