Skip to content

Commit

Permalink
refactor(test_parse.py): Split render tests into their own file
Browse files Browse the repository at this point in the history
  • Loading branch information
mrwilson committed Sep 9, 2023
1 parent d76d9e1 commit 2c6b14e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 39 deletions.
41 changes: 2 additions & 39 deletions adr_viewer/test_parse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from adr_viewer import parse_adr_to_config, render_html
from adr_viewer import parse_adr_to_config


def test_should_extract_title_from_record():
Expand Down Expand Up @@ -42,49 +42,12 @@ def test_should_mark_pending_records():

assert config['status'] == 'pending'


def test_should_mark_pproposed_records():
config = parse_adr_to_config('test/adr/0004-proposed-status.md')

assert config['status'] == 'pending'

def test_should_render_html_with_project_title():
html = render_html({
'project_title': 'my-project'
})

assert '<title>ADR Viewer - my-project</title>' in html


def test_should_render_html_with_record_status():
html = render_html({
'records': [{
'status': 'accepted',
}]
})

assert '<div class="panel-heading adr-accepted">' in html


def test_should_render_html_with_record_body():
html = render_html({
'records': [{
'body': '<h1>This is my ADR</h1>',
}]
})

assert '<div class="panel-body"><h1>This is my ADR</h1></div>' in html


def test_should_render_html_with_collapsible_index():
html = render_html({
'records': [{
'title': 'Record 123',
'index': 123
}]
})

assert '<a data-toggle="collapse" href="#collapse123">Record 123</a>' in html


def test_should_ignore_invalid_files():
config = parse_adr_to_config('test/adr/0003-bad-formatting.md')
Expand Down
40 changes: 40 additions & 0 deletions adr_viewer/test_render.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from adr_viewer import render_html


def test_should_render_html_with_project_title():
html = render_html({
'project_title': 'my-project'
})

assert '<title>ADR Viewer - my-project</title>' in html


def test_should_render_html_with_record_status():
html = render_html({
'records': [{
'status': 'accepted',
}]
})

assert '<div class="panel-heading adr-accepted">' in html


def test_should_render_html_with_record_body():
html = render_html({
'records': [{
'body': '<h1>This is my ADR</h1>',
}]
})

assert '<div class="panel-body"><h1>This is my ADR</h1></div>' in html


def test_should_render_html_with_collapsible_index():
html = render_html({
'records': [{
'title': 'Record 123',
'index': 123
}]
})

assert '<a data-toggle="collapse" href="#collapse123">Record 123</a>' in html

0 comments on commit 2c6b14e

Please sign in to comment.