Test writing usage data to file
(self, mock_file, mock_touch, mock_makedirs)
| 344 | @patch("fastdeploy.usage.usage_lib.Path.touch") |
| 345 | @patch("fastdeploy.usage.usage_lib.open", new_callable=mock_open) |
| 346 | def test_write_to_file(self, mock_file, mock_touch, mock_makedirs): |
| 347 | """Test writing usage data to file""" |
| 348 | usage_message = UsageMessage() |
| 349 | data = {"uuid": "test-uuid", "timestamp": 1234567890} |
| 350 | |
| 351 | usage_message._write_to_file(data) |
| 352 | |
| 353 | # Verify file operations |
| 354 | mock_makedirs.assert_called_once() |
| 355 | mock_touch.assert_called_once() |
| 356 | |
| 357 | # Verify JSON was written |
| 358 | all_writes = [call.args[0] for call in mock_file().write.call_args_list] |
| 359 | full_content = "".join(all_writes) |
| 360 | self.assertEqual(json.loads(full_content), data) |
| 361 | |
| 362 | |
| 363 | class TestReportUsageWorker(unittest.TestCase): |
nothing calls this directly
no test coverage detected