Skip to content

Commit

Permalink
Add tests for JSON client
Browse files Browse the repository at this point in the history
  • Loading branch information
gounux committed Apr 26, 2024
1 parent 457fe36 commit 2176a54
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/test_json_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import unittest

from geotribu_cli.json.json_client import JsonFeedClient


class TestJsonClient(unittest.TestCase):
"""Test Geotribu JSON client."""

def __init__(self, methodName: str = "runTest") -> None:
super().__init__(methodName)
self.client = JsonFeedClient()
self.items = self.client.items()
self.tags = self.client.tags()

def test_items_exist(self):
self.assertGreater(len(self.items), 0)

def test_some_existing_items(self):
titles = [i["title"] for i in self.items]
self.assertIn(
"Automatisation de publication des données de qualité de l'air sur Mastodon",
titles,
)
self.assertIn("Le crowdsourcing avec cocarto", titles)
self.assertIn(
"De Twitter (X) à Mastodon : guide pour les géomaticien/nes", titles
)

def test_tags_exist(self):
self.assertGreater(len(self.tags), 0)

def test_some_existing_tags(self):
for tag in ["OpenLayers", "QGIS", "OpenStreetMap", "QFieldCloud"]:
self.assertIn(tag, self.tags)

def test_unexisting_tags(self):
for tag in ["Kinkeliba", "Jogging", "cziygiyezrvcyryez"]:
self.assertNotIn(tag, self.tags)

def test_sorted_tags(self):
sorted_tags = self.client.tags(should_sort=True)
i = 1
while i < len(sorted_tags):
if sorted_tags[i] < sorted_tags[i - 1]:
raise Exception("Tags are not alphabetically sorted")
i += 1

0 comments on commit 2176a54

Please sign in to comment.