From 015bf2a4f2efe798d5d96797504b176596cdedfd Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 15 Nov 2024 11:21:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A(back)=20fix=20test=20related=20to?= =?UTF-8?q?=20postgres?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upgrading to postgresql 16.4 changes some error messages. We have to update them to ensure compoatibility with postgres 16.4 --- tests/apps/courses/test_models_licence.py | 18 +++++++++++++++--- tests/plugins/large_banner/test_cms_plugins.py | 5 ++++- tests/plugins/nesteditem/test_cms_plugins.py | 10 ++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/tests/apps/courses/test_models_licence.py b/tests/apps/courses/test_models_licence.py index d79e2300db..57f1793ed7 100644 --- a/tests/apps/courses/test_models_licence.py +++ b/tests/apps/courses/test_models_licence.py @@ -23,7 +23,11 @@ def test_models_license_fields_name_required(self): LicenceFactory(name=None) self.assertTrue( # Postgresql - 'null value in column "name" violates not-null' in str(cm.exception) + ( + 'null value in column "name" of relation "richie_licence_translation"' + " violates not-null constraint" + ) + in str(cm.exception) # Mysql or "Column 'name' cannot be null" in str(cm.exception) ) @@ -57,7 +61,11 @@ def test_models_license_fields_logo_required(self): self.assertTrue( # Postgresql - 'null value in column "logo_id" violates not-null' in str(cm.exception) + ( + 'null value in column "logo_id" of relation "richie_licence"' + " violates not-null constraint" + ) + in str(cm.exception) # Mysql or "Column 'logo_id' cannot be null" in str(cm.exception) ) @@ -71,7 +79,11 @@ def test_models_license_fields_content_required(self): self.assertTrue( # Postgresql - 'null value in column "content" violates not-null' in str(cm.exception) + ( + 'null value in column "content" of relation "richie_licence_translation"' + " violates not-null constraint" + ) + in str(cm.exception) # Mysql or "Column 'content' cannot be null" in str(cm.exception) ) diff --git a/tests/plugins/large_banner/test_cms_plugins.py b/tests/plugins/large_banner/test_cms_plugins.py index ec3cc51108..21ac67f95f 100644 --- a/tests/plugins/large_banner/test_cms_plugins.py +++ b/tests/plugins/large_banner/test_cms_plugins.py @@ -26,7 +26,10 @@ def test_cms_plugins_large_banner_title_required(self): with self.assertRaises(IntegrityError) as cm: LargeBannerFactory(title=None) self.assertTrue( - 'null value in column "title" violates not-null constraint' + ( + 'null value in column "title" of relation "large_banner_largebanner"' + " violates not-null constraint" + ) in str(cm.exception) or "Column 'title' cannot be null" in str(cm.exception) ) diff --git a/tests/plugins/nesteditem/test_cms_plugins.py b/tests/plugins/nesteditem/test_cms_plugins.py index 8bfca3815c..252fa150ae 100644 --- a/tests/plugins/nesteditem/test_cms_plugins.py +++ b/tests/plugins/nesteditem/test_cms_plugins.py @@ -24,7 +24,10 @@ def test_factory_nesteditem_content_required(self): with self.assertRaises(IntegrityError) as cm: NestedItemFactory(content=None) self.assertTrue( - 'null value in column "content" violates not-null constraint' + ( + 'null value in column "content" of relation "nesteditem_nesteditem"' + " violates not-null constraint" + ) in str(cm.exception) or "Column 'content' cannot be null" in str(cm.exception) ) @@ -37,7 +40,10 @@ def test_factory_nesteditem_variant_required(self): with self.assertRaises(IntegrityError) as cm: NestedItemFactory(variant=None) self.assertTrue( - 'null value in column "variant" violates not-null constraint' + ( + 'null value in column "variant" of relation "nesteditem_nesteditem"' + " violates not-null constraint" + ) in str(cm.exception) or "Column 'variant' cannot be null" in str(cm.exception) )