hdx.freshness.testdata.dbtestresult
SQLAlchemy class representing DBTestResult row. Holds test data mimicking the result of downloading and hashing urls (first time).
DBTestResult Objects
class DBTestResult(Base)
id: Mapped[str] = mapped_column(primary_key=True) url: Mapped[str] = mapped_column(nullable=False) format: Mapped[str] = mapped_column(nullable=False) err: Mapped[str] = mapped_column(nullable=True) http_last_modified: Mapped[datetime] = mapped_column(nullable=True) hash: Mapped[str] = mapped_column(nullable=True) xlsx_hash: Mapped[str] = mapped_column(nullable=True) force_hash: Mapped[bool] = mapped_column(nullable=False)
__repr__
def __repr__() -> str
String representation of DBTestResult row
Returns:
str
- String representation of DBTestResult row
hdx.freshness.testdata.serialize
Functions to serialise and deserialise test data, for example for datasets
serialize_datasets
def serialize_datasets(session: Session, datasets: List[Dataset]) -> None
Serialise HDX datasets to database objects
Arguments:
session
sqlalchemy.orm.Session - Session to use for queries for test datadatasets
List[Dataset] - HDX datasets
Returns:
None
serialize_now
def serialize_now(session: Session, now: datetime) -> None
Serialise date to database object
Arguments:
session
sqlalchemy.orm.Session - Session to use for queries for test datanow
datetime - Current date
Returns:
None
serialize_results
def serialize_results(session: Session, results: Dict[str, Tuple]) -> None
Serialise results of downloading and hashing urls (first time) to database objects
Arguments:
session
sqlalchemy.orm.Session - Session to use for queries for test dataresults
Dict[str, Tuple] - Results of downloading and hashing urls (1st time)
Returns:
None
serialize_hashresults
def serialize_hashresults(session: Session, hash_results: Dict[str,
Tuple]) -> None
Serialise results of downloading and hashing urls (second time) to database objects
Arguments:
session
sqlalchemy.orm.Session - Session to use for queries for test datahash_results
Dict[str, Tuple] - Results of downloading+hashing urls (2nd time)
Returns:
None
deserialize_datasets
def deserialize_datasets(session: Session) -> Iterable[Dataset]
Deserialise database objects to HDX datasets
Arguments:
session
sqlalchemy.orm.Session - Session to use for queries for test data
Returns:
Iterable[Dataset]
- HDX Dataset objects
deserialize_now
def deserialize_now(session: Session) -> datetime
Deserialise database object to date
Arguments:
session
sqlalchemy.orm.Session - Session to use for queries for test data
Returns:
datetime
- date
deserialize_results
def deserialize_results(session: Session) -> List[Tuple]
Deserialise database objects to results of downloading and hashing urls (first time)
Arguments:
session
sqlalchemy.orm.Session - Session to use for queries for test data
Returns:
List[Tuple]
- Results of downloading and hashing urls (first time)
deserialize_hashresults
def deserialize_hashresults(session: Session) -> List[Tuple]
Deserialise database objects to results of downloading and hashing urls (second time)
Arguments:
session
sqlalchemy.orm.Session - Session to use for queries for test data
Returns:
List[Tuple]
- Results of downloading and hashing urls (second time)
hdx.freshness.testdata.dbtesthashresult
SQLAlchemy class representing DBTestResult row. Holds test data mimicking the result of downloading and hashing urls (second time).
DBTestHashResult Objects
class DBTestHashResult(Base)
id: Mapped[str] = mapped_column(primary_key=True) url: Mapped[str] = mapped_column(nullable=False) format: Mapped[str] = mapped_column(nullable=False) err: Mapped[str] = mapped_column(nullable=True) http_last_modified: Mapped[datetime] = mapped_column(nullable=True) hash: Mapped[str] = mapped_column(nullable=True) xlsx_hash: Mapped[str] = mapped_column(nullable=True) force_hash: Mapped[bool] = mapped_column(nullable=False)
__repr__
def __repr__() -> str
String representation of DBTestHashresult row
Returns:
str
- String representation of DBTestHashResult row
hdx.freshness.testdata.dbtestdataset
SQLAlchemy class representing DBTestDataset row. Holds test data for datasets with the aim of mimicking what would come from HDX.
DBTestDataset Objects
class DBTestDataset(Base)
id: Mapped[str] = mapped_column(primary_key=True) organization_id: Mapped[str] = mapped_column(nullable=False) organization_name: Mapped[str] = mapped_column(nullable=False) organization_title: Mapped[str] = mapped_column(nullable=False) dataset_name: Mapped[str] = mapped_column(nullable=False) dataset_title: Mapped[str] = mapped_column(nullable=False) dataset_private: Mapped[bool] = mapped_column(nullable=False) dataset_maintainer: Mapped[str] = mapped_column(nullable=True) dataset_date: Mapped[str] = mapped_column(nullable=True) update_frequency: Mapped[str] = mapped_column(nullable=True) review_date: Mapped[str] = mapped_column(nullable=True) last_modified: Mapped[str] = mapped_column(nullable=False) updated_by_script: Mapped[str] = mapped_column(nullable=True) metadata_modified: Mapped[str] = mapped_column(nullable=False) is_requestdata_type: Mapped[bool] = mapped_column(nullable=True) dataset_location: Mapped[str] = mapped_column(nullable=True)
__repr__
def __repr__() -> str
String representation of DBTestDataset row
Returns:
str
- String representation of DBTestDataset row
hdx.freshness.testdata.dbtestdate
SQLAlchemy class representing DBTestDate row. Holds test data for dates.
DBTestDate Objects
class DBTestDate(Base)
test_date: Mapped[datetime] = mapped_column(primary_key=True)
__repr__
def __repr__() -> str
String representation of DBTestDate row
Returns:
str
- String representation of DBTestDate row
hdx.freshness.testdata.dbtestresource
SQLAlchemy class representing DBTestResource row. Holds test data for resources with the aim of mimicking what would come from HDX.
DBTestResource Objects
class DBTestResource(Base)
id: Mapped[str] = mapped_column(primary_key=True) name: Mapped[str] = mapped_column(nullable=False) format: Mapped[str] = mapped_column(nullable=False) dataset_id: Mapped[str] = mapped_column( ForeignKey("dbtestdatasets.id"), nullable=False ) url: Mapped[str] = mapped_column(nullable=False) metadata_modified: Mapped[str] = mapped_column(nullable=False) last_modified: Mapped[str] = mapped_column(nullable=False)
__repr__
def __repr__() -> str
String representation of DBTestResource row
Returns:
str
- String representation of DBTestResource row