|
| 1 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
1 | 4 | import pytest
|
2 | 5 | from pathlib import Path
|
3 | 6 |
|
@@ -65,3 +68,37 @@ def test_verify_snippet_start_end(file_contents: str, expected_error_count: int)
|
65 | 68 | _, errors = snippets.parse_snippets(file_contents.split("\n"), Path("test"), "")
|
66 | 69 | error_count = len(errors)
|
67 | 70 | assert error_count == expected_error_count
|
| 71 | + |
| 72 | + |
| 73 | +def test_strip_snippet_tags(): |
| 74 | + assert ["Line A", "Line C"] == snippets.strip_snippet_tags( |
| 75 | + [ |
| 76 | + "Line A", |
| 77 | + "# snippet-start:[line b]", |
| 78 | + "Line C", |
| 79 | + "# snippet-end:[line d]", |
| 80 | + "line E # snippet-end", |
| 81 | + ] |
| 82 | + ) |
| 83 | + |
| 84 | + |
| 85 | +def test_strip_spdx_header(): |
| 86 | + assert ["Line A", "Line B"] == snippets.strip_spdx_header( |
| 87 | + [ |
| 88 | + "# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.", |
| 89 | + "# SPDX-License-Identifier: Apache-2.0", |
| 90 | + "Line A", |
| 91 | + "Line B", |
| 92 | + ] |
| 93 | + ) |
| 94 | + assert ["Line A", "Line B"] == snippets.strip_spdx_header( |
| 95 | + [ |
| 96 | + "# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.", |
| 97 | + "# SPDX-License-Identifier: Apache-2.0", |
| 98 | + "", |
| 99 | + "Line A", |
| 100 | + "Line B", |
| 101 | + ] |
| 102 | + ) |
| 103 | + |
| 104 | + assert [] == snippets.strip_spdx_header([]) |
0 commit comments