Skip to content

Commit 932bc5d

Browse files
committed
test: stabilize formatting and RobotLibDoc tests after Prettier/Ruff
- Align directory release notes generator expectations with Prettier markdown - Restore <!DOCTYPE html> in RobotLibDoc template (ElementTree.parse) - Add .prettierignore for template, VCR cassettes, diagram assets, Jinja templates - Normalize RobotLibDoc CSV sources and refresh page object line numbers
1 parent 0498f70 commit 932bc5d

4 files changed

Lines changed: 55 additions & 22 deletions

File tree

.prettierignore

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
Test*.yaml
1+
# Jinja-templated HTML: Prettier lowercases <!DOCTYPE>, which breaks
2+
# xml.etree.ElementTree.parse() in RobotLibDoc tests.
3+
cumulusci/tasks/robotframework/template.html
4+
5+
# VCR cassettes are YAML-shaped but not reliably parseable by Prettier's YAML
6+
# formatter (multi-line quoted bodies, anchors, etc.).
7+
**/cassettes/**
8+
9+
# Bundled third-party diagram assets (minified JS/CSS).
210
docs/diagram/
3-
**/*.min.js
4-
**/*.min.css
5-
cumulusci/files/templates/
11+
12+
# Jinja-templated JSON/YAML shipped as project templates.
13+
cumulusci/files/templates/

cumulusci/tasks/release_notes/tests/test_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_full_content(self):
8383
release_notes = DirectoryReleaseNotesGenerator(change_notes_dir)
8484

8585
content = release_notes()
86-
expected = "# Critical Changes\r\n\r\n* This will break everything!\r\n\r\n# Changes\r\n\r\nHere's something I did. It was really cool\r\nOh yeah I did something else too!\r\n\r\n# Issues Closed\r\n\r\n#2345\r\n#6236"
86+
expected = "# Critical Changes\r\n\r\n- This will break everything!\r\n\r\n# Changes\r\n\r\nHere's something I did. It was really cool\r\nOh yeah I did something else too!\r\n\r\n# Issues Closed\r\n\r\n#2345\r\n#6236"
8787
print(expected)
8888
print("-------------------------------------")
8989
print(content)

cumulusci/tasks/robotframework/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />

cumulusci/tasks/robotframework/tests/test_robotframework.py

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -486,86 +486,111 @@ def test_csv(self):
486486
reader = csv.reader(csvfile)
487487
actual_output = [row for row in reader]
488488

489+
def _resolved_source(path: str) -> str:
490+
"""Normalize RobotLibDoc CSV `Source` paths across cwd layouts.
491+
492+
Robot may emit absolute paths, cwd-relative paths, or repo-root-relative
493+
paths that include `.worktrees/...` segments. For assertions, map
494+
everything to a stable absolute path rooted at the current working
495+
directory + `cumulusci/tasks/robotframework/tests/`.
496+
"""
497+
498+
normalized = path.replace("\\", "/")
499+
tail = "cumulusci/tasks/robotframework/tests/"
500+
if tail in normalized:
501+
rest = normalized.split(tail, 1)[1]
502+
return str((Path.cwd() / tail / rest).resolve())
503+
return str(Path(path).resolve())
504+
489505
# not only does this verify that the expected keywords are in
490506
# the output, but that the base class keywords are *not*
491-
datadir = os.path.join("cumulusci", "tasks", "robotframework", "tests", "")
507+
tests_dir = Path(__file__).resolve().parent
508+
page_objects = str(tests_dir / "TestPageObjects.py")
509+
test_library = str(tests_dir / "TestLibrary.py")
510+
test_resource = str(tests_dir / "TestResource.robot")
492511
expected_output = [
493512
["Name", "Source", "Line#", "po type", "po_object", "Documentation"],
494513
[
495514
"Keyword One",
496-
f"{datadir}TestPageObjects.py",
497-
"13",
515+
page_objects,
516+
"14",
498517
"Listing",
499518
"Something__c",
500519
"",
501520
],
502521
[
503522
"Keyword One",
504-
f"{datadir}TestPageObjects.py",
505-
"24",
523+
page_objects,
524+
"25",
506525
"Detail",
507526
"Something__c",
508527
"",
509528
],
510529
[
511530
"Keyword Three",
512-
f"{datadir}TestPageObjects.py",
513-
"30",
531+
page_objects,
532+
"31",
514533
"Detail",
515534
"Something__c",
516535
"",
517536
],
518537
[
519538
"Keyword Two",
520-
f"{datadir}TestPageObjects.py",
521-
"16",
539+
page_objects,
540+
"17",
522541
"Listing",
523542
"Something__c",
524543
"",
525544
],
526545
[
527546
"Keyword Two",
528-
f"{datadir}TestPageObjects.py",
529-
"27",
547+
page_objects,
548+
"28",
530549
"Detail",
531550
"Something__c",
532551
"",
533552
],
534553
[
535554
"Library Keyword One",
536-
f"{datadir}TestLibrary.py",
555+
test_library,
537556
"13",
538557
"",
539558
"",
540559
"Keyword documentation with *bold* and _italics_",
541560
],
542561
[
543562
"Library Keyword Two",
544-
f"{datadir}TestLibrary.py",
563+
test_library,
545564
"17",
546565
"",
547566
"",
548567
"",
549568
],
550569
[
551570
"Resource keyword one",
552-
f"{datadir}TestResource.robot",
571+
test_resource,
553572
"2",
554573
"",
555574
"",
556575
"",
557576
],
558577
[
559578
"Resource keyword two",
560-
f"{datadir}TestResource.robot",
579+
test_resource,
561580
"6",
562581
"",
563582
"",
564583
"",
565584
],
566585
]
567586

568-
assert actual_output == expected_output
587+
normalized_actual = [
588+
[row[0], _resolved_source(row[1]), *row[2:]] for row in actual_output
589+
]
590+
normalized_expected = [
591+
[row[0], _resolved_source(row[1]), *row[2:]] for row in expected_output
592+
]
593+
assert normalized_actual == normalized_expected
569594

570595
@mock.patch("cumulusci.tasks.robotframework.libdoc.view_file")
571596
def test_preview_option(self, mock_view_file):

0 commit comments

Comments
 (0)