|
3 | 3 |
|
4 | 4 | Tests cover: |
5 | 5 | - _rows_to_dicts helper function |
6 | | -- write_plain function |
7 | 6 | - write_json function |
8 | 7 | - write_csv function |
| 8 | +- write_rich_plain function |
9 | 9 | """ |
10 | 10 |
|
11 | 11 | import csv |
|
14 | 14 | import pytest |
15 | 15 | from unittest.mock import MagicMock, patch |
16 | 16 |
|
17 | | -from taskhound.output.writer import _rows_to_dicts, write_plain, write_json, write_csv |
| 17 | +from taskhound.output.writer import _rows_to_dicts, write_json, write_csv |
18 | 18 |
|
19 | 19 |
|
20 | 20 | # ============================================================================ |
@@ -91,65 +91,6 @@ def test_mixed_objects_and_dicts(self, sample_task_dict, sample_task_object): |
91 | 91 | assert result[1] == {"host": "WS01.example.com", "path": "\\MaintTask", "type": "TASK"} |
92 | 92 |
|
93 | 93 |
|
94 | | -# ============================================================================ |
95 | | -# Unit Tests: write_plain |
96 | | -# ============================================================================ |
97 | | - |
98 | | - |
99 | | -class TestWritePlain: |
100 | | - """Tests for write_plain function""" |
101 | | - |
102 | | - @patch('taskhound.output.writer.good') |
103 | | - def test_creates_output_directory(self, mock_good, temp_output_dir): |
104 | | - """Should create output directory if it doesn't exist""" |
105 | | - subdir = temp_output_dir / "subdir" |
106 | | - lines = ["Line 1", "Line 2"] |
107 | | - |
108 | | - write_plain(str(subdir), "host1", lines) |
109 | | - |
110 | | - assert subdir.exists() |
111 | | - |
112 | | - @patch('taskhound.output.writer.good') |
113 | | - def test_writes_lines_to_file(self, mock_good, temp_output_dir): |
114 | | - """Should write lines to file with newlines""" |
115 | | - lines = ["Line 1", "Line 2", "Line 3"] |
116 | | - |
117 | | - write_plain(str(temp_output_dir), "host1.example.com", lines) |
118 | | - |
119 | | - output_file = temp_output_dir / "host1.example.com.txt" |
120 | | - assert output_file.exists() |
121 | | - |
122 | | - content = output_file.read_text() |
123 | | - assert content == "Line 1\nLine 2\nLine 3\n" |
124 | | - |
125 | | - @patch('taskhound.output.writer.good') |
126 | | - def test_empty_lines_creates_file(self, mock_good, temp_output_dir): |
127 | | - """Should create file even with empty lines""" |
128 | | - write_plain(str(temp_output_dir), "host1", []) |
129 | | - |
130 | | - output_file = temp_output_dir / "host1.txt" |
131 | | - assert output_file.exists() |
132 | | - content = output_file.read_text() |
133 | | - assert content == "" |
134 | | - |
135 | | - @patch('taskhound.output.writer.good') |
136 | | - def test_colon_replaced_in_filename(self, mock_good, temp_output_dir): |
137 | | - """Should replace colons with underscores in filename""" |
138 | | - write_plain(str(temp_output_dir), "host:port", ["test"]) |
139 | | - |
140 | | - output_file = temp_output_dir / "host_port.txt" |
141 | | - assert output_file.exists() |
142 | | - |
143 | | - @patch('taskhound.output.writer.good') |
144 | | - def test_logs_success_message(self, mock_good, temp_output_dir): |
145 | | - """Should log success message""" |
146 | | - write_plain(str(temp_output_dir), "host1", ["test"]) |
147 | | - |
148 | | - mock_good.assert_called_once() |
149 | | - call_arg = mock_good.call_args[0][0] |
150 | | - assert "Wrote results to" in call_arg |
151 | | - |
152 | | - |
153 | 94 | # ============================================================================ |
154 | 95 | # Unit Tests: write_json |
155 | 96 | # ============================================================================ |
|
0 commit comments