Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add testplan version to report info section #1158

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"pandas", # required by plotly.express
"rpyc",
"matplotlib",
"memoization",
"coverage",
"typing_extensions",
"dill",
Expand Down
4 changes: 2 additions & 2 deletions testplan/common/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
import contextlib
import tempfile
import hashlib
from functools import lru_cache
from io import TextIOWrapper

from testplan.common.utils.context import render
from memoization import cached
from .strings import slugify

VAR_TMP = os.path.join(os.sep, "var", "tmp")


@cached
@lru_cache(None)
def fix_home_prefix(path):
"""
Try to replace a real path (/a/path/user) with a symlink
Expand Down
2 changes: 1 addition & 1 deletion testplan/report/testing/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Meta:
meta = fields.Dict()
label = fields.String(allow_none=True)
tags_index = TagField(dump_only=True)
information = fields.List(fields.List(fields.String()))
information = fields.List(fields.Tuple([fields.String(), fields.String()]))
resource_meta_path = fields.String(dump_only=True, allow_none=True)
counter = fields.Dict(dump_only=True)

Expand Down
7 changes: 7 additions & 0 deletions testplan/runnable/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ def __init__(self, **options):
uid=self.cfg.name,
timeout=self.cfg.timeout,
label=self.cfg.label,
information=[("testplan_version", self.get_testplan_version())],
)
self._exporters = None
self._web_server_thread = None
Expand All @@ -440,6 +441,12 @@ def __init__(self, **options):
def __str__(self):
return f"Testplan[{self.uid()}]"

@staticmethod
def get_testplan_version():
import testplan

return testplan.__version__

@property
def report(self) -> TestReport:
"""Tests report."""
Expand Down
35 changes: 13 additions & 22 deletions testplan/testing/base.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
"""Base classes for all Tests"""
import functools
import os
import re
import subprocess
import sys
import warnings
from enum import Enum
from schema import And, Or, Use
from typing import (
Callable,
Dict,
Generator,
Iterable,
List,
Optional,
Union,
Callable,
Iterable,
Type,
Tuple,
Type,
Union,
)

import plotly.express as px
from schema import And, Or, Use

from testplan import defaults
from testplan.common.config import ConfigOption, validate_func
from testplan.common.entity import (
Resource,
ResourceStatus,
ResourceTimings,
Runnable,
RunnableConfig,
RunnableResult,
ResourceTimings,
)
from testplan.common.remote.remote_driver import RemoteDriver
from testplan.common.utils import strings, interface, validation
from testplan.common.report import ReportCategories, RuntimeStatus
from testplan.common.report import Status as ReportStatus
from testplan.common.utils import interface, strings, validation
from testplan.common.utils.composer import compose_contexts
from testplan.common.utils.context import render
from testplan.common.utils.process import (
Expand All @@ -40,24 +42,13 @@
subprocess_popen,
)
from testplan.common.utils.timing import format_duration, parse_duration
from testplan.common.report import (
Status as ReportStatus,
ReportCategories,
RuntimeStatus,
)
from testplan.report import (
TestCaseReport,
TestGroupReport,
test_styles,
)
from testplan.testing import common, filtering, ordering, tagging, result
from testplan.report import TestCaseReport, TestGroupReport, test_styles
from testplan.testing import common, filtering, ordering, result, tagging
from testplan.testing.environment import TestEnvironment, parse_dependency
from testplan.testing.multitest.driver.connection import DriverConnectionGraph
from testplan.testing.multitest.entries.assertions import RawAssertion
from testplan.testing.multitest.entries.base import Attachment
from testplan.testing.multitest.test_metadata import TestMetadata
from testplan.testing.multitest.driver.connection import DriverConnectionGraph

from testplan.testing.multitest import result

TEST_INST_INDENT = 2
SUITE_INDENT = 4
Expand Down
4 changes: 4 additions & 0 deletions tests/functional/testplan/exporters/testing/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pathlib
import tempfile

import testplan
from testplan import TestplanMock
from testplan.common.utils.testing import argv_overridden
from testplan.exporters.testing import JSONExporter
Expand Down Expand Up @@ -77,6 +78,9 @@ def test_split_and_merge(runpath):
copy.deepcopy(report)
)
assert "information" in meta
assert (
dict(meta["information"])["testplan_version"] == testplan.__version__
)
assert meta["entries"] == []
assert (
JSONExporter.merge_json_report(meta, structure, assertions) == report
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/testplan/runnable/interactive/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ def test_put_filtered(self, api_env):
json_report[
"runtime_status"
] = report.RuntimeStatus.RUNNING.to_json_compatible()
json_report["information"] = [
list(t) for t in json_report["information"]
]
rsp = client.put("/api/v1/interactive/report", json=json_report)
assert rsp.status_code == 200

Expand Down
Loading