Cannot unit test the uniqueness constraint in share and group types models

Bug #1843498 reported by Goutham Pacha Ravi on 2019-09-10
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

This bug is a result of the code review iterations on

There was a unit test added to check that, when a share type with name "ABC" exists, another share type's name cannot be updated to be "ABC". This collision in names is guarded by uniqueness constraints in the "share_types" and "share_group_types" tables [1][2][3][4].

However, unit tests run on Sqlite, and this constraint isn't holding.

The unit test that failed:


     def test_share_type_update_name_exist(self):
            name='exist_name', extra_specs={'somekey': 'someval'})
        share_type = db_utils.create_share_type(name='regalia')
        values = {"name": "exist_name"}
                          self.ctxt, share_type['id'], values)

Failure observed in the unit tests:

    Captured traceback:
    Traceback (most recent call last):
      File "manila/tests/db/sqlalchemy/", line 3285, in test_share_type_update_name_exist
        self.ctxt, share_type['id'], values)
      File "/home/zuul/src/", line 485, in assertRaises
        self.assertThat(our_callable, matcher)
      File "/home/zuul/src/", line 498, in assertThat
        raise mismatch_error
    testtools.matchers._impl.MismatchError: <function share_type_update at 0x7f8d9c0fd938> returned None


tags: added: low-hanging-fruit tests unit
Changed in manila:
importance: Undecided → Low
description: updated
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers