Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Signed-off-by: hoangtungdinh <[email protected]>
  • Loading branch information
hoangtungdinh committed Sep 30, 2024
1 parent cff304e commit a35f7e0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
12 changes: 8 additions & 4 deletions qc_baselib/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from dataclasses import dataclass
from typing import Union, List, Set
from lxml import etree
from datetime import datetime

from qc_baselib import Configuration
from .models import IssueSeverity, StatusType, result, common
Expand Down Expand Up @@ -48,7 +49,6 @@ class Result:
result.register_checker_bundle(
name="TestBundle",
build_date="2024-05-31",
description="Example checker bundle",
version="0.0.1",
)
Expand All @@ -65,7 +65,7 @@ class Result:
result.load_from_file(RESULT_FILE_PATH)
version = result.get_version()
version = result.get_result_version()
```
For more information regarding the results report XSD schema you can check
Expand Down Expand Up @@ -321,14 +321,18 @@ def _get_issue(

def register_checker_bundle(
self,
build_date: str,
description: str,
name: str,
version: str,
build_date: Union[None, str] = None,
summary: str = "",
) -> None:
bundle = result.CheckerBundleType(
build_date=build_date,
build_date=(
build_date
if build_date is not None
else datetime.today().strftime("%Y-%m-%d")
),
description=description,
name=name,
version=version,
Expand Down
19 changes: 18 additions & 1 deletion tests/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import pytest
from lxml import etree
from pydantic_core import ValidationError
from qc_baselib.models import config, result
from datetime import datetime
from qc_baselib.models import result
from qc_baselib import Result, IssueSeverity, StatusType, Configuration


Expand Down Expand Up @@ -1503,3 +1504,19 @@ def test_create_rule_id_validation() -> None:
checker_id="TestChecker",
rule_uid="test.com:qc:1.0.0:",
)


def test_build_date() -> None:
result = Result()

result.register_checker_bundle(
name="TestBundle",
description="Example checker bundle",
version="0.0.1",
)

checker_bundle_result = result.get_checker_bundle_result("TestBundle")

print(checker_bundle_result.build_date)

assert checker_bundle_result.build_date == datetime.now().strftime("%Y-%m-%d")

0 comments on commit a35f7e0

Please sign in to comment.