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

feat: 295 monorepo directory structure design proposal #389

Merged
merged 137 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
01fea64
initial directory structure organization
hbraswelrh Nov 12, 2024
ec67718
feat: initial work on config and common options
gvauter Nov 13, 2024
a1984a5
chore: add openssf scorecard workflow (#359)
jpower432 Nov 14, 2024
cc569d5
build(deps): bump compliance-trestle from 3.4.0 to 3.5.0 (#380)
dependabot[bot] Nov 14, 2024
c5b9418
feat: adds logic to load yaml config into click context to set defaut…
gvauter Nov 15, 2024
c6a2569
feat: adds debug logging statements
gvauter Nov 15, 2024
78fd113
feat: add markdown directory creation and call to compliance trestle …
gvauter Nov 15, 2024
6be37e8
feat: simplify directory creation and better error handling for inval…
gvauter Nov 20, 2024
45fc4b8
feat: initial work on autosync
qduanmu Nov 20, 2024
a239482
Initial create command for click cli
hbraswelrh Nov 20, 2024
5931b5c
Initial create command for click cli
hbraswelrh Nov 20, 2024
1ba1010
adding unit test for config module
gvauter Nov 20, 2024
7645fbe
adding unit test for config module
gvauter Nov 20, 2024
268c558
Update autosync command
qduanmu Nov 21, 2024
823e5bc
Update autosync command
qduanmu Nov 21, 2024
000e26e
feat: add ssp index option
gvauter Nov 21, 2024
5aeb27d
feat: add ssp index option
gvauter Nov 21, 2024
362faf1
add unit tests for init command
gvauter Nov 21, 2024
75fd0c1
add unit tests for init command
gvauter Nov 21, 2024
59da2c8
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
gvauter Nov 21, 2024
7f266f0
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
gvauter Nov 21, 2024
1382cdc
feat: root call create and logging replacement
hbraswelrh Nov 21, 2024
3292aa5
feat: root call create and logging replacement
hbraswelrh Nov 21, 2024
0a12ef9
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Nov 21, 2024
89de0ce
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Nov 21, 2024
d41e017
feat: add upstream commands, fix common options decorators, expand co…
gvauter Nov 24, 2024
b172bcf
feat: add upstream commands, fix common options decorators, expand co…
gvauter Nov 24, 2024
0a1c0cd
Update autosync options and add tests
qduanmu Nov 25, 2024
c4a90a8
Update autosync options and add tests
qduanmu Nov 25, 2024
05cb60a
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Nov 25, 2024
d3b7215
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Nov 25, 2024
3725e7e
docs: adr-001 cli implementation (#347)
gvauter Nov 26, 2024
ed11e85
feat: add logic to make_config for nested upstream model and update r…
gvauter Nov 26, 2024
8f34874
feat: add logic to make_config for nested upstream model and update r…
gvauter Nov 26, 2024
2a3845d
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
gvauter Nov 26, 2024
f50c39d
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
gvauter Nov 26, 2024
b3ba8de
feat: create command logic for compdef and ssp
hbraswelrh Nov 26, 2024
ffae2e8
feat: create command logic for compdef and ssp
hbraswelrh Nov 26, 2024
3b63750
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Nov 26, 2024
b97d7fa
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Nov 26, 2024
9284ad8
feat: create command updates to prompts and logger messages
hbraswelrh Nov 26, 2024
92092a7
feat: create command updates to prompts and logger messages
hbraswelrh Nov 26, 2024
3c13ad6
feat: add default git info to init prompts and config
gvauter Nov 27, 2024
3a9a7c3
feat: add default git info to init prompts and config
gvauter Nov 27, 2024
a4dbaa6
fix hidden keep file creation
gvauter Nov 27, 2024
7d3b9e3
fix hidden keep file creation
gvauter Nov 27, 2024
1206a16
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
gvauter Nov 27, 2024
1b5566e
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
gvauter Nov 27, 2024
8fe0747
Add rule-transform command and unit test
qduanmu Nov 27, 2024
4484a56
Add rule-transform command and unit test
qduanmu Nov 27, 2024
74dd43d
feat: create command logic and adding unit tests
hbraswelrh Nov 27, 2024
17d524a
feat: create command logic and adding unit tests
hbraswelrh Nov 27, 2024
c628013
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Nov 27, 2024
cf044da
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Nov 27, 2024
d21f5f6
Fix AttributeError, some misc updates
qduanmu Nov 29, 2024
df0e5d2
Fix AttributeError, some misc updates
qduanmu Nov 29, 2024
aef085f
feat: unit tests added for create command
hbraswelrh Dec 2, 2024
dbf9fa2
feat: unit tests added for create command
hbraswelrh Dec 2, 2024
7bca6cd
refactor sync upstreams and autosync to match existing entrypoint syntax
gvauter Dec 3, 2024
40d6009
refactor sync upstreams and autosync to match existing entrypoint syntax
gvauter Dec 3, 2024
486ad1e
Fix AttributeError, some misc updates
qduanmu Nov 29, 2024
fb36a11
Fix AttributeError, some misc updates
qduanmu Nov 29, 2024
742cef9
feat: unit tests added for create command
hbraswelrh Dec 2, 2024
026657c
feat: unit tests added for create command
hbraswelrh Dec 2, 2024
f9a2bca
fix: docstrings added for create command unit tests
hbraswelrh Dec 3, 2024
ee0feec
fix: docstrings added for create command unit tests
hbraswelrh Dec 3, 2024
8f68749
refactor sync upstreams and autosync to match existing entrypoint syntax
gvauter Dec 3, 2024
39ebbab
refactor sync upstreams and autosync to match existing entrypoint syntax
gvauter Dec 3, 2024
ec2d3f6
refactor sync upstreams and autosync to match existing entrypoint syntax
gvauter Dec 3, 2024
f439a6e
refactor sync upstreams and autosync to match existing entrypoint syntax
gvauter Dec 3, 2024
9164f41
fix: docstrings added for create unit tests
hbraswelrh Dec 3, 2024
fc49a30
fix: docstrings added for create unit tests
hbraswelrh Dec 3, 2024
ef31702
add file pattern filter
gvauter Dec 3, 2024
39ded49
add file pattern filter
gvauter Dec 3, 2024
f352487
fix: updated headers with license and copyright
hbraswelrh Dec 3, 2024
3c094d2
fix: updated headers with license and copyright
hbraswelrh Dec 3, 2024
9fd8c3b
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Dec 3, 2024
d31e2c0
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Dec 3, 2024
170cfbc
fix: updated logger statements
hbraswelrh Dec 3, 2024
afa3f8e
fix: updated logger statements
hbraswelrh Dec 3, 2024
fa13754
fix: logger statements shortened
hbraswelrh Dec 3, 2024
a11615f
fix: logger statements shortened
hbraswelrh Dec 3, 2024
0ca9439
fix: yaml default deletion
hbraswelrh Dec 3, 2024
799b0ec
fix: yaml default deletion
hbraswelrh Dec 3, 2024
99915e4
docs: updates to reference the CLI commands in the README.md
hbraswelrh Dec 3, 2024
a44aa80
docs: updates to reference the CLI commands in the README.md
hbraswelrh Dec 3, 2024
f9feb88
feat: update for required ssp name
hbraswelrh Dec 3, 2024
8dbe4e3
feat: update for required ssp name
hbraswelrh Dec 3, 2024
91d115c
Update trestlebot/cli/commands/init.py
gvauter Dec 3, 2024
d6356c0
Update trestlebot/cli/commands/init.py
gvauter Dec 3, 2024
c6b5560
Update trestlebot/cli/commands/init.py
gvauter Dec 3, 2024
cba3776
Update trestlebot/cli/commands/init.py
gvauter Dec 3, 2024
5f456a8
fix typo in error msg
gvauter Dec 3, 2024
f72483d
fix typo in error msg
gvauter Dec 3, 2024
7bac602
fix help text for sync upstreams
gvauter Dec 3, 2024
f8c12b7
fix help text for sync upstreams
gvauter Dec 3, 2024
fa1466c
fix: update for help text and testing location errors
hbraswelrh Dec 3, 2024
8133f73
fix: update for help text and testing location errors
hbraswelrh Dec 3, 2024
d1cbc0b
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Dec 3, 2024
2df503b
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Dec 3, 2024
be89e66
fix: update for clarity on profile name for trestle workspace
hbraswelrh Dec 4, 2024
4c5a7e2
fix: update for clarity on profile name for trestle workspace
hbraswelrh Dec 4, 2024
f6fcf2d
Fix AssertionError, add missing register
qduanmu Dec 4, 2024
1669ea8
Fix AssertionError, add missing register
qduanmu Dec 4, 2024
e09b455
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Dec 4, 2024
562da56
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
hbraswelrh Dec 4, 2024
80cd9cc
fix: profile name prompting update
hbraswelrh Dec 4, 2024
4226a86
fix: profile name prompting update
hbraswelrh Dec 4, 2024
877ac9a
feat: updating compdef list to required
hbraswelrh Dec 4, 2024
66f55c7
feat: updating compdef list to required
hbraswelrh Dec 4, 2024
db34e53
docs: change of verbiage for readability
hbraswelrh Dec 4, 2024
dfc0aba
docs: change of verbiage for readability
hbraswelrh Dec 4, 2024
5c5a17a
docs: change to indicate trestle-bot as a cli tool
hbraswelrh Dec 4, 2024
230568d
docs: change to indicate trestle-bot as a cli tool
hbraswelrh Dec 4, 2024
0e31aa8
feat: change to help description of create command
hbraswelrh Dec 4, 2024
143b92a
feat: change to help description of create command
hbraswelrh Dec 4, 2024
88da512
docs: added high level folder structure for cli
hbraswelrh Dec 6, 2024
553ad1d
docs: added high level folder structure for cli
hbraswelrh Dec 6, 2024
7711aec
fix: default value returned if no key in dictionary
hbraswelrh Dec 11, 2024
b3b8ebd
fix: default value returned if no key in dictionary
hbraswelrh Dec 11, 2024
826a8f5
feat: align skip-item option to skip-items
qduanmu Dec 13, 2024
5144e10
feat: align skip-item option to skip-items
qduanmu Dec 13, 2024
84c38ba
fix: add missing git options in create command
qduanmu Dec 16, 2024
06e574b
fix: add missing git options in create command
qduanmu Dec 16, 2024
ddff735
fix: refactor testt and remove prompts
gvauter Dec 17, 2024
6e28c41
fix: refactor testt and remove prompts
gvauter Dec 17, 2024
e47dca5
fix: formatting issues and typos
gvauter Dec 17, 2024
f125d5f
fix: formatting issues and typos
gvauter Dec 17, 2024
fd2f738
chore: merge latest from main and fix conflicts
gvauter Dec 17, 2024
3b95d76
chore: merge latest from main and fix conflicts
gvauter Dec 17, 2024
954d38a
chore: update poetry lock with latest dependencies
gvauter Dec 17, 2024
586bfca
chore: update poetry lock with latest dependencies
gvauter Dec 17, 2024
1f6f6c6
fix: do not overwrite config path if set
gvauter Dec 17, 2024
ceb084c
fix: do not overwrite config path if set
gvauter Dec 17, 2024
769d0df
fix: do not overwrite config path if set
gvauter Dec 17, 2024
18eaf09
fix: do not overwrite config path if set
gvauter Dec 17, 2024
32a4132
Merge branch '295-monorepo-directory-structure-design-proposal' of gi…
gvauter Dec 18, 2024
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
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ For workflow diagrams, see the [diagrams](./docs/workflows/) under the `docs` fo
#### Code structure

- `actions` - Provides specific logic for `trestle-bot` tasks that are packaged as Actions. See [README.md](./actions/README.md) for more information.
- `entrypoints` - Provides top level logic for specific user-facing tasks. These tasks are not necessarily related in any way so they are not organized into a hierarchical command structure, but they do inherit logic and flags from a base class.
- `cli` - Provides top level logic for specific user-facing tasks. These tasks are not necessarily related so they are not organized into a hierarchical command structure, but they do share some common modules.
- `cli/commands` - Provides top level logic for commands and their associated subcommands. The commands are accessed by the single entrypoint `root.py`.
- `cli/options` - Provides command line options and arguments that are frequently used within `cli/commands`.
- `provider.py, github.py, and gitlab.py` - Git provider abstract class and concrete implementations for interacting with the API.
- `tasks` - Pre-tasks can be configured before the main git logic is run. Any task that does workspace management should go here.
- `tasks/authored` - The `authored` package contains logic for managing authoring tasks for single instances of a top-level OSCAL model. These encapsulate logic from the `compliance-trestle` library and allows loose coupling between `tasks` and `authored` types.
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@



trestle-bot assists users in leveraging [Compliance-Trestle](https://github.com/oscal-compass/compliance-trestle) in CI/CD workflows for [OSCAL](https://github.com/usnistgov/OSCAL) formatted compliance content management.
trestle-bot is a CLI tool that assists users in leveraging [Compliance-Trestle](https://github.com/oscal-compass/compliance-trestle) in CI/CD workflows for [OSCAL](https://github.com/usnistgov/OSCAL) formatted compliance content management.

> WARNING: This project is currently under initial development. APIs may be changed incompatibly from one commit to another.

## Getting Started

### Available Commands

The `autosync` command will sync trestle-generated Markdown files to OSCAL JSON files in a trestle workspace. All content under the provided markdown directory when the action is run will be transformed. This action supports all top-level models [supported by compliance-trestle for authoring](https://oscal-compass.github.io/compliance-trestle/tutorials/ssp_profile_catalog_authoring/ssp_profile_catalog_authoring/).
The `autosync` command will sync trestle-generated Markdown files to OSCAL JSON files in a trestle workspace. All content under the provided markdown directory will be transformed when the action is run. This action supports all top-level models [supported by compliance-trestle for authoring](https://oscal-compass.github.io/compliance-trestle/tutorials/ssp_profile_catalog_authoring/ssp_profile_catalog_authoring/).

The `rules-transform` command can be used when managing [OSCAL Component Definitions](https://pages.nist.gov/OSCAL-Reference/models/v1.1.1/component-definition/json-outline/) in a trestle workspace. The action will transform rules defined in the rules YAML view to an OSCAL Component Definition JSON file.

The `create-cd` command can be used to create a new [OSCAL Component Definition](https://pages.nist.gov/OSCAL-Reference/models/v1.1.1/component-definition/json-outline/) in a trestle workspace. The action will create a new Component Definition JSON file and corresponding directories that contain rules YAML files and trestle-generated Markdown files. This action prepares the workspace for use with the `rules-transform` and `autosync` actions.
The `create compdef` command can be used to create a new [OSCAL Component Definition](https://pages.nist.gov/OSCAL-Reference/models/v1.1.1/component-definition/json-outline/) in a trestle workspace. The action will create a new Component Definition JSON file and corresponding directories that contain rules YAML files and trestle-generated Markdown files. This action prepares the workspace for use with the `rules-transform` and `autosync` actions.

The `sync-upstreams` command can be used to sync and validate upstream OSCAL content stored in a git repository to a local trestle workspace. Which content is synced is determined by the `include_model_names` and `exclude_model_names` inputs.
The `sync-upstreams` command can be used to sync and validate upstream OSCAL content stored in a git repository to a local trestle workspace. The inputs `include_models` and `exclude_models` determine which content is synced to the trestle workspace.

The `create-ssp` command can be used to create a new [OSCAL System Security Plans](https://pages.nist.gov/OSCAL-Reference/models/v1.1.1/system-security-plan/json-outline/) (SSP) in a trestle workspace. The action will create a new SSP JSON file and corresponding directories that contain trestle-generated Markdown files. This action prepares the workspace for use with the `autosync` action by creating or updating the `ssp-index.json` file. The `ssp-index.json` file is used to track the relationships between the SSP and the other OSCAL content in the workspace for the `autosync` action.
The `create ssp` command can be used to create a new [OSCAL System Security Plans](https://pages.nist.gov/OSCAL-Reference/models/v1.1.1/system-security-plan/json-outline/) (SSP) in a trestle workspace. The action will create a new SSP JSON file and corresponding directories that contain trestle-generated Markdown files. This action prepares the workspace for use with the `autosync` action by creating or updating the `ssp-index.json` file. The `ssp-index.json` file is used to track the relationships between the SSP and the other OSCAL content in the workspace for the `autosync` action.

Below is a table of the available commands and their current availability as a GitHub Action:

| Command | Available as a GitHub Action |
|--------------------|------------------------------|
| `autosync` | ✓ |
| `rules-transform` | ✓ |
| `create-cd` | ✓ |
| `sync-upstreams` | ✓ |
| `create-ssp` | |
| Command | Available as a GitHub Action |
|-------------------|------------------------------|
| `autosync` | ✓ |
| `rules-transform` | ✓ |
| `create compdef` | ✓ |
| `sync-upstreams` | ✓ |
| `create ssp` | |

For detailed documentation on how to use each action, see the README.md in each folder under [actions](./actions/).

Expand All @@ -47,7 +47,7 @@ provider information is supported for GitHub Actions (GitHub) and GitLab CI (Git

### Run as a Container

> Note: When running the commands in a container, all are prefixed with `trestlebot` (e.g. `trestlebot-autosync`). The default entrypoint for the container is the autosync command.
> Note: When running the commands in a container, all are prefixed with `trestlebot` (e.g. `trestlebot autosync`). The default entrypoint for the container is the autosync command.

Build and run the container locally:

Expand All @@ -72,4 +72,4 @@ This project is licensed under the Apache 2.0 License - see the [LICENSE.md](LIC

## Troubleshooting

See [TROUBLESHOOTING.md](./TROUBLESHOOTING.md) for troubleshooting tips.
See [TROUBLESHOOTING.md](./TROUBLESHOOTING.md) for troubleshooting tips.
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ flake8-print = "^5.0.0"
pre-commit = "^3.4.0"
mkdocs-material = "^9.5.43"
markdown-include = "^0.8.1"
types-pyyaml = "^6.0.12.20240917"

[tool.poetry.group.tests]
optional = true
Expand Down
94 changes: 94 additions & 0 deletions tests/trestlebot/cli/test_autosync_cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Red Hat, Inc.


"""Testing module for trestlebot autosync command"""
import pathlib
from typing import Tuple

from click.testing import CliRunner
from git import Repo

from trestlebot.cli.commands.autosync import autosync_cmd
from trestlebot.cli.config import TrestleBotConfig, write_to_file


def test_invalid_oscal_model(tmp_repo: Tuple[str, Repo]) -> None:
"""Test invalid OSCAl model option."""

repo_path, _ = tmp_repo
runner = CliRunner()
result = runner.invoke(
autosync_cmd,
[
"--oscal-model",
"invalid",
"--repo-path",
repo_path,
"--markdown-dir",
"markdown",
"--branch",
"main",
"--committer-name",
"Test User",
"--committer-email",
"[email protected]",
],
)
assert "Invalid value for '--oscal-model'" in result.output
assert result.exit_code == 2


def test_missing_ssp_index_file_option(tmp_repo: Tuple[str, Repo]) -> None:
"""Test missing ssp_index_file option for autosync ssp."""
repo_path, _ = tmp_repo
runner = CliRunner()
cmd_options = [
"--oscal-model",
"ssp",
"--repo-path",
repo_path,
"--markdown-dir",
"markdown",
"--branch",
"main",
"--committer-name",
"Test User",
"--committer-email",
"[email protected]",
]
result = runner.invoke(autosync_cmd, cmd_options)
assert result.exit_code == 1
assert "Missing option '--ssp-index-file'" in result.output


def test_missing_markdown_dir_option(tmp_repo: Tuple[str, Repo]) -> None:
# When no markdown_dir setting in trestlebot config file.
repo_path, _ = tmp_repo
runner = CliRunner()
filepath = pathlib.Path(repo_path).joinpath("config.yml")
config_obj = TrestleBotConfig(repo_path=repo_path)
write_to_file(config_obj, filepath)
cmd_options = [
"--oscal-model",
"compdef",
"--repo-path",
repo_path,
"--branch",
"main",
"--committer-name",
"Test User",
"--committer-email",
"[email protected]",
"--config",
str(filepath),
]
result = runner.invoke(autosync_cmd, cmd_options)
assert result.exit_code == 2
assert "Error: Missing option '--markdown-dir'" in result.output

# With 'markdown_dir' setting in config.yml
config_obj = TrestleBotConfig(markdown_dir="markdown")
write_to_file(config_obj, filepath)
result = runner.invoke(autosync_cmd, cmd_options)
assert result.exit_code == 0
80 changes: 80 additions & 0 deletions tests/trestlebot/cli/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024 Red Hat, Inc.


"""Unit tests for CLI config module"""
import pathlib

import pytest
import yaml

from trestlebot.cli.config import (
TrestleBotConfig,
TrestleBotConfigError,
UpstreamsConfig,
load_from_file,
make_config,
write_to_file,
)


@pytest.fixture
def config_obj() -> TrestleBotConfig:
return TrestleBotConfig(
repo_path="/tmp",
markdown_dir="markdown",
upstreams=UpstreamsConfig(sources=["repo@main"]),
)


def test_invalid_config_raises_errors() -> None:
"""Test create config with invalid directory to raise error."""

with pytest.raises(TrestleBotConfigError) as ex:
_ = make_config(dict(repo_path="0"))

assert (
str(ex.value)
== "Invalid config value for repo_path. Path does not point to a directory."
)


def test_make_config_raises_no_errors(tmp_init_dir: str) -> None:
"""Test create a valid config object."""
values = {
"repo_path": tmp_init_dir,
"markdown_dir": "markdown",
"committer_name": "committer-name",
"committer_email": "committer-email",
"upstreams": {"sources": ["https://test@main"], "skip_validation": True},
}
config = make_config(values)
assert isinstance(config, TrestleBotConfig)
assert config.upstreams is not None
assert config.upstreams.sources == ["https://test@main"]
assert config.upstreams.skip_validation is True
assert config.repo_path == pathlib.Path(tmp_init_dir)
assert config.markdown_dir == values["markdown_dir"]
assert config.committer_name == values["committer_name"]
assert config.committer_email == values["committer_email"]


def test_config_write_to_file(config_obj: TrestleBotConfig, tmp_init_dir: str) -> None:
"""Test config is written to yaml file."""
filepath = pathlib.Path(tmp_init_dir).joinpath("config.yml")
write_to_file(config_obj, filepath)
with open(filepath, "r") as f:
yaml_data = yaml.safe_load(f)

assert yaml_data == config_obj.to_yaml_dict()


def test_config_load_from_file(config_obj: TrestleBotConfig, tmp_init_dir: str) -> None:
"""Test config is read from yaml file into config object."""
filepath = pathlib.Path(tmp_init_dir).joinpath("config.yml")
with filepath.open("w") as config_file:
yaml.dump(config_obj.to_yaml_dict(), config_file)

config = load_from_file(filepath)
assert isinstance(config, TrestleBotConfig)
assert config == config_obj
Loading
Loading