From dd3feb0891bf52b319c65a3de5a9e8ebbdc50e6e Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Thu, 16 Aug 2018 01:17:02 +0100 Subject: Reorganized window db function tests. --- tests/db_functions/test_window.py | 39 ---------------------------- tests/db_functions/window/__init__.py | 0 tests/db_functions/window/test_validation.py | 39 ++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 39 deletions(-) delete mode 100644 tests/db_functions/test_window.py create mode 100644 tests/db_functions/window/__init__.py create mode 100644 tests/db_functions/window/test_validation.py diff --git a/tests/db_functions/test_window.py b/tests/db_functions/test_window.py deleted file mode 100644 index 2efc88fdfa..0000000000 --- a/tests/db_functions/test_window.py +++ /dev/null @@ -1,39 +0,0 @@ -from django.db.models.functions import Lag, Lead, NthValue, Ntile -from django.test import SimpleTestCase - - -class ValidationTests(SimpleTestCase): - def test_nth_negative_nth_value(self): - msg = 'NthValue requires a positive integer as for nth' - with self.assertRaisesMessage(ValueError, msg): - NthValue(expression='salary', nth=-1) - - def test_nth_null_expression(self): - msg = 'NthValue requires a non-null source expression' - with self.assertRaisesMessage(ValueError, msg): - NthValue(expression=None) - - def test_lag_negative_offset(self): - msg = 'Lag requires a positive integer for the offset' - with self.assertRaisesMessage(ValueError, msg): - Lag(expression='salary', offset=-1) - - def test_lead_negative_offset(self): - msg = 'Lead requires a positive integer for the offset' - with self.assertRaisesMessage(ValueError, msg): - Lead(expression='salary', offset=-1) - - def test_null_source_lead(self): - msg = 'Lead requires a non-null source expression' - with self.assertRaisesMessage(ValueError, msg): - Lead(expression=None) - - def test_null_source_lag(self): - msg = 'Lag requires a non-null source expression' - with self.assertRaisesMessage(ValueError, msg): - Lag(expression=None) - - def test_negative_num_buckets_ntile(self): - msg = 'num_buckets must be greater than 0' - with self.assertRaisesMessage(ValueError, msg): - Ntile(num_buckets=-1) diff --git a/tests/db_functions/window/__init__.py b/tests/db_functions/window/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/db_functions/window/test_validation.py b/tests/db_functions/window/test_validation.py new file mode 100644 index 0000000000..2efc88fdfa --- /dev/null +++ b/tests/db_functions/window/test_validation.py @@ -0,0 +1,39 @@ +from django.db.models.functions import Lag, Lead, NthValue, Ntile +from django.test import SimpleTestCase + + +class ValidationTests(SimpleTestCase): + def test_nth_negative_nth_value(self): + msg = 'NthValue requires a positive integer as for nth' + with self.assertRaisesMessage(ValueError, msg): + NthValue(expression='salary', nth=-1) + + def test_nth_null_expression(self): + msg = 'NthValue requires a non-null source expression' + with self.assertRaisesMessage(ValueError, msg): + NthValue(expression=None) + + def test_lag_negative_offset(self): + msg = 'Lag requires a positive integer for the offset' + with self.assertRaisesMessage(ValueError, msg): + Lag(expression='salary', offset=-1) + + def test_lead_negative_offset(self): + msg = 'Lead requires a positive integer for the offset' + with self.assertRaisesMessage(ValueError, msg): + Lead(expression='salary', offset=-1) + + def test_null_source_lead(self): + msg = 'Lead requires a non-null source expression' + with self.assertRaisesMessage(ValueError, msg): + Lead(expression=None) + + def test_null_source_lag(self): + msg = 'Lag requires a non-null source expression' + with self.assertRaisesMessage(ValueError, msg): + Lag(expression=None) + + def test_negative_num_buckets_ntile(self): + msg = 'num_buckets must be greater than 0' + with self.assertRaisesMessage(ValueError, msg): + Ntile(num_buckets=-1) -- cgit v1.3