You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
"""Unit tests for ids module."""
|
|
|
|
|
|
def test_document_id_format():
|
|
from libs.common.ids import document_id
|
|
did = document_id("sec", "ISSUER::0000320193", "2026-01-29", "0000320193-26-000001")
|
|
assert did.startswith("DOC::sec::ISSUER::0000320193::2026-01-29::")
|
|
|
|
|
|
def test_event_id_format():
|
|
from libs.common.ids import event_id
|
|
eid = event_id("DOC::sec::x::2026-01-01::acc", "earnings_release")
|
|
assert eid.startswith("EVT::")
|
|
assert "earnings_release" in eid
|
|
|
|
|
|
def test_issuer_id_from_cik():
|
|
from libs.common.ids import issuer_id_from_cik
|
|
iid = issuer_id_from_cik("320193")
|
|
assert iid == "ISSUER::0000320193"
|
|
|
|
|
|
def test_symbol_id_from_ticker():
|
|
from libs.common.ids import symbol_id_from_ticker
|
|
sid = symbol_id_from_ticker("AAPL")
|
|
assert sid == "SYM::AAPL::XNYS"
|
|
|
|
|
|
def test_symbol_id_uppercase():
|
|
from libs.common.ids import symbol_id_from_ticker
|
|
sid = symbol_id_from_ticker("aapl", "NASDAQ")
|
|
assert sid == "SYM::AAPL::NASDAQ"
|
|
|
|
|
|
def test_sha256_checksum():
|
|
from libs.common.ids import sha256_checksum
|
|
c = sha256_checksum(b"hello")
|
|
assert len(c) == 64
|
|
assert c == sha256_checksum(b"hello")
|
|
|
|
|
|
def test_sha256_different():
|
|
from libs.common.ids import sha256_checksum
|
|
assert sha256_checksum(b"hello") != sha256_checksum(b"world")
|
|
|
|
|
|
def test_new_job_run_id():
|
|
import uuid
|
|
|
|
from libs.common.ids import new_job_run_id
|
|
rid = new_job_run_id()
|
|
# Must be valid UUID
|
|
uuid.UUID(rid)
|