From 1e74a710e369c08f46dc61ac0f7ded56774fb132 Mon Sep 17 00:00:00 2001 From: Tai Sakuma Date: Sun, 9 Jun 2024 14:17:54 -0400 Subject: [PATCH] Rename `taskid` to `task_id` to correct a spellcheck error --- .vscode/settings.json | 1 - atpbar/main.py | 6 +- atpbar/presentation/barjupyter.py | 20 +++--- atpbar/presentation/bartty.py | 8 +-- atpbar/presentation/base.py | 20 +++--- atpbar/presentation/txtprint.py | 6 +- atpbar/progress_report/complement.py | 20 +++--- atpbar/progress_report/report.py | 4 +- atpbar/progress_report/reporter.py | 6 +- tests/presentation/test_ProgressPrint.py | 2 +- tests/presentation/test_base.py | 32 ++++----- tests/presentation/test_presentation.py | 26 +++++--- .../progress_report/test_report_complement.py | 66 +++++++++---------- tests/progress_report/test_reporter.py | 20 +++--- tests/scenarios/utils.py | 2 +- 15 files changed, 122 insertions(+), 117 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8befd37..a232079 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -45,6 +45,5 @@ "spyder", "starmap", "superfences", - "taskid" ] } diff --git a/atpbar/main.py b/atpbar/main.py index 2704f3f..51877a6 100644 --- a/atpbar/main.py +++ b/atpbar/main.py @@ -81,7 +81,7 @@ def _report_start(self) -> None: if self.reporter is None: return try: - report = Report(taskid=self.id_, name=self.name, done=0, total=self.len_) + report = Report(task_id=self.id_, name=self.name, done=0, total=self.len_) self.reporter.report(report) except BaseException: pass @@ -90,7 +90,7 @@ def _report_progress(self, i: int) -> None: if self.reporter is None: return try: - report = Report(taskid=self.id_, done=(i + 1)) + report = Report(task_id=self.id_, done=(i + 1)) self.reporter.report(report) except BaseException: pass @@ -113,7 +113,7 @@ def report_last(pbar: Atpbar[T]) -> Iterator[None]: if pbar.reporter is None: return try: - report = Report(taskid=pbar.id_, first=False, last=True) + report = Report(task_id=pbar.id_, first=False, last=True) pbar.reporter.report(report) except BaseException: pass diff --git a/atpbar/presentation/barjupyter.py b/atpbar/presentation/barjupyter.py index c125bff..624d0e5 100755 --- a/atpbar/presentation/barjupyter.py +++ b/atpbar/presentation/barjupyter.py @@ -30,8 +30,8 @@ def _create_widgets(self) -> None: self.container_widget = widgets.VBox() display(self.container_widget) - for taskid in self._new_task_ids: - report = self._report_dict[taskid] + for task_id in self._new_task_ids: + report = self._report_dict[task_id] self._create_widget(report) def _create_widget(self, report: Report) -> None: @@ -50,13 +50,13 @@ def _create_widget(self, report: Report) -> None: self.container_widget.children = ( self.complete_box_list + self.active_box_list ) - self.widget_dict[report['taskid']] = (box, bar, label) + self.widget_dict[report['task_id']] = (box, bar, label) def _update_widgets(self) -> None: - for taskid in ( + for task_id in ( self._finishing_task_ids + self._active_task_ids + self._new_task_ids ): - report = self._report_dict[taskid] + report = self._report_dict[task_id] self._update_widget(report) self._reorder_widgets(report) @@ -73,17 +73,17 @@ def _update_widget(self, report: Report) -> None: percent = round(percent * 100, 2) percent_fmt = '{:6.2f}%'.format(percent) - box = self.widget_dict[report['taskid']][0] + box = self.widget_dict[report['task_id']][0] box # to silence not-used warning - bar = self.widget_dict[report['taskid']][1] + bar = self.widget_dict[report['task_id']][1] bar.value = report['done'] bar.max = report['total'] bar.description = percent_fmt if report['last']: bar.bar_style = 'success' - label = self.widget_dict[report['taskid']][2] + label = self.widget_dict[report['task_id']][2] name_field_length = 32 percent = float(report['done']) / report['total'] if report['total'] > 0 else 1 bar = (':' * int(percent * 40)).ljust(40, ' ') @@ -94,8 +94,8 @@ def _update_widget(self, report: Report) -> None: ) def _reorder_widgets(self, report: Report) -> None: - for taskid in self._finishing_task_ids: - box, bar, label = self.widget_dict[taskid] + for task_id in self._finishing_task_ids: + box, bar, label = self.widget_dict[task_id] if box in self.active_box_list: self.active_box_list.remove(box) self.complete_box_list.append(box) diff --git a/atpbar/presentation/bartty.py b/atpbar/presentation/bartty.py index 8da2fcf..124e556 100755 --- a/atpbar/presentation/bartty.py +++ b/atpbar/presentation/bartty.py @@ -61,17 +61,17 @@ def _erase_active_bars(self) -> None: def _compose_just_finished_bars(self) -> None: self.just_finished_bars = [ - self._compose_bar_from_taskid(i) for i in self._finishing_task_ids + self._compose_bar_from_task_id(i) for i in self._finishing_task_ids ] def _compose_active_bars(self) -> None: self.active_bars = [ - self._compose_bar_from_taskid(i) + self._compose_bar_from_task_id(i) for i in self._active_task_ids + self._new_task_ids ] - def _compose_bar_from_taskid(self, taskid: UUID) -> str: - report = self._report_dict[taskid] + def _compose_bar_from_task_id(self, task_id: UUID) -> str: + report = self._report_dict[task_id] return self._compose_bar_from_report(report) def _compose_bar_from_report(self, report: Report) -> str: diff --git a/atpbar/presentation/base.py b/atpbar/presentation/base.py index 348ca07..bdc61ba 100755 --- a/atpbar/presentation/base.py +++ b/atpbar/presentation/base.py @@ -53,38 +53,38 @@ def _present(self, report: Report) -> None: def _register_report(self, report: Report) -> bool: - taskid = report['taskid'] + task_id = report['task_id'] - if taskid in self._complete_task_ids: + if task_id in self._complete_task_ids: return False - self._report_dict[taskid] = report + self._report_dict[task_id] = report - if taskid in self._finishing_task_ids: + if task_id in self._finishing_task_ids: return True if report['last']: try: - self._active_task_ids.remove(taskid) + self._active_task_ids.remove(task_id) except ValueError: pass try: - self._new_task_ids.remove(taskid) + self._new_task_ids.remove(task_id) except ValueError: pass - self._finishing_task_ids.append(taskid) + self._finishing_task_ids.append(task_id) return True - if taskid in self._active_task_ids: + if task_id in self._active_task_ids: return True - if taskid in self._new_task_ids: + if task_id in self._new_task_ids: return True - self._new_task_ids.append(taskid) + self._new_task_ids.append(task_id) return True def _update_registry(self) -> None: diff --git a/atpbar/presentation/txtprint.py b/atpbar/presentation/txtprint.py index 83a8083..30f1c68 100755 --- a/atpbar/presentation/txtprint.py +++ b/atpbar/presentation/txtprint.py @@ -23,7 +23,7 @@ def present(self, report: Report) -> None: self._present(report) - self.last_time_map[report['taskid']] = self._time() + self.last_time_map[report['task_id']] = self._time() def _present(self, report: Report) -> None: time_ = time.strftime('%m/%d %H:%M', time.localtime(time.time())) @@ -48,10 +48,10 @@ def _need_to_present_(self, report: Report) -> bool: if report['last']: return True - if report['taskid'] not in self.last_time_map: + if report['task_id'] not in self.last_time_map: return True - if self._time() - self.last_time_map[report['taskid']] > self.interval: + if self._time() - self.last_time_map[report['task_id']] > self.interval: return True return False diff --git a/atpbar/progress_report/complement.py b/atpbar/progress_report/complement.py index 350134f..13991e1 100755 --- a/atpbar/progress_report/complement.py +++ b/atpbar/progress_report/complement.py @@ -12,7 +12,7 @@ class ProgressReportComplementer: Parameters ---------- report : Report - A report must always include `taskid`. The first report for a task must + A report must always include `task_id`. The first report for a task must include `done`, `total`, and 'name'. The `first` and `last` will be automatically determined if not given. @@ -22,17 +22,17 @@ def __init__(self) -> None: self.previous_reports = dict[UUID, Report]() def __call__(self, report: Report) -> None: - taskid = report['taskid'] - if taskid in self.previous_reports: - self._complement(taskid, report) + task_id = report['task_id'] + if task_id in self.previous_reports: + self._complement(task_id, report) self._first(report) self._last(report) - self._store(taskid, report.copy()) + self._store(task_id, report.copy()) - def _complement(self, taskid: UUID, report: Report) -> None: + def _complement(self, task_id: UUID, report: Report) -> None: report_copy = report.copy() - report.update(Report(taskid=taskid)) - report.update(self.previous_reports[taskid]) + report.update(Report(task_id=task_id)) + report.update(self.previous_reports[task_id]) report.update(report_copy) def _first(self, report: Report) -> None: @@ -45,7 +45,7 @@ def _last(self, report: Report) -> None: return report['last'] = report['done'] >= report['total'] - def _store(self, taskid: UUID, report: Report) -> None: + def _store(self, task_id: UUID, report: Report) -> None: report.pop('first', None) report.pop('last', None) - self.previous_reports[taskid] = report + self.previous_reports[task_id] = report diff --git a/atpbar/progress_report/report.py b/atpbar/progress_report/report.py index 67ddd2d..e59d451 100644 --- a/atpbar/progress_report/report.py +++ b/atpbar/progress_report/report.py @@ -7,7 +7,7 @@ class Report(TypedDict, total=False): Parameters ---------- - taskid : immutable + task_id : immutable The unique task ID. done : int The number of the iterations done so far @@ -30,7 +30,7 @@ class Report(TypedDict, total=False): TODO: Use typing.Required for Python 3.11 and above ''' - taskid: UUID + task_id: UUID done: int total: int name: str diff --git a/atpbar/progress_report/reporter.py b/atpbar/progress_report/reporter.py index 588d8c2..b99a11f 100755 --- a/atpbar/progress_report/reporter.py +++ b/atpbar/progress_report/reporter.py @@ -81,7 +81,7 @@ def report(self, report: Report) -> None: self.queue.put(report) - self.last_time[report['taskid']] = time.time() + self.last_time[report['task_id']] = time.time() def _need_to_report(self, report: Report) -> bool: @@ -91,10 +91,10 @@ def _need_to_report(self, report: Report) -> bool: if report['last']: return True - if report['taskid'] not in self.last_time: + if report['task_id'] not in self.last_time: return True - if time.time() - self.last_time[report['taskid']] > self.interval: + if time.time() - self.last_time[report['task_id']] > self.interval: return True return False diff --git a/tests/presentation/test_ProgressPrint.py b/tests/presentation/test_ProgressPrint.py index eb7d8f5..e852512 100644 --- a/tests/presentation/test_ProgressPrint.py +++ b/tests/presentation/test_ProgressPrint.py @@ -24,7 +24,7 @@ def test_repr() -> None: def test_report(capsys: pytest.CaptureFixture) -> None: obj = ProgressPrint() i = uuid.uuid4() - report = Report(taskid=i, name='task1', done=0, total=10, first=True, last=False) + report = Report(task_id=i, name='task1', done=0, total=10, first=True, last=False) obj.present(report) captured = capsys.readouterr() stdout_lines = captured.out.strip().split('\n') diff --git a/tests/presentation/test_base.py b/tests/presentation/test_base.py index fc03e07..33aabd1 100644 --- a/tests/presentation/test_base.py +++ b/tests/presentation/test_base.py @@ -35,33 +35,33 @@ def test_repr(obj: MockProgressBar) -> None: def test_present(obj: Presentation) -> None: i = uuid.uuid4() j = uuid.uuid4() - obj.present(dict(taskid=i, last=False)) + obj.present(dict(task_id=i, last=False)) assert obj.active() - obj.present(dict(taskid=i, last=False)) + obj.present(dict(task_id=i, last=False)) assert obj.active() - obj.present(dict(taskid=j, last=False)) + obj.present(dict(task_id=j, last=False)) assert obj.active() - obj.present(dict(taskid=j, last=False)) + obj.present(dict(task_id=j, last=False)) assert obj.active() - obj.present(dict(taskid=i, last=True)) + obj.present(dict(task_id=i, last=True)) assert obj.active() - obj.present(dict(taskid=j, last=True)) + obj.present(dict(task_id=j, last=True)) assert not obj.active() params = [ ## - pytest.param(dict(taskid=1, last=False), [], [], [], [], [1], [], [], [], True), - pytest.param(dict(taskid=1, last=False), [1], [], [], [], [1], [], [], [], True), - pytest.param(dict(taskid=1, last=False), [], [1], [], [], [], [1], [], [], True), - pytest.param(dict(taskid=1, last=False), [], [], [1], [], [], [], [1], [], True), - pytest.param(dict(taskid=1, last=False), [], [], [], [1], [], [], [], [1], False), + pytest.param(dict(task_id=1, last=False), [], [], [], [], [1], [], [], [], True), + pytest.param(dict(task_id=1, last=False), [1], [], [], [], [1], [], [], [], True), + pytest.param(dict(task_id=1, last=False), [], [1], [], [], [], [1], [], [], True), + pytest.param(dict(task_id=1, last=False), [], [], [1], [], [], [], [1], [], True), + pytest.param(dict(task_id=1, last=False), [], [], [], [1], [], [], [], [1], False), ## - pytest.param(dict(taskid=1, last=True), [], [], [], [], [], [], [1], [], True), - pytest.param(dict(taskid=1, last=True), [1], [], [], [], [], [], [1], [], True), - pytest.param(dict(taskid=1, last=True), [], [1], [], [], [], [], [1], [], True), - pytest.param(dict(taskid=1, last=True), [], [], [1], [], [], [], [1], [], True), - pytest.param(dict(taskid=1, last=True), [], [], [], [1], [], [], [], [1], False), + pytest.param(dict(task_id=1, last=True), [], [], [], [], [], [], [1], [], True), + pytest.param(dict(task_id=1, last=True), [1], [], [], [], [], [], [1], [], True), + pytest.param(dict(task_id=1, last=True), [], [1], [], [], [], [], [1], [], True), + pytest.param(dict(task_id=1, last=True), [], [], [1], [], [], [], [1], [], True), + pytest.param(dict(task_id=1, last=True), [], [], [], [1], [], [], [], [1], False), ] param_names = ( 'report, ' diff --git a/tests/presentation/test_presentation.py b/tests/presentation/test_presentation.py index 0594a09..75b61b1 100644 --- a/tests/presentation/test_presentation.py +++ b/tests/presentation/test_presentation.py @@ -34,18 +34,24 @@ def test_presentation(Class: type[Presentation]) -> None: obj = Class() repr(obj) obj.active() - obj.present(dict(name='task1', done=0, total=10, taskid=i, first=True, last=False)) - obj.present(dict(name='task1', done=2, total=10, taskid=i, first=False, last=False)) + obj.present(dict(name='task1', done=0, total=10, task_id=i, first=True, last=False)) + obj.present( + dict(name='task1', done=2, total=10, task_id=i, first=False, last=False) + ) obj.active() - obj.present(dict(name='task1', done=0, total=5, taskid=j, first=True, last=False)) - obj.present(dict(name='task1', done=3, total=5, taskid=j, first=False, last=False)) + obj.present(dict(name='task1', done=0, total=5, task_id=j, first=True, last=False)) + obj.present(dict(name='task1', done=3, total=5, task_id=j, first=False, last=False)) obj.active() - obj.present(dict(name='task1', done=10, total=10, taskid=i, first=False, last=True)) + obj.present( + dict(name='task1', done=10, total=10, task_id=i, first=False, last=True) + ) obj.active() - obj.present(dict(name='task1', done=5, total=5, taskid=j, first=False, last=True)) + obj.present(dict(name='task1', done=5, total=5, task_id=j, first=False, last=True)) obj.active() obj.active() - obj.present(dict(name='task1', done=10, total=10, taskid=i, first=False, last=True)) + obj.present( + dict(name='task1', done=10, total=10, task_id=i, first=False, last=True) + ) obj.active() @@ -60,7 +66,7 @@ def test_time_track(Class: type[Presentation]) -> None: name='task1', done=0, total=10, - taskid=i, + task_id=i, first=True, last=False, ) @@ -70,7 +76,7 @@ def test_time_track(Class: type[Presentation]) -> None: name='task1', done=2, total=10, - taskid=i, + task_id=i, first=False, last=False, ) @@ -80,7 +86,7 @@ def test_time_track(Class: type[Presentation]) -> None: name='task1', done=10, total=10, - taskid=i, + task_id=i, first=False, last=True, ) diff --git a/tests/progress_report/test_report_complement.py b/tests/progress_report/test_report_complement.py index fd8037d..1195f5c 100644 --- a/tests/progress_report/test_report_complement.py +++ b/tests/progress_report/test_report_complement.py @@ -19,33 +19,33 @@ def test_repr(obj: ProgressReportComplementer) -> None: def test_complement(obj: ProgressReportComplementer) -> None: task_id = uuid.uuid4() - report0 = Report(taskid=task_id, done=0, total=10, name='task1') + report0 = Report(task_id=task_id, done=0, total=10, name='task1') expected0 = Report( - taskid=task_id, done=0, total=10, first=True, last=False, name='task1' + task_id=task_id, done=0, total=10, first=True, last=False, name='task1' ) obj(report0) assert expected0 == report0 - report1 = Report(taskid=task_id, done=1, total=12) + report1 = Report(task_id=task_id, done=1, total=12) expected1 = Report( - taskid=task_id, done=1, total=12, first=False, last=False, name='task1' + task_id=task_id, done=1, total=12, first=False, last=False, name='task1' ) obj(report1) assert expected0 == report0 assert expected1 == report1 - report2 = Report(taskid=task_id, done=2) + report2 = Report(task_id=task_id, done=2) expected2 = Report( - taskid=task_id, done=2, total=12, first=False, last=False, name='task1' + task_id=task_id, done=2, total=12, first=False, last=False, name='task1' ) obj(report2) assert expected0 == report0 assert expected1 == report1 assert expected2 == report2 - report3 = Report(taskid=task_id, done=12) + report3 = Report(task_id=task_id, done=12) expected3 = Report( - taskid=task_id, done=12, total=12, first=False, last=True, name='task1' + task_id=task_id, done=12, total=12, first=False, last=True, name='task1' ) obj(report3) assert expected0 == report0 @@ -57,21 +57,21 @@ def test_complement(obj: ProgressReportComplementer) -> None: def test_volatile_fields(obj: ProgressReportComplementer) -> None: task_id = uuid.uuid4() - report0 = Report(taskid=task_id, done=0, total=10, first=True) - expected0 = Report(taskid=task_id, done=0, total=10, first=True, last=False) + report0 = Report(task_id=task_id, done=0, total=10, first=True) + expected0 = Report(task_id=task_id, done=0, total=10, first=True, last=False) obj(report0) assert expected0 == report0 # manually set `first` - report1 = Report(taskid=task_id, done=1, total=12, first=True, last=False) - expected1 = Report(taskid=task_id, done=1, total=12, first=True, last=False) + report1 = Report(task_id=task_id, done=1, total=12, first=True, last=False) + expected1 = Report(task_id=task_id, done=1, total=12, first=True, last=False) obj(report1) assert expected0 == report0 assert expected1 == report1 # doesn't remember previously manually set `first` - report2 = Report(taskid=task_id, done=2) - expected2 = Report(taskid=task_id, done=2, total=12, first=False, last=False) + report2 = Report(task_id=task_id, done=2) + expected2 = Report(task_id=task_id, done=2, total=12, first=False, last=False) obj(report2) assert expected0 == report0 assert expected1 == report1 @@ -81,30 +81,30 @@ def test_volatile_fields(obj: ProgressReportComplementer) -> None: def test_first(obj: ProgressReportComplementer) -> None: task_id_1 = uuid.uuid4() - report0 = Report(taskid=task_id_1, done=0, total=10) - expected0 = Report(taskid=task_id_1, done=0, total=10, first=True, last=False) + report0 = Report(task_id=task_id_1, done=0, total=10) + expected0 = Report(task_id=task_id_1, done=0, total=10, first=True, last=False) obj(report0) assert expected0 == report0 - report1 = Report(taskid=task_id_1, done=1, total=12) - expected1 = Report(taskid=task_id_1, done=1, total=12, first=False, last=False) + report1 = Report(task_id=task_id_1, done=1, total=12) + expected1 = Report(task_id=task_id_1, done=1, total=12, first=False, last=False) obj(report1) assert expected1 == report1 - report2 = Report(taskid=task_id_1, done=2, first=True) - expected2 = Report(taskid=task_id_1, done=2, total=12, first=True, last=False) + report2 = Report(task_id=task_id_1, done=2, first=True) + expected2 = Report(task_id=task_id_1, done=2, total=12, first=True, last=False) obj(report2) assert expected2 == report2 - report3 = Report(taskid=task_id_1, done=3) - expected3 = Report(taskid=task_id_1, done=3, total=12, first=False, last=False) + report3 = Report(task_id=task_id_1, done=3) + expected3 = Report(task_id=task_id_1, done=3, total=12, first=False, last=False) obj(report3) assert expected3 == report3 - # different taskid, both done and total are 0 + # different task_id, both done and total are 0 task_id_2 = uuid.uuid4() - report4 = Report(taskid=task_id_2, done=0, total=0) - expected4 = Report(taskid=task_id_2, done=0, total=0, first=True, last=True) + report4 = Report(task_id=task_id_2, done=0, total=0) + expected4 = Report(task_id=task_id_2, done=0, total=0, first=True, last=True) obj(report4) assert expected4 == report4 @@ -112,25 +112,25 @@ def test_first(obj: ProgressReportComplementer) -> None: def test_last(obj: ProgressReportComplementer) -> None: task_id_1 = uuid.uuid4() - report0 = Report(taskid=task_id_1, done=0, total=10) - expected0 = Report(taskid=task_id_1, done=0, total=10, first=True, last=False) + report0 = Report(task_id=task_id_1, done=0, total=10) + expected0 = Report(task_id=task_id_1, done=0, total=10, first=True, last=False) obj(report0) assert expected0 == report0 # set `last` manually - report1 = Report(taskid=task_id_1, done=1, total=12, last=True) - expected1 = Report(taskid=task_id_1, done=1, total=12, first=False, last=True) + report1 = Report(task_id=task_id_1, done=1, total=12, last=True) + expected1 = Report(task_id=task_id_1, done=1, total=12, first=False, last=True) obj(report1) assert expected1 == report1 task_id_2 = uuid.uuid4() - report2 = Report(taskid=task_id_2, done=0, total=10) - expected2 = Report(taskid=task_id_2, done=0, total=10, first=True, last=False) + report2 = Report(task_id=task_id_2, done=0, total=10) + expected2 = Report(task_id=task_id_2, done=0, total=10, first=True, last=False) obj(report2) assert expected2 == report2 # done = total - report3 = Report(taskid=task_id_2, done=10, total=10) - expected3 = Report(taskid=task_id_2, done=10, total=10, first=False, last=True) + report3 = Report(task_id=task_id_2, done=10, total=10) + expected3 = Report(task_id=task_id_2, done=10, total=10, first=False, last=True) obj(report3) assert expected3 == report3 diff --git a/tests/progress_report/test_reporter.py b/tests/progress_report/test_reporter.py index d8eefc0..80d46d6 100644 --- a/tests/progress_report/test_reporter.py +++ b/tests/progress_report/test_reporter.py @@ -44,13 +44,13 @@ def test_report_need_to_report( mock_time: mock.Mock, ) -> None: current_time = 15324.345 - taskid = uuid.uuid4() + task_id = uuid.uuid4() mock_time.time.return_value = current_time monkeypatch.setattr(obj, '_need_to_report', mock.Mock(return_value=True)) - report = Report(taskid=taskid, done=0, total=10) + report = Report(task_id=task_id, done=0, total=10) obj.report(report) assert [mock.call(report)] == mock_queue.put.call_args_list - assert {taskid: current_time} == obj.last_time + assert {task_id: current_time} == obj.last_time def test_report_no_need_to_report( self, @@ -60,10 +60,10 @@ def test_report_no_need_to_report( mock_time: mock.Mock, ) -> None: current_time = 15324.345 - taskid = uuid.uuid4() + task_id = uuid.uuid4() mock_time.time.return_value = current_time monkeypatch.setattr(obj, '_need_to_report', mock.Mock(return_value=False)) - report = Report(taskid=taskid, done=0, total=10) + report = Report(task_id=task_id, done=0, total=10) obj.report(report) assert [] == mock_queue.put.call_args_list assert {} == obj.last_time @@ -72,16 +72,16 @@ def test_report_no_need_to_report( task_id = uuid.uuid4() params = [ - pytest.param(Report(taskid=task_id, first=True, last=False), {}, 10.0, True), - pytest.param(Report(taskid=task_id, first=False, last=True), {}, 10.0, True), + pytest.param(Report(task_id=task_id, first=True, last=False), {}, 10.0, True), + pytest.param(Report(task_id=task_id, first=False, last=True), {}, 10.0, True), pytest.param( - Report(taskid=task_id, first=True, last=False), {task_id: 10.0}, 10.0, True + Report(task_id=task_id, first=True, last=False), {task_id: 10.0}, 10.0, True ), pytest.param( - Report(taskid=task_id, first=False, last=False), {task_id: 10.0}, 30.0, True + Report(task_id=task_id, first=False, last=False), {task_id: 10.0}, 30.0, True ), pytest.param( - Report(taskid=task_id, first=False, last=False), {task_id: 10.0}, 15.0, False + Report(task_id=task_id, first=False, last=False), {task_id: 10.0}, 15.0, False ), ] param_names = 'report, last_time, current_time, expected' diff --git a/tests/scenarios/utils.py b/tests/scenarios/utils.py index a78a905..af050e9 100644 --- a/tests/scenarios/utils.py +++ b/tests/scenarios/utils.py @@ -34,7 +34,7 @@ def __str__(self) -> str: def present(self, report: Report) -> None: super().present(report) self.reports.append(report) - self.task_ids.add(report['taskid']) + self.task_ids.add(report['task_id']) self.n_firsts += report['first'] self.n_lasts += report['last']