Skip to content

funfedi_parsing_test_cases

activity_suite module-attribute

activity_suite = Suite(
    "Activities",
    [
        create_suite,
        activity_context_suite,
        announce_suite,
        addressing_suite,
    ],
)

Contains the activity test suite

event_suite module-attribute

event_suite = Suite(
    "Events",
    [base_event_test_suite, necessary_event_properties],
)

Contains the test suite for events

notes_suite module-attribute

notes_suite = Suite(
    "Notes", [necessary_properties_notes_cases]
)

Contains the test suite for notes

poll_suite module-attribute

poll_suite = Suite(
    "Polls",
    [
        base_poll_test_suite,
        necessary_properties_polls_cases,
        number_of_options_suite,
    ],
)

Contains the test suite for polls

Case dataclass

Represents a test case

Parameters:

Name Type Description Default
name str
required
maker Any
required
status TestCaseStatus
<TestCaseStatus.unknown: 'unknown'>
comments list[str]

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

<dynamic>
Source code in funfedi_parsing_test_cases/types.py
@dataclass
class Case:
    """Represents a test case"""

    name: str
    maker: Any
    status: TestCaseStatus = TestCaseStatus.unknown
    comments: list[str] = field(default_factory=list)

Environment dataclass

Represents the environment used to construct a test case

Parameters:

Name Type Description Default
sending_actor_profile dict
required
receiving_actor str
required
Source code in funfedi_parsing_test_cases/types.py
@dataclass
class Environment:
    """Represents the environment used to construct a test case"""

    sending_actor_profile: dict
    receiving_actor: str

    @property
    def sending_actor(self):
        result = self.sending_actor_profile.get("id")
        if not isinstance(result, str):
            raise Exception("the sending_actor_profile needs to have an id")
        return result

    def id_maker(self, prefix="objects"):
        return urljoin(self.sending_actor, f"/{prefix}/{secrets.token_urlsafe(12)}")

SubSuite dataclass

Represents a particular set of thematic tests

Parameters:

Name Type Description Default
title str
required
short_name str
required
tests list[Case]
required
description str
''
Source code in funfedi_parsing_test_cases/suite/__init__.py
@dataclass
class SubSuite:
    """Represents a particular set of thematic tests"""

    title: str
    short_name: str
    tests: list[Case]

    description: str = field(default="")

Suite

Represents the set of all tests

Source code in funfedi_parsing_test_cases/suite/__init__.py
class Suite:
    """Represents the set of all tests"""

    name: str

    tests: dict[str, list[Case]]
    test_map: dict[str, dict[str, Case]]
    titles: dict[str, str]
    sub_suites: list[SubSuite]

    def __init__(self, name: str, tests: list[SubSuite]):
        """Constructs the suite"""
        self.name = name
        self.sub_suites = tests
        self.tests = {
            sub_suite.short_name: [validate(x) for x in sub_suite.tests]
            for sub_suite in tests
        }
        self.titles = {sub_suite.short_name: sub_suite.title for sub_suite in tests}
        self.test_map = {
            name: {test_case.name: test_case for test_case in cases}
            for name, cases in self.tests.items()
        }

    def retrieve(self, name: str, test_name: str) -> Case:
        """Fora suite name and test_name gets the case"""
        return self.test_map[name][test_name]

    @property
    def names(self) -> list[tuple[str, str]]:
        """Gets the names of all tests"""
        name_map = [
            [(name, case.name) for case in cases] for name, cases in self.tests.items()
        ]

        return sum(name_map, [])

names property

names: list[tuple[str, str]]

Gets the names of all tests

__init__

__init__(name: str, tests: list[SubSuite])

Constructs the suite

Source code in funfedi_parsing_test_cases/suite/__init__.py
def __init__(self, name: str, tests: list[SubSuite]):
    """Constructs the suite"""
    self.name = name
    self.sub_suites = tests
    self.tests = {
        sub_suite.short_name: [validate(x) for x in sub_suite.tests]
        for sub_suite in tests
    }
    self.titles = {sub_suite.short_name: sub_suite.title for sub_suite in tests}
    self.test_map = {
        name: {test_case.name: test_case for test_case in cases}
        for name, cases in self.tests.items()
    }

retrieve

retrieve(name: str, test_name: str) -> Case

Fora suite name and test_name gets the case

Source code in funfedi_parsing_test_cases/suite/__init__.py
def retrieve(self, name: str, test_name: str) -> Case:
    """Fora suite name and test_name gets the case"""
    return self.test_map[name][test_name]

TestCaseStatus

Bases: StrEnum

Status of a test cases

Source code in funfedi_parsing_test_cases/types.py
class TestCaseStatus(StrEnum):
    """Status of a test cases"""

    recommended = auto()
    unknown = auto()
    may_fail = auto()
    should_fail = auto()