Example #1
0
 def update_classif_mru(self, user_id: UserIDT, project_id: ProjectIDT, last_used: ClassifIDListT):
     """
         Update recently used list for the user+project.
         :param user_id:
         :param project_id:
         :param last_used: The used classif_id, in time order, i.e. recents are in last. No guarantee
                 of uniqueness inside the list.
     """
     mru = UserBO.get_mru(self.session, user_id, project_id)
     mru = UserBO.merge_mru(mru, last_used)
     UserBO.set_mru(self.session, user_id, project_id, mru)
Example #2
0
def test_mru():
    # Basic addition
    before = [2, 4, 6, 7]
    new = [8, 9, 9]
    after = UserBO.merge_mru(before, new)
    assert after == [9, 8, 2, 4, 6, 7]
    # Already there
    before = [8, 9, 2, 4, 6, 7]
    new = [8, 9, 9]
    after = UserBO.merge_mru(before, new)
    assert after == [9, 8, 2, 4, 6, 7]
    # Already there further
    before = [8, 9, 2, 4, 6, 7]
    new = [8, 9, 9, 7]
    after = UserBO.merge_mru(before, new)
    assert after == [7, 9, 8, 2, 4, 6]
    # Over the limit
    before = [8, 9, 2, 4, 6, 7]
    new = [10, 11, 12, 13, 14, 17, 19]
    after = UserBO.merge_mru(before, new)
    assert after == [19, 17, 14, 13, 12, 11, 10, 8, 9, 2]