|
1 | 1 | from django.test import TestCase |
2 | 2 |
|
3 | | -from django_mongodb_extensions.debug_toolbar.panels.mql.forms import MQLAggregateForm |
4 | 3 | from django_mongodb_extensions.debug_toolbar.panels.mql.utils import parse_query_args |
5 | 4 |
|
6 | 5 |
|
7 | | -class ConvertDocumentsToTableTests(TestCase): |
8 | | - def setUp(self): |
9 | | - self.form = MQLAggregateForm() |
10 | | - |
11 | | - def test_empty_documents(self): |
12 | | - """Empty document list returns empty rows and headers.""" |
13 | | - rows, headers = self.form.convert_documents_to_table([]) |
14 | | - self.assertEqual(rows, []) |
15 | | - self.assertEqual(headers, []) |
16 | | - |
17 | | - def test_handle_operation_error_format(self): |
18 | | - """Error return format matches convert_documents_to_table format.""" |
19 | | - error = ValueError("Test error") |
20 | | - mql_string = "db.test.aggregate([])" |
21 | | - rows, headers = self.form._handle_operation_error( |
22 | | - error, mql_string, "aggregate" |
23 | | - ) |
24 | | - |
25 | | - # Should return one row with one cell |
26 | | - self.assertEqual(len(rows), 1) |
27 | | - self.assertEqual(len(rows[0]), 1) |
28 | | - |
29 | | - # Cell should be a dict with 'value' and 'is_json' keys |
30 | | - cell = rows[0][0] |
31 | | - self.assertIsInstance(cell["value"], str) |
32 | | - self.assertIs(cell["is_json"], False) |
33 | | - |
34 | | - # Should have one header |
35 | | - self.assertEqual(headers[0], "Query Parsing Error") |
36 | | - |
37 | | - |
38 | 6 | class ParseQueryArgsTests(TestCase): |
39 | 7 | def test_unserializable_args(self): |
40 | 8 | """None mql_args_json raises ValueError to prevent replaying a different query.""" |
|
0 commit comments