Skip to content

Commit

Permalink
💚(back) fix test related to postgres
Browse files Browse the repository at this point in the history
Upgrading to postgresql 16.4 changes some error messages. We have to
update them to ensure compoatibility with postgres 16.4
  • Loading branch information
lunika authored and claudusd committed Nov 18, 2024
1 parent 931c14a commit 015bf2a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
18 changes: 15 additions & 3 deletions tests/apps/courses/test_models_licence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down Expand Up @@ -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)
)
Expand All @@ -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)
)
Expand Down
5 changes: 4 additions & 1 deletion tests/plugins/large_banner/test_cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
10 changes: 8 additions & 2 deletions tests/plugins/nesteditem/test_cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand All @@ -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)
)
Expand Down

0 comments on commit 015bf2a

Please sign in to comment.