Skip to content

Commit

Permalink
ReferentiedataTest versimpeld
Browse files Browse the repository at this point in the history
  • Loading branch information
sTomerG committed Jun 28, 2024
1 parent 1d1d543 commit c54e5ae
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions src/vera_testframework/pyspark/referentiedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
class ReferentiedataTest(ValidCategory): # type: ignore
"""
Initialize a ReferentiedataTest instance.
Args:
name (Optional[str]): The name of the test. If not provided, defaults to "VERAStandaard".
soort (str): The type/category of the data, which will be converted to uppercase.
attribuut (Literal["Code", "Naam"]): The attribute to use, either "Code" or "Naam". It will be capitalized.
Raises:
TypeError: If soort is not a string.
ValueError: If attribuut is not "Code" or "Naam".
"""

with open(
Expand All @@ -26,8 +29,13 @@ def __init__(
soort: str,
attribuut: Literal["Code", "Naam"],
):
self.soort = soort
self.attribuut = attribuut
if not isinstance(soort, str):
raise TypeError("soort must be a string")
if attribuut not in ["Code", "Naam"]:
raise ValueError("attribuut must be either 'Code' or 'Naam'")

self.soort = soort.upper()
self.attribuut = attribuut.capitalize()

name = name if name else "VERAStandaard"
super().__init__(name=name, categories=self._categorieen())
Expand All @@ -44,26 +52,6 @@ def _categorieen(self) -> set[str]:

return {row[self.attribuut] for row in categorieen_rows}

@property
def soort(self) -> str:
return self._soort

@soort.setter
def soort(self, value: str) -> None:
if not isinstance(value, str):
raise TypeError("soort must be a string")
self._soort = value.upper()

@property
def attribuut(self) -> str:
return self._attribuut

@attribuut.setter
def attribuut(self, value: Literal["Code", "Naam"]) -> None:
if value not in ["Code", "Naam"]:
raise ValueError("attribuut must be either 'Code' or 'Naam'")
self._attribuut = value.capitalize()

def __str__(self) -> str:
return f"ReferentiedataTest({self.soort}, {self.attribuut})"

Expand Down

0 comments on commit c54e5ae

Please sign in to comment.