cards 2.0.0__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cards-2.0.2/PKG-INFO ADDED
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.5
2
+ Name: cards
3
+ Version: 2.0.2
4
+ Summary: Project task tracking / todo list - A Teaching Project
5
+ Author: Brian Okken
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ License-File: LICENSE
15
+ Requires-Dist: tinydb==4.8.2
16
+ Requires-Dist: typer==0.17.4
17
+ Requires-Dist: rich==14.1.0
18
+ Requires-Dist: pytest ; extra == "test"
19
+ Requires-Dist: tox ; extra == "test"
20
+ Requires-Dist: tox-uv ; extra == "test"
21
+ Requires-Dist: coverage ; extra == "test"
22
+ Requires-Dist: pytest-cov ; extra == "test"
23
+ Project-URL: Home, https://github.com/okken/cards
24
+ Provides-Extra: test
25
+ Import-Name: cards
26
+
27
+ cards
28
+ =====
29
+
30
+ Project task tracking / todo list
31
+
32
+ A Teaching Project
33
+ ----------------------------
34
+
35
+ This project is used for teaching the concepts of software testing.
36
+ Specifically, testing with the pytest test framework.
37
+
38
+ The project appears in:
39
+ - [The Complete pytest Course](https://courses.pythontest.com/)
40
+ - uses cards version 2.0.0
41
+ - [Python Testing with pytest, 2nd edition](https://pythontest.com/pytest-book/)
42
+ - uses cards version 1.0.1 - approximately
43
+
44
+ Can be used as a simple todo list
45
+ ---------------------------------
46
+
47
+ Even though the primary goal of the project is for teaching about software testing, I also use it as a simple command line task tracker for myself and my team.
48
+
49
+ Usage
50
+ -----
51
+
52
+ Here's a demo of how it works:
53
+
54
+ $ cards add a todo
55
+ $ cards add -o Brian another task
56
+ $ cards list
57
+
58
+ ID state owner summary
59
+ ───────────────────────────────────
60
+ 1 todo a todo
61
+ 2 todo Brian another task
62
+
63
+ $ cards update 1 -o Brian
64
+ . $ cards
65
+
66
+ ID state owner summary
67
+ ───────────────────────────────────
68
+ 1 todo Brian a todo
69
+ 2 todo Brian another task
70
+
71
+ $ cards start 1
72
+ $ cards
73
+
74
+ ID state owner summary
75
+ ─────────────────────────────────────
76
+ 1 in prog Brian a todo
77
+ 2 todo Brian another task
78
+
79
+ $ cards finish 1
80
+ $ cards
81
+
82
+ ID state owner summary
83
+ ───────────────────────────────────
84
+ 1 done Brian a todo
85
+ 2 todo Brian another task
86
+
87
+
88
+ $ cards delete 1
89
+ $ cards
90
+
91
+ ID state owner summary
92
+ ───────────────────────────────────
93
+ 2 todo Brian another task
94
+
95
+ $ cards --help
96
+
97
+ Usage: cards [OPTIONS] COMMAND [ARGS]...
98
+
99
+ Cards is a small command line task tracking application.
100
+
101
+ ╭─ Options ────────────────────────────────────────────────────────╮
102
+ │ --help Show this message and exit. │
103
+ ╰──────────────────────────────────────────────────────────────────╯
104
+ ╭─ Commands ───────────────────────────────────────────────────────╮
105
+ │ add Add a card to db. │
106
+ │ config List the path to the Cards db. │
107
+ │ count Return number of cards in db. │
108
+ │ delete Remove card in db with given id. │
109
+ │ finish Set a card state to 'done'. │
110
+ │ list List cards in db. │
111
+ │ start Set a card state to 'in prog'. │
112
+ │ update Modify a card in db with given id with new info. │
113
+ │ version Return version of cards application │
114
+ ╰──────────────────────────────────────────────────────────────────╯
115
+
@@ -10,7 +10,7 @@ This project is used for teaching the concepts of software testing.
10
10
  Specifically, testing with the pytest test framework.
11
11
 
12
12
  The project appears in:
13
- - [The Complete pytest Course](https://pythontest.com/courses/)
13
+ - [The Complete pytest Course](https://courses.pythontest.com/)
14
14
  - uses cards version 2.0.0
15
15
  - [Python Testing with pytest, 2nd edition](https://pythontest.com/pytest-book/)
16
16
  - uses cards version 1.0.1 - approximately
@@ -35,7 +35,20 @@ Here's a demo of how it works:
35
35
  2 todo Brian another task
36
36
 
37
37
  $ cards update 1 -o Brian
38
-
38
+ . $ cards
39
+
40
+ ID state owner summary
41
+ ───────────────────────────────────
42
+ 1 todo Brian a todo
43
+ 2 todo Brian another task
44
+
45
+ $ cards start 1
46
+ $ cards
47
+
48
+ ID state owner summary
49
+ ─────────────────────────────────────
50
+ 1 in prog Brian a todo
51
+ 2 todo Brian another task
39
52
 
40
53
  $ cards finish 1
41
54
  $ cards
@@ -5,21 +5,28 @@ build-backend = "flit_core.buildapi"
5
5
  [project]
6
6
  name = "cards"
7
7
  authors = [{name = "Brian Okken"}]
8
+ readme = "README.md"
9
+ dynamic = ["version", "description"]
8
10
  classifiers = [
9
11
  "License :: OSI Approved :: MIT License",
12
+ 'Programming Language :: Python :: 3.10',
13
+ 'Programming Language :: Python :: 3.11',
14
+ 'Programming Language :: Python :: 3.12',
15
+ 'Programming Language :: Python :: 3.13',
16
+ 'Programming Language :: Python :: 3.14',
10
17
  ]
11
- requires-python=">=3.8"
12
- dynamic = ["version", "description"]
18
+ requires-python=">=3.10"
13
19
  dependencies = [
14
- "tinydb==4.8.0",
15
- "typer==0.9.0",
16
- "rich==13.5.2"
20
+ "tinydb==4.8.2",
21
+ "typer==0.17.4",
22
+ "rich==14.1.0"
17
23
  ]
18
24
 
19
25
  [project.optional-dependencies]
20
26
  test = [
21
27
  "pytest",
22
28
  "tox",
29
+ "tox-uv",
23
30
  "coverage",
24
31
  "pytest-cov",
25
32
  ]
@@ -0,0 +1,6 @@
1
+ """Project task tracking / todo list - A Teaching Project"""
2
+
3
+ __version__ = "2.0.2"
4
+
5
+ from .api import * # noqa
6
+ from .cli import app # noqa
@@ -24,9 +24,9 @@ def version():
24
24
  @app.command()
25
25
  def add(summary: List[str], owner: str = typer.Option(None, "-o", "--owner")):
26
26
  """Add a card to db."""
27
- summary = " ".join(summary) if summary else None
27
+ summary_str = " ".join(summary) if summary else None
28
28
  with cards_db() as db:
29
- db.add_card(cards.Card(summary, owner, state="todo"))
29
+ db.add_card(cards.Card(summary_str, owner, state="todo"))
30
30
 
31
31
 
32
32
  @app.command()
@@ -49,7 +49,7 @@ def list_cards(
49
49
  """
50
50
  with cards_db() as db:
51
51
  the_cards = db.list_cards(owner=owner, state=state)
52
- table = Table(box=SIMPLE)
52
+ table = Table(box=SIMPLE, header_style="")
53
53
  table.add_column("ID")
54
54
  table.add_column("state")
55
55
  table.add_column("owner")
@@ -69,10 +69,10 @@ def update(
69
69
  summary: List[str] = typer.Option(None, "-s", "--summary"),
70
70
  ):
71
71
  """Modify a card in db with given id with new info."""
72
- summary = " ".join(summary) if summary else None
72
+ summary_str = " ".join(summary) if summary else None
73
73
  with cards_db() as db:
74
74
  try:
75
- db.update_card(card_id, cards.Card(summary, owner, state=None))
75
+ db.update_card(card_id, cards.Card(summary_str, owner, state=None))
76
76
  except cards.InvalidCardId:
77
77
  print(f"Error: Invalid card id {card_id}")
78
78
 
cards-2.0.0/.editorconfig DELETED
@@ -1,21 +0,0 @@
1
- # http://editorconfig.org
2
-
3
- root = true
4
-
5
- [*]
6
- indent_style = space
7
- indent_size = 4
8
- trim_trailing_whitespace = true
9
- insert_final_newline = true
10
- charset = utf-8
11
- end_of_line = lf
12
-
13
- [*.bat]
14
- indent_style = tab
15
- end_of_line = crlf
16
-
17
- [LICENSE]
18
- insert_final_newline = false
19
-
20
- [Makefile]
21
- indent_style = tab
@@ -1,15 +0,0 @@
1
- * cards version:
2
- * Python version:
3
- * Operating System:
4
-
5
- ### Description
6
-
7
- Describe what you were trying to get done.
8
- Tell us what happened, what went wrong, and what you expected to happen.
9
-
10
- ### What I Did
11
-
12
- ```
13
- Paste the command(s) you ran and the output.
14
- If there was a crash, please include the traceback here.
15
- ```
@@ -1,8 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: pip
4
- directory: "/"
5
- schedule:
6
- interval: daily
7
- time: "13:00"
8
- open-pull-requests-limit: 10
@@ -1,23 +0,0 @@
1
- name: main
2
-
3
- on: [pull_request]
4
-
5
- jobs:
6
- build:
7
-
8
- runs-on: ubuntu-latest
9
-
10
- strategy:
11
- matrix:
12
- python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
13
-
14
- steps:
15
- - uses: actions/checkout@v3
16
- - name: Setup Python
17
- uses: actions/setup-python@v4
18
- with:
19
- python-version: ${{ matrix.python }}
20
- - name: Install Tox and any other packages
21
- run: pip install tox
22
- - name: Run Tox
23
- run: tox -e py
cards-2.0.0/.gitignore DELETED
@@ -1,107 +0,0 @@
1
- # Byte-compiled / optimized / DLL files
2
- __pycache__/
3
- *.py[cod]
4
- *$py.class
5
-
6
- # C extensions
7
- *.so
8
-
9
- # Distribution / packaging
10
- .Python
11
- env/
12
- build/
13
- develop-eggs/
14
- dist/
15
- downloads/
16
- eggs/
17
- .eggs/
18
- lib/
19
- lib64/
20
- parts/
21
- sdist/
22
- var/
23
- wheels/
24
- *.egg-info/
25
- .installed.cfg
26
- *.egg
27
-
28
- # PyInstaller
29
- # Usually these files are written by a python script from a template
30
- # before PyInstaller builds the exe, so as to inject date/other infos into it.
31
- *.manifest
32
- *.spec
33
-
34
- # Installer logs
35
- pip-log.txt
36
- pip-delete-this-directory.txt
37
-
38
- # Unit test / coverage reports
39
- htmlcov/
40
- .tox/
41
- .coverage
42
- .coverage.*
43
- .cache
44
- nosetests.xml
45
- coverage.xml
46
- *.cover
47
- .hypothesis/
48
-
49
- # Translations
50
- *.mo
51
- *.pot
52
-
53
- # Django stuff:
54
- *.log
55
- local_settings.py
56
-
57
- # Flask stuff:
58
- instance/
59
- .webassets-cache
60
-
61
- # Scrapy stuff:
62
- .scrapy
63
-
64
- # Sphinx documentation
65
- docs/_build/
66
-
67
- # PyBuilder
68
- target/
69
-
70
- # Jupyter Notebook
71
- .ipynb_checkpoints
72
-
73
- # pyenv
74
- .python-version
75
-
76
- # celery beat schedule file
77
- celerybeat-schedule
78
-
79
- # SageMath parsed files
80
- *.sage.py
81
-
82
- # dotenv
83
- .env
84
-
85
- # virtualenv
86
- .venv
87
- venv/
88
- ENV/
89
-
90
- # Spyder project settings
91
- .spyderproject
92
- .spyproject
93
-
94
- # Rope project settings
95
- .ropeproject
96
-
97
- # mkdocs documentation
98
- /site
99
-
100
- # mypy
101
- .mypy_cache/
102
-
103
- # pycharm
104
- .idea/
105
-
106
- # pytest
107
- .pytest_cache/
cards-2.0.0/Makefile DELETED
@@ -1,50 +0,0 @@
1
- .PHONY: clean clean-test clean-pyc clean-build docs help
2
-
3
- .DEFAULT_GOAL := help
4
-
5
- help:
6
- grep '\#\#' Makefile
7
-
8
- clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
9
-
10
- clean-build: ## remove build artifacts
11
- rm -fr dist/
12
-
13
- clean-pyc: ## remove Python file artifacts
14
- find . -name '*.pyc' -exec rm -f {} +
15
- find . -name '*.pyo' -exec rm -f {} +
16
- find . -name '*~' -exec rm -f {} +
17
- find . -name '__pycache__' -exec rm -fr {} +
18
-
19
- clean-test: ## remove test and coverage artifacts
20
- rm -fr .tox/
21
- find . -name '.coverage' -exec rm -fr {} +
22
- find . -name 'htmlcov' -exec rm -fr {} +
23
- find . -name '.pytest_cache' -exec rm -fr {} +
24
-
25
- lint: ## check style
26
- tox -e lint
27
-
28
- test: ## run tests on one version of Python
29
- tox -e py
30
-
31
- tox: ## run tests on all available versions of Python
32
- tox
33
-
34
- dist: clean ## builds source and wheel package
35
- flit build
36
- ls -l dist
37
-
38
- install: ## install in editable mode
39
- pip install -e .
40
-
41
- dev: ## create dev env
42
- py -m venv venv --prompt cards_proj
43
- venv/bin/pip install -U pip
44
- venv/bin/pip install pytest tox pytest-cov coverage
45
- venv/bin/pip install -e .
46
- @echo "-------------------------"
47
- @echo "dev env ready to activate"
48
- @echo "-------------------------"
49
-
50
-
cards-2.0.0/PKG-INFO DELETED
@@ -1,16 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: cards
3
- Version: 2.0.0
4
- Summary: Top-level package for cards.
5
- Author: Brian Okken
6
- Requires-Python: >=3.8
7
- Classifier: License :: OSI Approved :: MIT License
8
- Requires-Dist: tinydb==4.8.0
9
- Requires-Dist: typer==0.9.0
10
- Requires-Dist: rich==13.5.2
11
- Requires-Dist: pytest ; extra == "test"
12
- Requires-Dist: tox ; extra == "test"
13
- Requires-Dist: coverage ; extra == "test"
14
- Requires-Dist: pytest-cov ; extra == "test"
15
- Project-URL: Home, https://github.com/okken/cards
16
- Provides-Extra: test
@@ -1,6 +0,0 @@
1
- """Top-level package for cards."""
2
-
3
- __version__ = "2.0.0"
4
-
5
- from .api import * # noqa
6
- from .cli import app # noqa
File without changes
@@ -1,64 +0,0 @@
1
- """
2
- Test Cases
3
- * `add` to an empty database, with summary
4
- * `add` to a non-empty database, with summary
5
- * `add` a card with both summary and owner set
6
- * `add` a card with a missing summary
7
- * `add` a duplicate card
8
- """
9
- import pytest
10
- from cards import Card, MissingSummary
11
-
12
-
13
- def test_add_from_empty(cards_db):
14
- """
15
- count should be 1 and card retrievable
16
- """
17
- c = Card(summary="do something")
18
- i = cards_db.add_card(c)
19
- assert cards_db.count() == 1
20
- assert cards_db.get_card(i) == c
21
-
22
-
23
- def test_add_from_nonempty(cards_db_three_cards):
24
- """
25
- count should increase by 1 and card retrievable
26
- """
27
- cards_db = cards_db_three_cards
28
- c = Card(summary="do something")
29
- starting_count = cards_db.count()
30
- i = cards_db.add_card(c)
31
- assert cards_db.count() == starting_count + 1
32
- assert cards_db.get_card(i) == c
33
-
34
-
35
- def test_add_with_summary_and_owner(cards_db):
36
- """
37
- count should be 1 and card retrievable
38
- """
39
- c = Card(summary="do something", owner="Brian")
40
- i = cards_db.add_card(c)
41
- assert cards_db.count() == 1
42
- assert cards_db.get_card(i) == c
43
-
44
-
45
- def test_add_missing_summary(cards_db):
46
- """
47
- Should raise an exception
48
- """
49
- c = Card()
50
- with pytest.raises(MissingSummary):
51
- cards_db.add_card(c)
52
-
53
-
54
- def test_add_duplicate(cards_db):
55
- """
56
- Duplicates allowed, both retrievable, separate indices
57
- """
58
- c = Card(summary="do something")
59
- i_1 = cards_db.add_card(c)
60
- i_2 = cards_db.add_card(c)
61
- c1 = cards_db.get_card(i_1)
62
- c2 = cards_db.get_card(i_2)
63
- assert i_1 != i_2
64
- assert c1 == c2 == c
@@ -1,8 +0,0 @@
1
- """
2
- Test Cases
3
- * `config` returns the correct database path
4
- """
5
-
6
-
7
- def test_config(cards_db, tmp_db_path):
8
- assert cards_db.path() == tmp_db_path
@@ -1,21 +0,0 @@
1
- """
2
- Test Cases
3
- * `count` from an empty database
4
- * `count` with one item
5
- * `count` with more than one item
6
- """
7
- from cards import Card
8
-
9
-
10
- def test_count_no_cards(cards_db):
11
- assert cards_db.count() == 0
12
-
13
-
14
- def test_count_one_card(cards_db):
15
- cards_db.add_card(Card("foo"))
16
- assert cards_db.count() == 1
17
-
18
-
19
- def test_count_three_cards(cards_db_three_cards):
20
- cards_db = cards_db_three_cards
21
- assert cards_db.count() == 3
@@ -1,59 +0,0 @@
1
- """
2
- Test Cases:
3
- * `delete` one from a database with more than one
4
- * `delete` the last card
5
- * `delete` a non-existent card
6
- """
7
- import pytest
8
- from cards import Card, InvalidCardId
9
-
10
-
11
- @pytest.fixture()
12
- def three_cards(cards_db):
13
- i = cards_db.add_card(Card("foo"))
14
- j = cards_db.add_card(Card("bar"))
15
- k = cards_db.add_card(Card("baz"))
16
- return (i, j, k) # ids for the cards
17
-
18
-
19
- def test_delete_from_many(cards_db, three_cards):
20
- """
21
- Count should go from 3 to 2
22
- And card shouldn't be retrievable.
23
- But the rest should be.
24
- """
25
- (i, j, k) = three_cards # ids
26
- id_to_delete = j
27
- ids_still_there = (i, k)
28
-
29
- cards_db.delete_card(id_to_delete)
30
-
31
- assert cards_db.count() == 2
32
- # card should not be retrievable after deletion
33
- with pytest.raises(InvalidCardId):
34
- cards_db.get_card(id_to_delete)
35
- # non-deleted cards should still be retrievable
36
- for i in ids_still_there:
37
- # just making sure this doesn't throw an exception
38
- cards_db.get_card(i)
39
-
40
-
41
- def test_delete_last_card(cards_db):
42
- """
43
- Count should be back to 0
44
- And card shouldn't be retrievable.
45
- """
46
- i = cards_db.add_card(Card("foo"))
47
- cards_db.delete_card(i)
48
- assert cards_db.count() == 0
49
- with pytest.raises(InvalidCardId):
50
- cards_db.get_card(i)
51
-
52
-
53
- def test_delete_non_existent(cards_db):
54
- """
55
- Shouldn't be able to start a non-existent card.
56
- """
57
- i = 123 # any number will do, db is empty
58
- with pytest.raises(InvalidCardId):
59
- cards_db.delete_card(i)
@@ -1,28 +0,0 @@
1
- """
2
- Test Cases
3
- * `finish` from "todo", "in prog", and "done" states
4
- * `finish` an invalid id
5
- """
6
- import pytest
7
- from cards import Card, InvalidCardId
8
-
9
-
10
- @pytest.mark.parametrize("start_state", ("todo", "in prog", "done"))
11
- def test_finish(cards_db, start_state):
12
- """
13
- End state should be "done"
14
- """
15
- c = Card("foo", state=start_state)
16
- i = cards_db.add_card(c)
17
- cards_db.finish(i)
18
- c = cards_db.get_card(i)
19
- assert c.state == "done"
20
-
21
-
22
- def test_finish_non_existent(cards_db):
23
- """
24
- Shouldn't be able to start a non-existent card.
25
- """
26
- i = 123 # any number will do, db is empty
27
- with pytest.raises(InvalidCardId):
28
- cards_db.finish(i)
@@ -1,31 +0,0 @@
1
- """
2
- Test Cases
3
- * `list` from an empty database
4
- * `list` from a non-empty database
5
- """
6
- from cards import Card
7
-
8
-
9
- def test_list_no_cards(cards_db):
10
- """Empty db, empty list"""
11
- assert cards_db.list_cards() == []
12
-
13
-
14
- def test_list_several_cards(cards_db):
15
- """
16
- Given a variety of cards, make sure they get returned.
17
- """
18
- orig = [
19
- Card("foo"),
20
- Card("bar", owner="me"),
21
- Card("baz", owner="you", state="in prog"),
22
- ]
23
-
24
- for c in orig:
25
- cards_db.add_card(c)
26
-
27
- the_list = cards_db.list_cards()
28
-
29
- assert len(the_list) == len(orig)
30
- for c in orig:
31
- assert c in the_list
@@ -1,69 +0,0 @@
1
- """
2
- Test Cases for list filter
3
- # - specific owner
4
- # - specific state
5
- # - owner and state
6
- """
7
- import pytest
8
- from cards import Card
9
-
10
-
11
- @pytest.fixture(scope="module")
12
- def known_set():
13
- # summary matches index into this list
14
- return [
15
- Card(summary="zero", owner="Brian", state="todo"),
16
- Card(summary="one", owner="Brian", state="in prog"),
17
- Card(summary="two", owner="Brian", state="done"),
18
- Card(summary="three", owner="Okken", state="todo"),
19
- Card(summary="four", owner="Okken", state="in prog"),
20
- Card(summary="five", owner="Okken", state="done"),
21
- ]
22
-
23
-
24
- @pytest.fixture(scope="module")
25
- def db_filled(session_cards_db, known_set):
26
- cards_db = session_cards_db
27
-
28
- # make sure it's empty
29
- cards_db.delete_all()
30
-
31
- # then add our known set
32
- for c in known_set:
33
- cards_db.add_card(c)
34
- return cards_db
35
-
36
-
37
- def test_list_filter_owner(db_filled, known_set):
38
- """
39
- Should get cards 3, 4, 5 back:
40
- Card(summary="three", owner="Okken", state="todo"),
41
- Card(summary="four", owner="Okken", state="in prog"),
42
- Card(summary="five", owner="Okken", state="done"),
43
- """
44
- result = db_filled.list_cards(owner="Okken")
45
- assert len(result) == 3
46
- for i in (3, 4, 5):
47
- assert known_set[i] in result
48
-
49
-
50
- def test_list_filter_state(db_filled, known_set):
51
- """
52
- Should get cards 1 and 4 back:
53
- Card(summary="one", owner="Brian", state="in prog"),
54
- Card(summary="four", owner="Okken", state="in prog"),
55
- """
56
- result = db_filled.list_cards(state="in prog")
57
- assert len(result) == 2
58
- for i in (1, 4):
59
- assert known_set[i] in result
60
-
61
-
62
- def test_list_filter_both(db_filled, known_set):
63
- """
64
- Should get just card 2 back:
65
- Card(summary="two", owner="Brian", state="done"),
66
- """
67
- result = db_filled.list_cards(owner="Brian", state="done")
68
- assert len(result) == 1
69
- assert result[0] == known_set[2]
@@ -1,28 +0,0 @@
1
- """
2
- Test Cases
3
- * `start` from "todo", "in prog", and "done" states
4
- * `start` an invalid id
5
- """
6
- import pytest
7
- from cards import Card, InvalidCardId
8
-
9
-
10
- @pytest.mark.parametrize("start_state", ("todo", "in prog", "done"))
11
- def test_start(cards_db, start_state):
12
- """
13
- End state should be "in prog"
14
- """
15
- c = Card("foo", state=start_state)
16
- i = cards_db.add_card(c)
17
- cards_db.start(i)
18
- c = cards_db.get_card(i)
19
- assert c.state == "in prog"
20
-
21
-
22
- def test_start_non_existent(cards_db):
23
- """
24
- Shouldn't be able to start a non-existent card.
25
- """
26
- i = 123 # any number will do, db is empty
27
- with pytest.raises(InvalidCardId):
28
- cards_db.start(i)
@@ -1,54 +0,0 @@
1
- """
2
- Test Cases
3
- * `update` the owner of a card
4
- * `update` the summary of a card
5
- * `update` owner and summary of a card at the same time
6
- * `update` a non-existent card
7
- """
8
- import pytest
9
- from cards import Card, InvalidCardId
10
-
11
-
12
- def test_update_owner(cards_db):
13
- """
14
- summary and state should stay the same
15
- owner should change
16
- """
17
- i = cards_db.add_card(Card("foo", owner="me"))
18
- cards_db.update_card(i, Card(owner="not me", state=None))
19
-
20
- mod = cards_db.get_card(i)
21
- assert mod == Card("foo", owner="not me")
22
-
23
-
24
- def test_update_summary(cards_db):
25
- """
26
- owner and state should stay the same
27
- summary should change
28
- """
29
- i = cards_db.add_card(Card("foo", owner="me", state="done"))
30
- cards_db.update_card(i, Card(summary="bar", state=None))
31
-
32
- mod = cards_db.get_card(i)
33
- assert mod == Card("bar", owner="me", state="done")
34
-
35
-
36
- def test_update_both(cards_db):
37
- """
38
- state should stay the same
39
- owner and summary should change
40
- """
41
- i = cards_db.add_card(Card("foo", owner="me"))
42
- cards_db.update_card(i, Card(summary="bar", owner="not me"))
43
-
44
- mod = cards_db.get_card(i)
45
- assert mod == Card("bar", owner="not me", state="todo")
46
-
47
-
48
- def test_update_non_existent(cards_db):
49
- """
50
- Shouldn't be able to update a non-existent card.
51
- """
52
- i = 123 # any number will do, db is empty
53
- with pytest.raises(InvalidCardId):
54
- cards_db.update_card(i, Card(summary="bar", owner="not me"))
@@ -1,17 +0,0 @@
1
- """
2
- Test Cases
3
- * `version` returns the correct version
4
- """
5
- import re
6
- import cards
7
-
8
-
9
- def test_version():
10
- """
11
- There is no api for version other than cards.__version__.
12
- However, we do expect it to be:
13
- - a string containing a version in the form of "x.y.z"
14
- So, why not, let's test for that.
15
- """
16
- version = cards.__version__
17
- assert re.match(r"\d+\.\d+\.\d+", version)
File without changes
@@ -1,13 +0,0 @@
1
- import shlex
2
-
3
- from cards.cli import app
4
- from typer.testing import CliRunner
5
-
6
- runner = CliRunner()
7
-
8
-
9
- def cards_cli(command_string):
10
- command_list = shlex.split(command_string)
11
- result = runner.invoke(app, command_list)
12
- output = result.stdout.rstrip()
13
- return output
@@ -1,116 +0,0 @@
1
- import cards
2
- import pytest
3
-
4
- from cards_cli_helper import cards_cli
5
-
6
-
7
- @pytest.fixture(autouse=True)
8
- def patch_db_for_cards_cli(tmp_db_path, monkeypatch):
9
- """Make the CLI use the temporary directory"""
10
- monkeypatch.setenv("CARDS_DB_DIR", str(tmp_db_path))
11
-
12
-
13
- def test_version():
14
- assert cards_cli("version") == cards.__version__
15
-
16
-
17
- def test_config(tmp_db_path, cards_db):
18
- assert cards_cli("config") == str(tmp_db_path)
19
-
20
-
21
- def test_config_normal_path(tmp_db_path, monkeypatch):
22
- """Undo the autouse fixture, for just this test."""
23
- monkeypatch.delenv("CARDS_DB_DIR")
24
- assert cards_cli("config") != str(tmp_db_path)
25
-
26
-
27
- def test_count(cards_db_three_cards):
28
- assert cards_cli("count") == "3"
29
-
30
-
31
- def test_start(cards_db):
32
- i = cards_db.add_card(cards.Card("some task"))
33
- cards_cli(f"start {i}")
34
- after = cards_db.get_card(i)
35
- assert after.state == "in prog"
36
-
37
-
38
- def test_finish(cards_db):
39
- i = cards_db.add_card(cards.Card("some task"))
40
- cards_cli(f"finish {i}")
41
- after = cards_db.get_card(i)
42
- assert after.state == "done"
43
-
44
-
45
- def test_add(cards_db):
46
- cards_cli("add some task")
47
- expected = cards.Card("some task", owner="", state="todo")
48
- all_cards = cards_db.list_cards()
49
- assert len(all_cards) == 1
50
- assert all_cards[0] == expected
51
-
52
-
53
- def test_add_with_owner(cards_db):
54
- """
55
- A card shows up in the list with expected contents.
56
- """
57
- cards_cli("add some task -o brian")
58
- expected = cards.Card("some task", owner="brian", state="todo")
59
- all_cards = cards_db.list_cards()
60
- assert len(all_cards) == 1
61
- assert all_cards[0] == expected
62
-
63
-
64
- def test_delete(cards_db):
65
- i = cards_db.add_card(cards.Card("foo"))
66
- cards_cli(f"delete {i}")
67
- assert cards_db.count() == 0
68
-
69
-
70
- def test_update(cards_db):
71
- i = cards_db.add_card(cards.Card("foo"))
72
- cards_cli(f"update {i} -o okken -s something")
73
- expected = cards.Card("something", owner="okken", state="todo")
74
- actual = cards_db.get_card(i)
75
- assert actual == expected
76
-
77
-
78
- expected_output = """\
79
-
80
- ID state owner summary
81
- ────────────────────────────────
82
- 1 todo some task
83
- 2 todo another
84
- """
85
-
86
-
87
- def test_list(cards_db):
88
- cards_db.add_card(cards.Card("some task"))
89
- cards_db.add_card(cards.Card("another"))
90
- output = cards_cli("list")
91
- assert output.strip() == expected_output.strip()
92
-
93
-
94
- def test_main(cards_db):
95
- cards_db.add_card(cards.Card("some task"))
96
- cards_db.add_card(cards.Card("another"))
97
- output = cards_cli("")
98
- assert output.strip() == expected_output.strip()
99
-
100
-
101
- # Error cases
102
-
103
-
104
- @pytest.mark.parametrize(
105
- "command",
106
- ["delete 25", "start 25", "finish 25", "update 25 -s foo -o brian"],
107
- )
108
- def test_invalid_card_id(cards_db, command):
109
- out = cards_cli(command)
110
- assert out == "Error: Invalid card id 25"
111
-
112
-
113
- def test_missing_summary(cards_db):
114
- out = cards_cli("add")
115
- assert "Error" in out
116
- assert "Missing argument 'SUMMARY...'" in out
@@ -1,34 +0,0 @@
1
- import cards
2
- import pytest
3
- from cards import Card
4
-
5
-
6
- @pytest.fixture(scope="session")
7
- def tmp_db_path(tmp_path_factory):
8
- """Path to temporary database"""
9
- return tmp_path_factory.mktemp("cards_db")
10
-
11
-
12
- @pytest.fixture(scope="session")
13
- def session_cards_db(tmp_db_path):
14
- """CardsDB"""
15
- db_ = cards.CardsDB(tmp_db_path)
16
- yield db_
17
- db_.close()
18
-
19
-
20
- @pytest.fixture(scope="function")
21
- def cards_db(session_cards_db):
22
- """Empty CardsDB"""
23
- db = session_cards_db
24
- db.delete_all()
25
- return db
26
-
27
-
28
- @pytest.fixture(scope="function")
29
- def cards_db_three_cards(cards_db):
30
- """CardsDB with 3 cards"""
31
- cards_db.add_card(Card("foo"))
32
- cards_db.add_card(Card("bar"))
33
- cards_db.add_card(Card("baz"))
34
- return cards_db
cards-2.0.0/tox.ini DELETED
@@ -1,34 +0,0 @@
1
- [tox]
2
- envlist = py38, py39, py310, py311, py312
3
- skip_missing_interpreters = True
4
-
5
- [testenv]
6
- deps =
7
- pytest
8
- pytest-cov
9
- commands =
10
- pytest --cov=cards --cov=tests --cov-branch --cov-fail-under=100 {posargs}
11
- package = wheel
12
- wheel_build_env = .pkg
13
-
14
- [pytest]
15
- addopts =
16
- --strict-markers
17
- --strict-config
18
- -ra
19
- testpaths = tests
20
- pythonpath = tests/cli
21
-
22
- [coverage:run]
23
- branch = True
24
-
25
- [coverage:paths]
26
- source =
27
- src
28
- */site-packages"
29
-
30
- [coverage:report]
31
- exclude_also =
32
- if __name__ == .__main__.:
33
-
34
- ignore_errors = True
File without changes
File without changes
File without changes