diff --git a/tests/plan/export/data/plan.fmf b/tests/plan/export/data/plan.fmf index 3a493ae7e5..6477058e4b 100644 --- a/tests/plan/export/data/plan.fmf +++ b/tests/plan/export/data/plan.fmf @@ -25,3 +25,9 @@ execute: - merge-pull-request - add-build-to-update - add-build-to-compose + +/remote: + plan: + import: + url: https://github.com/teemtee/tmt + name: /plans/features/basic diff --git a/tests/plan/export/test.sh b/tests/plan/export/test.sh index c996af9ae6..06c18bf3b4 100755 --- a/tests/plan/export/test.sh +++ b/tests/plan/export/test.sh @@ -16,6 +16,7 @@ rlJournalStart rlAssertGrep "- name: /plan/gate" $rlRun_LOG rlAssertGrep "discover:" $rlRun_LOG rlAssertGrep "execute:" $rlRun_LOG + rlAssertNotGrep " _" $rlRun_LOG rlPhaseEnd rlPhaseStartTest "tmt plan export /plan/basic" @@ -24,6 +25,7 @@ rlJournalStart rlAssertGrep "summary: Just basic keys." $rlRun_LOG rlAssertGrep "discover:" $rlRun_LOG rlAssertGrep "execute:" $rlRun_LOG + rlAssertNotGrep " _" $rlRun_LOG rlPhaseEnd rlPhaseStartTest "tmt plan export /plan/context" @@ -34,6 +36,7 @@ rlJournalStart rlAssertGrep "execute:" $rlRun_LOG rlAssertGrep "context:" $rlRun_LOG rlAssertGrep "component: dash" $rlRun_LOG + rlAssertNotGrep " _" $rlRun_LOG rlPhaseEnd rlPhaseStartTest "tmt plan export /plan/environment" @@ -44,6 +47,7 @@ rlJournalStart rlAssertGrep "execute:" $rlRun_LOG rlAssertGrep "environment:" $rlRun_LOG rlAssertGrep "RELEASE: f35" $rlRun_LOG + rlAssertNotGrep " _" $rlRun_LOG rlPhaseEnd rlPhaseStartTest "tmt plan export /plan/gate" @@ -56,6 +60,7 @@ rlJournalStart rlAssertGrep "- merge-pull-request" $rlRun_LOG rlAssertGrep "- add-build-to-update" $rlRun_LOG rlAssertGrep "- add-build-to-compose" $rlRun_LOG + rlAssertNotGrep " _" $rlRun_LOG rlPhaseEnd rlPhaseStartTest "Invalid format" diff --git a/tests/story/export/test.sh b/tests/story/export/test.sh index df0db7efa5..b6ca50fab6 100755 --- a/tests/story/export/test.sh +++ b/tests/story/export/test.sh @@ -11,6 +11,7 @@ rlJournalStart rlAssertGrep "name: /mini" $rlRun_LOG rlAssertGrep "order: 50" $rlRun_LOG rlAssertGrep "story: As a user I want this and that" $rlRun_LOG + rlAssertNotGrep " _" $rlRun_LOG rlPhaseEnd rlPhaseStartTest "Export to yaml (full story)" @@ -25,6 +26,7 @@ rlJournalStart rlAssertGrep "story: As a user I want this and that" $rlRun_LOG rlAssertGrep "title: A Concise Title" $rlRun_LOG rlAssertGrep "priority: must have" $rlRun_LOG + rlAssertNotGrep " _" $rlRun_LOG rlRun "grep -A1 ^link: $rlRun_LOG | grep -- ' - implemented-by: /some/code.py'" rlRun "grep -A1 ^tag: $rlRun_LOG | grep -- '- foo'" rlRun "grep -A1 ^example: $rlRun_LOG | grep -- '- An inspiring example'" diff --git a/tests/test/export/test.sh b/tests/test/export/test.sh index 226de9f1b1..cfb147d436 100755 --- a/tests/test/export/test.sh +++ b/tests/test/export/test.sh @@ -26,12 +26,14 @@ rlJournalStart rlPhaseStartTest "$cmd" rlRun -s "$cmd" 0 "Export test" rlAssertGrep "'name': '$tname'" $rlRun_LOG + rlAssertNotGrep "'_" $rlRun_LOG rlPhaseEnd cmd="tmt tests export --format yaml $tname" rlPhaseStartTest "$cmd" rlRun -s "$cmd" 0 "Export test" rlAssertGrep "name: $tname" $rlRun_LOG + rlAssertNotGrep " _" $rlRun_LOG rlPhaseEnd done @@ -61,12 +63,14 @@ rlJournalStart rlPhaseStartTest "$cmd" rlRun -s "$cmd" 0 "Export test" rlAssertGrep "'name': '$tname'" $rlRun_LOG + rlAssertNotGrep "'_" $rlRun_LOG rlPhaseEnd cmd="tmt tests export --format yaml --fmf-id $tname" rlPhaseStartTest "$cmd" rlRun -s "$cmd" 0 "Export test" rlAssertGrep "name: $tname" $rlRun_LOG + rlAssertNotGrep " _" $rlRun_LOG rlPhaseEnd done diff --git a/tmt/base.py b/tmt/base.py index 98e842b133..47e1d2b1a8 100644 --- a/tmt/base.py +++ b/tmt/base.py @@ -539,6 +539,12 @@ def export(self, *, format_: ExportFormat = ExportFormat.YAML, # Always include node name, add requested keys, ignore adjust data: Dict[str, Any] = dict(name=self.name) for key in keys: + # TODO: provide more mature solution for https://github.com/teemtee/tmt/issues/1688 + # Untile that, do not export fields that start with an underscore, to avoid leaking + # "private" object members. + if key.startswith('_'): + continue + if key == 'adjust': continue