diff options
| author | Grant Lanham <contact@grantlanham.com> | 2024-10-05 16:10:56 +0200 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-10-15 08:10:52 +0200 |
| commit | 3e87354f0ea62d5e2cf22bba136f0e5fdf71cb81 (patch) | |
| tree | fe3004ab9f7e3ef56c29b6d1b84d392fade1319f /tests/unit/test_plugin_calculator.py | |
| parent | d448def1a66afe9e0b702ac25ca921526a3f0ca2 (diff) | |
[fix] float operations in calculator plugin
This patch adds an additional *isinstance* check within the ast parser to check
for float along with int, fixing the underlying issue.
Co-Authored: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'tests/unit/test_plugin_calculator.py')
| -rw-r--r-- | tests/unit/test_plugin_calculator.py | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/tests/unit/test_plugin_calculator.py b/tests/unit/test_plugin_calculator.py index a26e78e1b..062624f03 100644 --- a/tests/unit/test_plugin_calculator.py +++ b/tests/unit/test_plugin_calculator.py @@ -42,20 +42,35 @@ class PluginCalculator(SearxTestCase): # pylint: disable=missing-class-docstrin @parameterized.expand( [ - "1+1", - "1-1", - "1*1", - "1/1", - "1**1", - "1^1", + ("1+1", "2", "en-US"), + ("1-1", "0", "en-US"), + ("1*1", "1", "en-US"), + ("1/1", "1", "en-US"), + ("1**1", "1", "en-US"), + ("1^1", "1", "en-US"), + ("1,000.0+1,000.0", "2,000", "en-US"), + ("1.0+1.0", "2", "en-US"), + ("1.0-1.0", "0", "en-US"), + ("1.0*1.0", "1", "en-US"), + ("1.0/1.0", "1", "en-US"), + ("1.0**1.0", "1", "en-US"), + ("1.0^1.0", "1", "en-US"), + ("1.000,0+1.000,0", "2.000", "de-DE"), + ("1,0+1,0", "2", "de-DE"), + ("1,0-1,0", "0", "de-DE"), + ("1,0*1,0", "1", "de-DE"), + ("1,0/1,0", "1", "de-DE"), + ("1,0**1,0", "1", "de-DE"), + ("1,0^1,0", "1", "de-DE"), ] ) - def test_int_operations(self, operation): + def test_localized_query(self, operation: str, contains_result: str, lang: str): request = Mock(remote_addr='127.0.0.1') - search = get_search_mock(query=operation, pageno=1) + search = get_search_mock(query=operation, lang=lang, pageno=1) result = self.store.call(self.store.plugins, 'post_search', request, search) self.assertTrue(result) self.assertIn('calculate', search.result_container.answers) + self.assertIn(contains_result, search.result_container.answers['calculate']['answer']) @parameterized.expand( [ |