Skip to content

Commit 8c954e1

Browse files
committed
Setup README and tests for it
1 parent dfd8696 commit 8c954e1

File tree

3 files changed

+242
-0
lines changed

3 files changed

+242
-0
lines changed

README.md

+164
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,169 @@ Used in:
2222
```shell
2323
~$ git clone https://github.com/6809/dragonlib.git
2424
~$ cd dragonlib
25+
~/dragonlib$ ./cli.py --help
26+
```
27+
Looks like:
28+
[comment]: <> (✂✂✂ auto generated main help start ✂✂✂)
29+
```
30+
Usage: ./cli.py [OPTIONS] COMMAND [ARGS]...
31+
32+
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
33+
│ --help Show this message and exit. │
34+
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
35+
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────╮
36+
│ update-readme-history Update project history base on git commits/tags in README.md │
37+
│ version Print version and exit │
38+
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
39+
```
40+
[comment]: <> (✂✂✂ auto generated main help end ✂✂✂)
41+
42+
TODO: Expand the CLI ;)
43+
44+
45+
### Development CLI
46+
47+
Start the dev CLI, e.g.:
48+
```shell
2549
~/dragonlib$ ./dev-cli.py --help
2650
```
51+
Looks like:
52+
53+
[comment]: <> (✂✂✂ auto generated dev help start ✂✂✂)
54+
```
55+
Usage: ./dev-cli.py [OPTIONS] COMMAND [ARGS]...
56+
57+
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────╮
58+
│ --help Show this message and exit. │
59+
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
60+
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────╮
61+
│ check-code-style Check code style by calling darker + flake8 │
62+
│ coverage Run tests and show coverage report. │
63+
│ fix-code-style Fix code style of all cli_base source code files via darker │
64+
│ install Run pip-sync and install 'cli_base' via pip as editable. │
65+
│ mypy Run Mypy (configured in pyproject.toml) │
66+
│ pip-audit Run pip-audit check against current requirements files │
67+
│ publish Build and upload this project to PyPi │
68+
│ test Run unittests │
69+
│ tox Run tox │
70+
│ update Update "requirements*.txt" dependencies files │
71+
│ update-test-snapshot-files Update all test snapshot files (by remove and recreate all snapshot │
72+
│ files) │
73+
│ version Print version and exit │
74+
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
75+
```
76+
[comment]: <> (✂✂✂ auto generated dev help end ✂✂✂)
77+
78+
79+
80+
## History
81+
82+
[comment]: <> (✂✂✂ auto generated history start ✂✂✂)
83+
84+
* [v0.2.0](https://github.com/6809/dragonlib/compare/v0.1.7...v0.2.0)
85+
* 2024-09-24 - Setup README and tests for it
86+
* 2024-09-24 - Add github action
87+
* 2024-09-24 - Activate pre-commit hooks on install
88+
* 2024-09-24 - Reformat with black and fix old code parts
89+
* 2024-09-24 - Add .editorconfig
90+
* 2024-09-24 - Run pyupgrade
91+
* 2024-09-24 - Modernize Project Setup
92+
* [v0.1.7](https://github.com/6809/dragonlib/compare/v0.1.6...v0.1.7)
93+
* 2015-08-21 - Bugfix logging, remove six and code cleanup
94+
* 2015-08-19 - remove obsolete code + run tests also with pypy3
95+
* [v0.1.6](https://github.com/6809/dragonlib/compare/v0.1.5...v0.1.6)
96+
* 2015-08-19 - +AUTHORS
97+
* 2015-08-19 - add test for BasicLexer
98+
* 2015-08-19 - use nose to run unittests
99+
* 2015-08-19 - update travis config
100+
* 2015-08-19 - Bugfix disable logging:
101+
* [v0.1.5](https://github.com/6809/dragonlib/compare/v0.1.4...v0.1.5)
102+
* 2015-05-26 - fixup! WIP: support PY2, too
103+
* 2015-05-26 - WIP: support PY2, too
104+
* 2015-05-26 - TODO: Add Support for Python 2 and PyPy
105+
* 2015-05-26 - disable pypy test :(
106+
107+
<details><summary>Expand older history entries ...</summary>
108+
109+
* [v0.1.4](https://github.com/6809/dragonlib/compare/v0.1.3...v0.1.4)
110+
* 2015-05-26 - bugfix for ReSt
111+
* 2015-05-26 - TODO python 2 support!
112+
* 2015-05-26 - add "publish" in setup.py
113+
* 2015-05-26 - add links to travis/coveralls
114+
* 2015-05-26 - add a AUTOLOAD.DWL for unittest
115+
* 2015-05-26 - Bugfix: don't print new lines etc.
116+
* 2015-05-26 - exclude undone test
117+
* 2015-05-26 - test_suite="dragonlib.tests.get_tests"
118+
* 2015-05-26 - update meta files
119+
* [v0.1.3](https://github.com/6809/dragonlib/compare/v0.1.2...v0.1.3)
120+
* 2014-12-15 - add a pygments lexer
121+
* 2014-11-20 - better error message
122+
* 2014-11-20 - use string.printable
123+
* [v0.1.2](https://github.com/6809/dragonlib/compare/v0.1.1...v0.1.2)
124+
* 2014-11-19 - Bugfix/enhanced the whole binary stuff and add more unittests
125+
* 2014-11-18 - WIP: add unittest for BinaryFile()
126+
* 2014-11-18 - bugfix in log_bytes()
127+
* 2014-11-18 - Bugfix parse binary files
128+
* 2014-11-17 - FIXME
129+
* 2014-11-17 - that's enough
130+
* 2014-11-17 - more robust
131+
* 2014-11-17 - less debug
132+
* 2014-11-17 - display log settings
133+
* [v0.1.1](https://github.com/6809/dragonlib/compare/5030bac...v0.1.1)
134+
* 2014-11-15 - lower some log output
135+
* 2014-11-15 - add api.bas2bin() too
136+
* 2014-11-15 - Add for converting Dragon DOS Binary to ASCII listing
137+
* 2014-11-13 - create a package
138+
* 2014-11-13 - update README
139+
* 2014-11-13 - Initial commit
140+
* 2014-11-13 - move LOG_LEVELS
141+
* 2014-09-30 - WIP: BASIC editor: reformat code
142+
* 2014-09-30 - add more info
143+
* 2014-09-30 - Bugfix
144+
* 2014-09-30 - Bugfix renum tool + renum INVADER.bas
145+
* 2014-09-30 - Bugfix if line number > $ff
146+
* 2014-09-30 - Add a more informative "display tokens" window
147+
* 2014-09-22 - Don't raise error, if dump doesn't include address...
148+
* 2014-09-22 - Better default log formatter
149+
* 2014-09-18 - change logging setup
150+
* 2014-09-13 - Update unittests in dragonlib, too.
151+
* 2014-09-13 - bugfix six.moves.xrange
152+
* 2014-09-13 - use xrange from six.py
153+
* 2014-09-12 - replace own lib2and3 with six
154+
* 2014-09-12 - WIP: refactor logging usage
155+
* 2014-09-11 - better tracebacks by using reraise
156+
* 2014-09-04 - remove from __future__ import unicode_literals
157+
* 2014-09-04 - bugfix string.letters vs. string.ascii_letters
158+
* 2014-09-03 - chnages to support python 2 and 3 with the same code
159+
* 2014-09-03 - changes to run with python2 and __future__ imports
160+
* 2014-09-03 - just run 2to3 script
161+
* 2014-08-28 - Highlight line numbers and more the just one
162+
* 2014-08-28 - First, simple code highlighting
163+
* 2014-08-28 - Don't consume spaces between line number and code
164+
* 2014-08-27 - reimplement the CLI, today only for Dragon32/64 and CoCo
165+
* 2014-08-27 - Bugfix: CoCo used the same default start address
166+
* 2014-08-27 - update CoCo tokens with Extended Color BASIC 1.1
167+
* 2014-08-20 - CoCo used a other default program start address than dragon
168+
* 2014-08-20 - + 0xff80: "SGN"
169+
* 2014-08-20 - WIP: Support CoCo in editor
170+
* 2014-08-20 - do the ' <-> :' and ELSE <-> :ELSE replacement internaly
171+
* 2014-08-20 - Use the new BASIC parser - TODO: Code cleanup!
172+
* 2014-08-20 - convert line number to int
173+
* 2014-08-20 - rename format functions
174+
* 2014-08-20 - add a BASIC parser with unittests
175+
* 2014-08-20 - code formating
176+
* 2014-08-18 - Add TODO unittests
177+
* 2014-08-18 - Better debug output
178+
* 2014-08-18 - better log output while load/inject BASIC program
179+
* 2014-08-18 - Bugfix: support ON...GOTO and ON...GOSUB in renumbering
180+
* 2014-08-17 - add another renum unittest +code cleanup
181+
* 2014-08-17 - add "renumber listing" tool in editor
182+
* 2014-08-17 - TODO: Don't replace reversed words into tokens in comments and strings.
183+
* 2014-08-16 - Bugfix in inject BASIC program:
184+
* 2014-08-16 - WIP: move dump/load stuff into editor
185+
* 2014-08-15 - WIP: start splitting project: add "dragonlib"
186+
187+
</details>
188+
189+
190+
[comment]: <> (✂✂✂ auto generated history end ✂✂✂)

dragonlib/tests/test_readme.py

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from bx_py_utils.auto_doc import assert_readme_block
2+
from bx_py_utils.path import assert_is_file
3+
from manageprojects.test_utils.click_cli_utils import invoke_click
4+
from manageprojects.tests.base import BaseTestCase
5+
6+
from dragonlib import constants
7+
from dragonlib.cli_app import cli
8+
from dragonlib.cli_dev import PACKAGE_ROOT
9+
from dragonlib.cli_dev import cli as dev_cli
10+
11+
12+
def assert_cli_help_in_readme(text_block: str, marker: str):
13+
README_PATH = PACKAGE_ROOT / 'README.md'
14+
assert_is_file(README_PATH)
15+
16+
text_block = text_block.replace(constants.CLI_EPILOG, '')
17+
text_block = f'```\n{text_block.strip()}\n```'
18+
assert_readme_block(
19+
readme_path=README_PATH,
20+
text_block=text_block,
21+
start_marker_line=f'[comment]: <> (✂✂✂ auto generated {marker} start ✂✂✂)',
22+
end_marker_line=f'[comment]: <> (✂✂✂ auto generated {marker} end ✂✂✂)',
23+
)
24+
25+
26+
class ReadmeTestCase(BaseTestCase):
27+
def test_main_help(self):
28+
stdout = invoke_click(cli, '--help')
29+
self.assert_in_content(
30+
got=stdout,
31+
parts=(
32+
'Usage: ./cli.py [OPTIONS] COMMAND [ARGS]...',
33+
constants.CLI_EPILOG,
34+
),
35+
)
36+
assert_cli_help_in_readme(text_block=stdout, marker='main help')
37+
38+
def test_dev_help(self):
39+
stdout = invoke_click(dev_cli, '--help')
40+
self.assert_in_content(
41+
got=stdout,
42+
parts=(
43+
'Usage: ./dev-cli.py [OPTIONS] COMMAND [ARGS]...',
44+
' check-code-style ',
45+
' coverage ',
46+
constants.CLI_EPILOG,
47+
),
48+
)
49+
assert_cli_help_in_readme(text_block=stdout, marker='dev help')
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
from unittest import TestCase, skipIf
3+
4+
from bx_py_utils.auto_doc import assert_readme_block
5+
from cli_base.cli_tools.git_history import get_git_history
6+
7+
import dragonlib
8+
from dragonlib.cli_dev import PACKAGE_ROOT
9+
10+
11+
class ReadmeHistoryTestCase(TestCase):
12+
@skipIf(
13+
# After a release the history may be "changed" because of version bump
14+
# and we should not block merge requests because of this.
15+
'GITHUB_ACTION' in os.environ,
16+
reason='Skip on github actions',
17+
)
18+
def test_readme_history(self):
19+
git_history = get_git_history(
20+
current_version=dragonlib.__version__,
21+
add_author=False,
22+
)
23+
history = '\n'.join(git_history)
24+
assert_readme_block(
25+
readme_path=PACKAGE_ROOT / 'README.md',
26+
text_block=f'\n{history}\n',
27+
start_marker_line='[comment]: <> (✂✂✂ auto generated history start ✂✂✂)',
28+
end_marker_line='[comment]: <> (✂✂✂ auto generated history end ✂✂✂)',
29+
)

0 commit comments

Comments
 (0)