test: Add test infrastructure and basic model testing

This commit is contained in:
Georg Krause
2023-07-26 14:29:08 +02:00
parent 282031245c
commit a91eea5922
5 changed files with 483 additions and 67 deletions

View File

@@ -2,14 +2,20 @@ import logging
import requests
from typing import Dict, Union
class Instance:
def __init__(self, instance_dict):
def __init__(self, instance_dict : Dict):
"""If obfuscate, reject_media or reject_reports are not specified default to False"""
self.obfuscate = False
self.reject_media = False
self.reject_reports = False
self.id = None
self.severity: str = "suspend"
self.obfuscate: bool = False
self.reject_media: bool = False
self.reject_reports: bool = False
self.id: Union[int, None] = None
self.domain: str = ""
self.private_comment: str = ""
self.public_comment: str = ""
self.parse_block(instance_dict)
@@ -35,8 +41,8 @@ class Instance:
# this specifies possible properties and default values if not found on the remote source. If a default is None
# the value is required and the parse will fail
properties_and_defaults = [("domain", None), ("severity", "suspend"), ("public_comment", ""),
("private_comment", ""), ("obfuscate", False), ("reject_media", True),
("reject_reports", True)]
("private_comment", ""), ("obfuscate", False), ("reject_media", False),
("reject_reports", False)]
for key, default in properties_and_defaults:
try:
setattr(self, key, instance_dict[key])
@@ -51,6 +57,7 @@ class Instance:
headers = {
f'Authorization': f'Bearer {token}',
}
# As long as we generate this enside of apply we cannot properly test for the correct format
data = {"domain": self.domain,
"severity": self.severity,
"reject_media": str(self.reject_media).lower(),