Skip to content

Commit 7a16f00

Browse files
committed
Refactor tests
1 parent 40eef2d commit 7a16f00

File tree

2 files changed

+1
-56
lines changed

2 files changed

+1
-56
lines changed

tests/mql_panel/test_forms.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django_mongodb_extensions.mql_panel.forms import MQLQueryForm
88

99

10-
class ConvertDocumentsToTableTests(TestCase):
10+
class MQLPanelTests(TestCase):
1111
def setUp(self):
1212
self.form = MQLQueryForm()
1313

@@ -17,31 +17,6 @@ def test_empty_documents(self):
1717
self.assertEqual(rows, [])
1818
self.assertEqual(headers, [])
1919

20-
def test_handle_operation_error_format(self):
21-
"""Error return format matches convert_documents_to_table format."""
22-
error = ValueError("Test error")
23-
mql_string = "db.test.aggregate([])"
24-
rows, headers = self.form._handle_operation_error(
25-
error, mql_string, "aggregate"
26-
)
27-
28-
# Should return one row with one cell
29-
self.assertEqual(len(rows), 1)
30-
self.assertEqual(len(rows[0]), 1)
31-
32-
# Cell should be a dict with 'value' and 'is_json' keys
33-
cell = rows[0][0]
34-
self.assertIsInstance(cell["value"], str)
35-
self.assertIs(cell["is_json"], False)
36-
37-
# Should have one header
38-
self.assertEqual(headers[0], "Query Parsing Error")
39-
40-
41-
class FormatCellValueTests(TestCase):
42-
def setUp(self):
43-
self.form = MQLQueryForm()
44-
4520
def test_simple_fields(self):
4621
"""Primitive field values like in model query output."""
4722
cases = [

tests/mql_panel/test_panel.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from django.test import RequestFactory, TestCase, override_settings
55

66
from django_mongodb_extensions.mql_panel import MQLPanel
7-
from django_mongodb_extensions.mql_panel.forms import MQLQueryForm
87

98
rf = RequestFactory()
109

@@ -139,32 +138,3 @@ def test_query_width_ratio(self):
139138
self.panel.generate_stats(self.request, response)
140139
total_width = sum(q["width_ratio"] for q in self.panel._queries)
141140
self.assertAlmostEqual(total_width, 100, places=5)
142-
143-
144-
class ConvertDocumentsToTableTests(TestCase):
145-
def setUp(self):
146-
self.form = MQLQueryForm()
147-
148-
def test_empty_documents(self):
149-
"""Empty document list returns empty rows and headers."""
150-
rows, headers = self.form.convert_documents_to_table([])
151-
self.assertEqual(rows, [])
152-
self.assertEqual(headers, [])
153-
154-
def test_handle_operation_error_format(self):
155-
"""Error return format matches convert_documents_to_table format."""
156-
error = ValueError("Test error")
157-
mql_string = "db.test.aggregate([])"
158-
rows, headers = self.form._handle_operation_error(error, mql_string, "query")
159-
160-
# Should return one row with one cell
161-
self.assertEqual(len(rows), 1)
162-
self.assertEqual(len(rows[0]), 1)
163-
164-
# Cell should be a dict with 'value' and 'is_json' keys
165-
cell = rows[0][0]
166-
self.assertIsInstance(cell["value"], str)
167-
self.assertIs(cell["is_json"], False)
168-
169-
# Should have one header
170-
self.assertEqual(headers[0], "Query Parsing Error")

0 commit comments

Comments
 (0)