Skip to content

Commit df438b4

Browse files
committed
Update code
1 parent d50304f commit df438b4

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

backend/apps/owasp/models/project_health_metrics.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,10 @@ def generate_overview_pdf() -> BytesIO:
199199
],
200200
]
201201

202-
table = Table(table_data, colWidths="*")
203-
table.setStyle(
204-
TableStyle(
202+
table = Table(
203+
table_data,
204+
colWidths="*",
205+
style=TableStyle(
205206
[
206207
("BACKGROUND", (0, 0), (-1, 0), "lightgrey"),
207208
("TEXTCOLOR", (0, 0), (-1, 0), "black"),
@@ -210,7 +211,7 @@ def generate_overview_pdf() -> BytesIO:
210211
("BOTTOMPADDING", (0, 0), (-1, 0), 5),
211212
("BACKGROUND", (0, 1), (-1, -1), "white"),
212213
]
213-
)
214+
),
214215
)
215216
table.wrapOn(canvas, 400, 600)
216217
table.drawOn(canvas, 100, 570)

backend/tests/apps/owasp/models/project_health_metrics_test.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,18 @@ def test_handle_days_calculation(self, field_name, expected_days):
122122

123123
@patch("apps.owasp.models.project_health_metrics.ProjectHealthMetrics.get_stats")
124124
@patch("reportlab.pdfgen.canvas.Canvas")
125-
@patch("reportlab.platypus.tables.Table")
126-
@patch("reportlab.platypus.tables.TableStyle")
125+
@patch("reportlab.platypus.Table")
126+
@patch("reportlab.platypus.TableStyle")
127+
@patch("reportlab.platypus.tables.Table.setStyle")
127128
@patch("io.BytesIO")
128129
def test_generate_overview_pdf(
129-
self, mock_bytes_io, mock_table_style, mock_table, mock_canvas, mock_get_stats
130+
self,
131+
mock_bytes_io,
132+
mock_set_style,
133+
mock_table_style,
134+
mock_table,
135+
mock_canvas,
136+
mock_get_stats,
130137
):
131138
"""Test that the command executes without errors."""
132139
metrics_stats = ProjectHealthStatsNode(
@@ -167,7 +174,9 @@ def test_generate_overview_pdf(
167174
mock_bytes_io.assert_called_once()
168175
mock_canvas.assert_called_once_with(mock_bytes_io.return_value)
169176
canvas = mock_canvas.return_value
170-
mock_table.assert_called_once_with(table_data, colWidths="*")
177+
mock_table.assert_called_once_with(
178+
table_data, colWidths="*", style=mock_table_style.return_value
179+
)
171180
mock_table_style.assert_called_once()
172181
mock_table.return_value.wrapOn.assert_called_once_with(canvas, 400, 600)
173182
mock_table.return_value.drawOn.assert_called_once_with(canvas, 100, 570)

0 commit comments

Comments
 (0)