├── .gitignore ├── CHANGELOG ├── LICENSE ├── README.md ├── requirements.txt ├── setup.py ├── taskquant ├── __init__.py ├── __main__.py ├── score │ ├── __init__.py │ └── accum.py └── utils │ ├── __init__.py │ ├── colors.py │ ├── create_table.py │ └── helpful.py └── tests ├── __init__.py └── test_accum.py /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | */__pycache__/ 3 | __pycache__/ 4 | dist/ 5 | taskquant.egg-info/ 6 | build/ 7 | tests/testdata/ -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | ##### v0.0.5 3 | - Introduces a weekly (`-w`) flag, allowing users to aggregate their scoresheet by week (instead of by day). 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022 Supertype Pte Ltd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## TaskQuant 2 | This is a CLI application that helps Taskwarrior users quantify their productivity by tracking the 'score' attribute in their tasks. 3 | 4 | `score` is a custom [User Defined Attributes](https://taskwarrior.org/docs/udas.html). You will need to have that configured in your `.taskrc` file. A sample configuration for this attribute would be: 5 | 6 | ``` 7 | uda.score.type=numeric 8 | uda.score.label=Score 🏆 9 | urgency.uda.score.coefficient=2 10 | ``` 11 | 12 | TaskQuant will then compute the score(s) you have accumulated across the different tasks and return a scoresheet. 13 | 14 | TaskQuant **has no external dependencies** except `tasklib`, which is also by [the same organization](https://github.com/GothenburgBitFactory) that developed Taskwarrior. 15 | 16 | It is written entirely in Python, using standard library. It may have optional dependencies, but those are not required and a fallback option will always be used by default. 17 | 18 | For those reasons, TaskQuant is extremely lightweight. As it stands, it's only 6.8kb of code, and should install in under a second. 19 | 20 | #### Installation 21 | TaskQuant is available on [pypi](https://pypi.org/project/taskquant/). 22 | ``` 23 | pip install taskquant 24 | ``` 25 | If you so desire, you can optionally install `tabulate` to get a prettier table output (this is completely optional, and pure cosmetic): 26 | ``` 27 | pip install tabulate 28 | ``` 29 | 30 | 31 | ### Usage 32 | Install the package and execute: 33 | 34 | ```bash 35 | tq 36 | ``` 37 | 38 | - It supports an optional `-p` (`path`) argument to specify the path to your `.task` file. **Especially** helpful if you changed the default location of your `.task` file. 39 | - It supports an optional `-v` (`verbose`) argument to print out additional 40 | information in its output. 41 | 42 | ```bash 43 | tq -p ~/vaults/tasks -v 44 | 45 | # outputs: 46 | +------------+-------+------------+ 47 | | Date | Score | Cumulative | 48 | +------------+-------+------------+ 49 | | 2022-03-09 | 0 | 0 | 50 | | 2022-03-10 | 8 | 8 | 51 | | 2022-03-11 | 1 | 9 | 52 | | 2022-03-12 | 43 | 52 | 53 | | 2022-03-13 | 4 | 56 | 54 | | 2022-03-14 | 4 | 60 | 55 | | 2022-03-15 | 7 | 67 | 56 | | 2022-03-16 | 9 | 76 | 57 | | 2022-03-17 | 4 | 80 | 58 | | 2022-03-18 | 4 | 84 | 59 | | 2022-03-19 | 3 | 87 | 60 | | 2022-03-20 | 2 | 89 | 61 | | 2022-03-21 | 5 | 94 | 62 | +------------+-------+------------+ 63 | Total completed tasks: 48 64 | Active dates: 13 65 | task_path: /home/samuel/vaults/tasks 66 | ``` 67 | 68 | You can also print a weekly (`-w`) version of the scoresheet: 69 | 70 | ```bash 71 | tq -w 72 | +-------+-------+------------+ 73 | | Week# | Score | Cumulative | 74 | +-------+-------+------------+ 75 | | 10 | 56 | 56 | 76 | | 11 | 33 | 89 | 77 | | 12 | 26 | 115 | 78 | | 13 | 12 | 127 | 79 | +-------+-------+------------+ 80 | ``` 81 | The first column refers to the ISO week number of the year. 82 | 83 | 84 | - To see all optional arguments, use the `-h` (`help`) argument. 85 | 86 | ```bash 87 | tq -h 88 | ``` 89 | 90 | #### Dependencies 91 | - [tasklib](https://github.com/GothenburgBitFactory/tasklib) 92 | - (Optional) [tabulate](https://github.com/astanin/python-tabulate) 93 | 94 | #### Testing 95 | Tests are written in `unittest` and stored in the `tests` directory. 96 | 97 | To execute tests without arguments and automatic test discovery: 98 | 99 | ```bash 100 | python -m unittest 101 | ``` 102 | 103 | To test a specific test file (`-v` for verbose output): 104 | 105 | ```bash 106 | python -m unittest -v tests/test_accum.py 107 | 108 | test_create_combined_table (tests.test_accum.TestAccum) ... ok 109 | test_create_full_date ... ok 110 | test_create_table_auto (tests.test_accum.TestAccum) ... ok 111 | test_extract_tasks (tests.test_accum.TestAccum) ... ok 112 | test_fill_rolling_date (tests.test_accum.TestAccum) ... ok 113 | test_invalid_path_warning (tests.test_accum.TestAccum) ... ok 114 | test_task_to_dict (tests.test_accum.TestAccum) ... ok 115 | 116 | ---------------------------------------------------------------------- 117 | Ran 7 tests in 0.049s 118 | 119 | OK 120 | 121 | 122 | ``` 123 | 124 | ### Roadmap 125 | - Add terminal-based charts and graphs 126 | - New ways to visualize scores based on tags, projects or other attributes 127 | 128 | ### Links to Tutorials 129 | Watch how we build this package, line by line (detailed tutorial): 130 | - [Building TaskQuant | Part 1](https://youtu.be/lT2jqmhRkxo) 131 | - [Taskwarrior: Terminal-based task management Quick Tour](https://youtu.be/cDYIes9avW4) 132 | - [Building TaskQuant | Full Playlist](https://youtube.com/playlist?list=PLXsFtK46HZxXIVE4tRjwMjwKFVaQSdT5W) 133 | - [Dev.to article: Todo + gamification with Taskwarrior & Taskquant](https://dev.to/onlyphantom/todo-gamification-with-taskwarrior-taskquant-3e38) 134 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | backports.zoneinfo==0.2.1 2 | black==22.1.0 3 | click==8.0.4 4 | mypy-extensions==0.4.3 5 | pathspec==0.9.0 6 | platformdirs==2.5.1 7 | pytz==2021.3 8 | pytz-deprecation-shim==0.1.0.post0 9 | tabulate==0.8.9 10 | tasklib==2.4.3 11 | tomli==2.0.1 12 | typing_extensions==4.1.1 13 | tzdata==2021.5 14 | tzlocal==4.1 15 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | from pathlib import Path 3 | from taskquant import __version__ 4 | 5 | 6 | setup( 7 | name="taskquant", 8 | version=__version__, 9 | description="A python CLI that extends taskwarrior for productivity scoreboard & gamification (quantified self)", 10 | long_description=(Path(__file__).parent / "README.md").read_text(), 11 | long_description_content_type="text/markdown", 12 | url="https://github.com/onlyphantom/taskquant", 13 | author="Samuel Chan", 14 | author_email="s@supertype.ai", 15 | license="MIT", 16 | packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]), 17 | include_package_data=True, 18 | install_requires=["tasklib"], 19 | extra_requires=["tabulate"], 20 | classifiers=[ 21 | "License :: OSI Approved :: MIT License", 22 | "Programming Language :: Python :: 3", 23 | "Programming Language :: Python :: 3.7", 24 | "Operating System" " :: OS Independent", 25 | ], 26 | entry_points={ 27 | "console_scripts": [ 28 | "tq=taskquant.__main__:main", 29 | ] 30 | }, 31 | python_requires=">=3.7", 32 | ) 33 | -------------------------------------------------------------------------------- /taskquant/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.0.5" 2 | -------------------------------------------------------------------------------- /taskquant/__main__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import argparse 3 | 4 | from taskquant.score.accum import score_accum 5 | from taskquant.utils.helpful import dir_path 6 | from taskquant.utils.colors import textstyle 7 | 8 | parser = argparse.ArgumentParser( 9 | description="CLI utility that extends taskwarrior for productivity scoreboard & gamification" 10 | ) 11 | parser.add_argument("-p", "--path", type=dir_path, help="path to your .task") 12 | parser.add_argument("-w", "--weekly", action="store_true", help="weekly score") 13 | 14 | # add verbose flag 15 | parser.add_argument("-v", "--verbose", action="store_true", help="verbose mode") 16 | 17 | args = parser.parse_args() 18 | 19 | 20 | def main(): 21 | score_accum( 22 | task_path=args.path or "~/.task", 23 | verbosity=args.verbose, 24 | weekly=args.weekly, 25 | ) 26 | 27 | # if verbose 28 | if args.verbose: 29 | print( 30 | f"{textstyle.NORDBG2BOLD}task_path:{textstyle.RESET}{textstyle.OKGREEN} {args.path}{textstyle.RESET}" 31 | ) 32 | 33 | 34 | if __name__ == "__main__": 35 | main() 36 | -------------------------------------------------------------------------------- /taskquant/score/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onlyphantom/taskquant/df7eb5713053ad6bd1be6e51d75595835f2572e1/taskquant/score/__init__.py -------------------------------------------------------------------------------- /taskquant/score/accum.py: -------------------------------------------------------------------------------- 1 | """ 2 | In Development, run taskquant as module to be able to pass arguments 3 | collected by argparse (__main__.py): 4 | 5 | python -m taskquant -p ~/vaults/tasks -v 6 | """ 7 | 8 | import sys 9 | import warnings 10 | from datetime import timedelta 11 | from itertools import groupby 12 | 13 | from tasklib import TaskWarrior 14 | 15 | try: 16 | from tabulate import tabulate 17 | except ImportError: 18 | from taskquant.utils.create_table import create_table 19 | 20 | from taskquant.utils.colors import textstyle 21 | 22 | 23 | def _extract_tasks(task_path): 24 | tw = TaskWarrior(data_location=task_path) 25 | return tw.tasks.completed() 26 | 27 | 28 | def _create_table_auto( 29 | body, headers, verbosity, completed_length, date_length, plain=False 30 | ): 31 | 32 | if plain is False and "tabulate" in sys.modules: 33 | print(tabulate(body, headers=headers, tablefmt="pretty")) 34 | else: 35 | from taskquant.utils.create_table import create_table 36 | 37 | create_table(body, headers=headers) 38 | 39 | if verbosity: 40 | print( 41 | f"{textstyle.NORDBG2BOLD}Total completed tasks:{textstyle.RESET}{textstyle.OKGREEN} {completed_length}{textstyle.RESET}" 42 | ) 43 | print( 44 | f"{textstyle.NORDBG1BOLD}Active dates:{textstyle.RESET}{textstyle.OKGREEN} {date_length}{textstyle.RESET}" 45 | ) 46 | 47 | 48 | def _task_to_dict(tasks): 49 | cl = list() 50 | 51 | for task in tasks: 52 | cl.append( 53 | ( 54 | task["project"], 55 | task["end"].date(), 56 | task["effort"] or "", 57 | task["score"] or 0, 58 | task["tags"], 59 | ) 60 | ) 61 | 62 | # sort cl by ["end"] date 63 | cl_sorted = sorted(cl, key=lambda x: x[1]) 64 | 65 | agg_date = [ 66 | [k, sum(v[3] for v in g)] for k, g in groupby(cl_sorted, key=lambda x: x[1]) 67 | ] 68 | 69 | agg_date_dict = dict(agg_date) 70 | startdate = agg_date[0][0] 71 | enddate = agg_date[-1][0] 72 | return agg_date_dict, startdate, enddate 73 | 74 | 75 | def _create_full_date(startdate, enddate, agg_date_dict): 76 | """ 77 | Creating an unbroken series of date given a start and end date 78 | """ 79 | fulldate = {} 80 | while startdate <= enddate: 81 | fulldate.update({startdate: agg_date_dict.get(startdate, 0)}) 82 | startdate += timedelta(days=1) 83 | return fulldate 84 | 85 | 86 | def _fill_rolling_date(fulldate): 87 | """ 88 | Perform a rolling sum using fulldate 89 | """ 90 | rollingdate = {} 91 | accu = 0 92 | for k, v in fulldate.items(): 93 | accu += v 94 | rollingdate.update({k: accu}) 95 | 96 | return rollingdate 97 | 98 | 99 | def _create_combined_table(fulldate, rollingdate): 100 | combined_l = [] 101 | for key in fulldate.keys(): 102 | combined_l.append([key, fulldate[key], rollingdate[key]]) 103 | return combined_l 104 | 105 | 106 | def _create_weekly_rollingsum(combined_l): 107 | combined_l = [ 108 | [k, sum(v[1] for v in g)] 109 | for k, g in groupby(combined_l, key=lambda x: x[0].isocalendar()[1]) 110 | ] 111 | 112 | for i, l in enumerate(combined_l): 113 | if i == 0: 114 | l.append(l[1]) 115 | else: 116 | l.append(l[1] + combined_l[i - 1][2]) 117 | 118 | return combined_l 119 | 120 | 121 | def score_accum(task_path, verbosity=False, weekly=False): 122 | """ 123 | Create a scoreboard using 'score' attribute of tasks 124 | """ 125 | completed = _extract_tasks(task_path) 126 | 127 | total_completed = len(completed) 128 | 129 | if total_completed < 1: 130 | return warnings.warn( 131 | f"{textstyle.OKCYAN}A curious case of 0 completed tasks. Check {textstyle.WARNING}{task_path}{textstyle.OKCYAN} to make sure the path to Taskwarrior's .task is set correctly or try to complete some tasks in Taskwarrior!{textstyle.RESET}", 132 | ) 133 | else: 134 | agg_date_dict, startdate, enddate = _task_to_dict(completed) 135 | 136 | fulldate = _create_full_date(startdate, enddate, agg_date_dict) 137 | rollingdate = _fill_rolling_date(fulldate) 138 | 139 | combined_l = _create_combined_table(fulldate, rollingdate) 140 | if weekly: 141 | combined_l = _create_weekly_rollingsum(combined_l) 142 | combined_l_headers = list( 143 | map( 144 | # f'\033[1m\033[4m{x}\033[0m' 145 | lambda x: f"{textstyle.BOLD}{textstyle.UNDERLINE}{textstyle.OKCYAN}{x}{textstyle.RESET}", 146 | ["Week#", "Score", "Cumulative"], 147 | ) 148 | ) 149 | else: 150 | combined_l_headers = list( 151 | map( 152 | # f'\033[1m\033[4m{x}\033[0m' 153 | lambda x: f"{textstyle.BOLD}{textstyle.UNDERLINE}{textstyle.OKCYAN}{x}{textstyle.RESET}", 154 | ["Date", "Score", "Cumulative"], 155 | ) 156 | ) 157 | 158 | _create_table_auto( 159 | combined_l, 160 | combined_l_headers, 161 | verbosity, 162 | total_completed, 163 | len(agg_date_dict), 164 | False, 165 | ) 166 | return completed 167 | 168 | 169 | if __name__ == "__main__": 170 | score_accum() 171 | -------------------------------------------------------------------------------- /taskquant/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onlyphantom/taskquant/df7eb5713053ad6bd1be6e51d75595835f2572e1/taskquant/utils/__init__.py -------------------------------------------------------------------------------- /taskquant/utils/colors.py: -------------------------------------------------------------------------------- 1 | """ 2 | Reference: 3 | # 1. https://i.stack.imgur.com/KTSQa.png 4 | # 2. https://i.stack.imgur.com/9UVnC.png 5 | 6 | Usage: 7 | print(f"{textstyle.BOLD}{textstyle.UNDERLINE}Welcome to TaskQuanT{textstyle.RESET}") 8 | -> print(f"\033[1m\033[4mWelcome to TaskQuant\033[0m") 9 | """ 10 | 11 | 12 | class textstyle: 13 | HEADER = "\033[95m" 14 | OKBLUE = "\033[94m" 15 | OKCYAN = "\033[96m" 16 | OKGREEN = "\033[92m" 17 | WARNING = "\033[93m" 18 | FAIL = "\033[91m" 19 | RESET = "\033[0m" 20 | BOLD = "\033[1m" 21 | UNDERLINE = "\033[4m" 22 | # nord colors: https://www.nordtheme.com/docs/colors-and-palettes 23 | # 38;2 -> foreground rgb // 48;2 -> background rgb 24 | NORDBG1 = "\033[38;2;67;76;94;48;2;143;188;187m" 25 | NORDBG2 = "\033[38;2;67;76;94;48;2;136;192;208m" 26 | NORDBG1BOLD = "\033[38;2;67;76;94;48;2;143;188;187m\033[1m" 27 | NORDBG2BOLD = "\033[38;2;67;76;94;48;2;136;192;208m\033[1m" 28 | -------------------------------------------------------------------------------- /taskquant/utils/create_table.py: -------------------------------------------------------------------------------- 1 | def create_table(table, headers=None): 2 | 3 | if headers: 4 | headerstring = "\t{}\t" * len(headers) 5 | print(headerstring.format(*headers)) 6 | 7 | rowstring = "\t{}\t" * len(table[0]) 8 | 9 | for row in table: 10 | print(rowstring.format(*row)) 11 | -------------------------------------------------------------------------------- /taskquant/utils/helpful.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def dir_path(string): 5 | """ 6 | Determine if string is a valid directory path 7 | """ 8 | if os.path.isdir(string): 9 | return string 10 | else: 11 | raise NotADirectoryError(string) 12 | # warnings.warn( 13 | # f"{textstyle.WARNING}{string} is not a valid directory, path will be defaulted to ~/.task{textstyle.RESET}", 14 | # ) 15 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onlyphantom/taskquant/df7eb5713053ad6bd1be6e51d75595835f2572e1/tests/__init__.py -------------------------------------------------------------------------------- /tests/test_accum.py: -------------------------------------------------------------------------------- 1 | from datetime import date, timedelta 2 | import unittest 3 | from unittest.mock import patch 4 | 5 | from taskquant.score.accum import ( 6 | score_accum, 7 | _extract_tasks, 8 | _task_to_dict, 9 | _create_full_date, 10 | _fill_rolling_date, 11 | _create_combined_table, 12 | _create_table_auto, 13 | _create_weekly_rollingsum, 14 | ) 15 | 16 | 17 | def diff_date(date1, date2): 18 | return abs((date1 - date2).days) 19 | 20 | 21 | def create_mock_fulldate(): 22 | today = date.today() 23 | fulldate = {} 24 | for i in range(0, 10): 25 | fulldate.update({today: i}) 26 | today += timedelta(days=1) 27 | return fulldate 28 | 29 | 30 | class TestAccum(unittest.TestCase): 31 | def test_invalid_path_warning(self): 32 | invalid_task_path = "tests/testdata/" 33 | 34 | with self.assertWarns(Warning): 35 | score_accum(task_path=invalid_task_path) 36 | 37 | def test_extract_tasks(self): 38 | task_path = "~/vaults/tasks" 39 | completed = _extract_tasks(task_path) 40 | self.assertGreater(len(completed), 0) 41 | 42 | def test_task_to_dict(self): 43 | task_path = "~/vaults/tasks" 44 | tasks = _extract_tasks(task_path) 45 | # days_apart = abs((tasks[-1]["end"] - tasks[0]["end"]).days) 46 | days_apart = diff_date(tasks[0]["end"], tasks[-1]["end"]) 47 | 48 | agg_date_dict, _, _ = _task_to_dict(tasks) 49 | self.assertEqual(len(agg_date_dict), days_apart) 50 | 51 | def test_create_full_date(self): 52 | task_path = "~/vaults/tasks" 53 | tasks = _extract_tasks(task_path) 54 | agg_date_dict, startdate, enddate = _task_to_dict(tasks) 55 | fulldate = _create_full_date(startdate, enddate, agg_date_dict) 56 | 57 | # expect number of keys to be equal to number of days between start and end date (inclusive, +1) 58 | expected_n_keys = diff_date(enddate, startdate) + 1 59 | self.assertEqual(len(fulldate), expected_n_keys) 60 | 61 | def test_fill_rolling_date(self): 62 | fulldate = create_mock_fulldate() 63 | rollingdate = _fill_rolling_date(fulldate) 64 | 65 | expected = sum(fulldate.values()) 66 | self.assertEqual(list(rollingdate.values())[-1], expected) 67 | 68 | self.assertEqual( 69 | list(rollingdate.values())[-2], sum(list(fulldate.values())[:-1]) 70 | ) 71 | 72 | def test_create_combined_table(self): 73 | fulldate = create_mock_fulldate() 74 | rollingdate = _fill_rolling_date(fulldate) 75 | combined_l = _create_combined_table(fulldate, rollingdate) 76 | 77 | expected = [date.today() + timedelta(days=9), 9, 45] 78 | self.assertListEqual(expected, combined_l[-1]) 79 | 80 | def test_create_table_auto(self): 81 | fulldate = create_mock_fulldate() 82 | rollingdate = _fill_rolling_date(fulldate) 83 | combined_l = _create_combined_table(fulldate, rollingdate) 84 | headers = ["Date", "Score", "Cumulative"] 85 | 86 | with patch("builtins.print") as mock_print: 87 | _create_table_auto(combined_l, headers, False, 9, 9, True) 88 | 89 | import sys 90 | 91 | print(str(mock_print.call_args_list[0])) 92 | expected_header = "\\t" + "\\t\\t".join(headers) + "\\t" 93 | mock_print.assert_called_with("call('{}')".format(expected_header)) 94 | 95 | print(str(mock_print.call_args_list[10])) 96 | expected_lastrow = "\\t".join( 97 | ["", str(date.today() + timedelta(days=9)), "", "9", "", "45", ""] 98 | ) 99 | mock_print.assert_called_with("call('{}')".format(expected_lastrow)) 100 | 101 | def test_weekly_flag(self): 102 | combined_l = [ 103 | [date(2022, 3, 9), 0, 0], 104 | [date(2022, 3, 10), 8, 8], 105 | [date(2022, 3, 11), 1, 9], 106 | [date(2022, 3, 12), 43, 52], 107 | [date(2022, 3, 13), 4, 56], 108 | [date(2022, 3, 14), 4, 60], 109 | [date(2022, 3, 15), 7, 67], 110 | [date(2022, 3, 16), 9, 76], 111 | [date(2022, 3, 17), 4, 80], 112 | [date(2022, 3, 18), 4, 84], 113 | [date(2022, 3, 19), 3, 87], 114 | [date(2022, 3, 20), 2, 89], 115 | [date(2022, 3, 21), 7, 96], 116 | [date(2022, 3, 22), 5, 101], 117 | [date(2022, 3, 23), 5, 106], 118 | [date(2022, 3, 24), 2, 108], 119 | [date(2022, 3, 25), 1, 109], 120 | [date(2022, 3, 26), 6, 115], 121 | [date(2022, 3, 27), 0, 115], 122 | [date(2022, 3, 28), 4, 119], 123 | [date(2022, 3, 29), 5, 124], 124 | [date(2022, 3, 30), 1, 125], 125 | [date(2022, 3, 31), 2, 127], 126 | [date(2022, 4, 1), 0, 127], 127 | [date(2022, 4, 2), 2, 129], 128 | ] 129 | actual = _create_weekly_rollingsum(combined_l) 130 | expected = [[10, 56, 56], [11, 33, 89], [12, 26, 115], [13, 14, 129]] 131 | 132 | self.assertListEqual(actual, expected) 133 | 134 | 135 | if __name__ == "__main__": 136 | unittest.main() 137 | --------------------------------------------------------------------------------