[tests/results] support 'iso:…' tests
This commit is contained in:
@@ -86,26 +86,27 @@ __tests__ = (
|
|||||||
"#options" : {"max-posts": 100, "endpoint": "posts"},
|
"#options" : {"max-posts": 100, "endpoint": "posts"},
|
||||||
"#count" : range(200, 400),
|
"#count" : range(200, 400),
|
||||||
|
|
||||||
"added" : {str, None},
|
|
||||||
"archives" : [],
|
"archives" : [],
|
||||||
"attachments": list,
|
"attachments": list,
|
||||||
"captions" : None,
|
|
||||||
"content" : str,
|
|
||||||
"count" : int,
|
"count" : int,
|
||||||
"num" : int,
|
"num" : int,
|
||||||
"date" : "type:datetime",
|
|
||||||
"edited" : {str, None},
|
|
||||||
"embed" : dict,
|
|
||||||
"id" : str,
|
"id" : str,
|
||||||
"poll" : None,
|
"date" : "type:datetime",
|
||||||
"published" : str,
|
"published" : str,
|
||||||
"service" : "patreon",
|
"service" : "patreon",
|
||||||
"shared_file": False,
|
|
||||||
"subcategory": "patreon",
|
"subcategory": "patreon",
|
||||||
"tags" : {str, None},
|
|
||||||
"title" : str,
|
"title" : str,
|
||||||
"user" : "881792",
|
"user" : "881792",
|
||||||
"username" : "diives",
|
"username" : "diives",
|
||||||
|
|
||||||
|
"!added" : {str, None},
|
||||||
|
"!captions" : None,
|
||||||
|
"!content" : str,
|
||||||
|
"!edited" : {str, None},
|
||||||
|
"!embed" : dict,
|
||||||
|
"!poll" : None,
|
||||||
|
"!shared_file": False,
|
||||||
|
"!tags" : {str, None},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -483,7 +484,7 @@ __tests__ = (
|
|||||||
"public_id": "soso",
|
"public_id": "soso",
|
||||||
"relation_id": None,
|
"relation_id": None,
|
||||||
"service": "fanbox",
|
"service": "fanbox",
|
||||||
"updated": "2025-03-29T05:44:56.747243",
|
"updated": "iso:datetime",
|
||||||
},
|
},
|
||||||
"tags": [
|
"tags": [
|
||||||
"うごイラ",
|
"うごイラ",
|
||||||
|
|||||||
@@ -348,6 +348,21 @@ class TestExtractorResults(unittest.TestCase):
|
|||||||
for _ in value:
|
for _ in value:
|
||||||
len_value += 1
|
len_value += 1
|
||||||
self.assertEqual(int(length), len_value, msg=path)
|
self.assertEqual(int(length), len_value, msg=path)
|
||||||
|
elif test.startswith("iso:"):
|
||||||
|
iso = test[4:]
|
||||||
|
if iso in ("dt", "datetime", "8601"):
|
||||||
|
msg = f"{path} / ISO 8601"
|
||||||
|
try:
|
||||||
|
dt = datetime.datetime.fromisoformat(value)
|
||||||
|
except Exception as exc:
|
||||||
|
self.fail(f"Invalid datetime '{value}': {exc} {msg}")
|
||||||
|
self.assertIsInstance(dt, datetime.datetime, msg=msg)
|
||||||
|
elif iso in ("lang", "639", "639-1"):
|
||||||
|
msg = f"{path} / ISO 639-1"
|
||||||
|
self.assertIsInstance(value, str, msg=msg)
|
||||||
|
self.assertRegex(value, r"^[a-z]{2}(-\w+)?$", msg=msg)
|
||||||
|
else:
|
||||||
|
self.fail(f"Unsupported ISO test '{test}'")
|
||||||
else:
|
else:
|
||||||
self.assertEqual(test, value, msg=path)
|
self.assertEqual(test, value, msg=path)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user