Skip to content

Commit

Permalink
Merge pull request #279 from valory-xyz/fix/doc-hash-script
Browse files Browse the repository at this point in the history
fix: improve command regex
  • Loading branch information
DavidMinarsch authored Aug 23, 2022
2 parents 7eef2ea + 2b8b7e8 commit 29e530b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/check_doc_ipfs_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


CLI_REGEX = r"(?P<cli>aea)"
CMD_REGEX = r"(?P<cmd>.*)"
CMD_REGEX = r"(?P<cmd>(?!-)\S+(\s--\S+)*)"
VENDOR_REGEX = rf"(?P<vendor>{SIMPLE_ID_REGEX})"
PACKAGE_REGEX = rf"(?P<package>{SIMPLE_ID_REGEX})"
VERSION_REGEX = r"(?P<version>\d+\.\d+\.\d+)"
Expand Down
39 changes: 39 additions & 0 deletions tests/test_scripts/test_check_doc_ipfs_hashes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2022 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""This module contains tests for the documentation tools."""

import re

from scripts.check_doc_ipfs_hashes import AEA_COMMAND_REGEX


def test_cmd_regex() -> None:
"""Test the command regex"""

lines = [
"aea fetch --remote open_aea/my_first_aea:bafybeibnjfr3sdg57ggyxbcfkh42yqkj6a3gftp55l26aaw2z2jvvc3tny",
"aea fetch open_aea/my_first_aea:bafybeibnjfr3sdg57ggyxbcfkh42yqkj6a3gftp55l26aaw2z2jvvc3tny",
"aea fetch --remote --other_flag open_aea/my_first_aea:bafybeibnjfr3sdg57ggyxbcfkh42yqkj6a3gftp55l26aaw2z2jvvc3tny",
]

for line in lines:
assert re.match(
AEA_COMMAND_REGEX, line
), f"line '{line}' does not match AEA_COMMAND_REGEX"

0 comments on commit 29e530b

Please sign in to comment.