|
@@ -2057,6 +2057,101 @@ class TestContentApi(DefaultTest):
|
2057
|
2057
|
# (workspace2)
|
2058
|
2058
|
assert last_actives[8] == main_folder_workspace2
|
2059
|
2059
|
|
|
2060
|
+ def test_unit__get_last_active__ok__do_no_show_deleted_archived(self):
|
|
2061
|
+ uapi = UserApi(
|
|
2062
|
+ session=self.session,
|
|
2063
|
+ config=self.app_config,
|
|
2064
|
+ current_user=None,
|
|
2065
|
+ )
|
|
2066
|
+ group_api = GroupApi(
|
|
2067
|
+ current_user=None,
|
|
2068
|
+ session=self.session,
|
|
2069
|
+ config=self.app_config,
|
|
2070
|
+ )
|
|
2071
|
+ groups = [group_api.get_one(Group.TIM_USER),
|
|
2072
|
+ group_api.get_one(Group.TIM_MANAGER),
|
|
2073
|
+ group_api.get_one(Group.TIM_ADMIN)]
|
|
2074
|
+
|
|
2075
|
+ user = uapi.create_minimal_user(email='this.is@user',
|
|
2076
|
+ groups=groups, save_now=True)
|
|
2077
|
+ workspace = WorkspaceApi(
|
|
2078
|
+ current_user=user,
|
|
2079
|
+ session=self.session,
|
|
2080
|
+ config=self.app_config,
|
|
2081
|
+ ).create_workspace(
|
|
2082
|
+ 'test workspace',
|
|
2083
|
+ save_now=True
|
|
2084
|
+ )
|
|
2085
|
+ workspace2 = WorkspaceApi(
|
|
2086
|
+ current_user=user,
|
|
2087
|
+ session=self.session,
|
|
2088
|
+ config=self.app_config,
|
|
2089
|
+ ).create_workspace(
|
|
2090
|
+ 'test workspace2',
|
|
2091
|
+ save_now=True
|
|
2092
|
+ )
|
|
2093
|
+
|
|
2094
|
+ api = ContentApi(
|
|
2095
|
+ current_user=user,
|
|
2096
|
+ session=self.session,
|
|
2097
|
+ config=self.app_config,
|
|
2098
|
+ show_deleted=False,
|
|
2099
|
+ show_archived=False,
|
|
2100
|
+ )
|
|
2101
|
+ main_folder = api.create(CONTENT_TYPES.Folder.slug, workspace, None, 'this is randomized folder', '', True) # nopep8
|
|
2102
|
+ archived = api.create(CONTENT_TYPES.Page.slug, workspace, main_folder, 'archived', '', True) # nopep8
|
|
2103
|
+ deleted = api.create(CONTENT_TYPES.Page.slug, workspace, main_folder, 'deleted', '', True) # nopep8
|
|
2104
|
+ comment_archived = api.create_comment(workspace, parent=archived, content='just a comment', do_save=True) # nopep8
|
|
2105
|
+ comment_deleted = api.create_comment(workspace, parent=deleted, content='just a comment', do_save=True) # nopep8
|
|
2106
|
+ with new_revision(
|
|
2107
|
+ session=self.session,
|
|
2108
|
+ tm=transaction.manager,
|
|
2109
|
+ content=archived,
|
|
2110
|
+ ):
|
|
2111
|
+ api.archive(archived)
|
|
2112
|
+ api.save(archived)
|
|
2113
|
+
|
|
2114
|
+ with new_revision(
|
|
2115
|
+ session=self.session,
|
|
2116
|
+ tm=transaction.manager,
|
|
2117
|
+ content=deleted,
|
|
2118
|
+ ):
|
|
2119
|
+ api.delete(deleted)
|
|
2120
|
+ api.save(deleted)
|
|
2121
|
+ normal = api.create(CONTENT_TYPES.Page.slug, workspace, main_folder, 'normal', '', True) # nopep8
|
|
2122
|
+ comment_normal = api.create_comment(workspace, parent=normal, content='just a comment', do_save=True) # nopep8
|
|
2123
|
+
|
|
2124
|
+ last_actives = api.get_last_active()
|
|
2125
|
+ assert len(last_actives) == 2
|
|
2126
|
+ assert last_actives[0].content_id == normal.content_id
|
|
2127
|
+ assert last_actives[1].content_id == main_folder.content_id
|
|
2128
|
+
|
|
2129
|
+
|
|
2130
|
+ api._show_deleted = True
|
|
2131
|
+ api._show_archived = False
|
|
2132
|
+ last_actives = api.get_last_active()
|
|
2133
|
+ assert len(last_actives) == 3
|
|
2134
|
+ assert last_actives[0] == normal
|
|
2135
|
+ assert last_actives[1] == deleted
|
|
2136
|
+ assert last_actives[2] == main_folder
|
|
2137
|
+
|
|
2138
|
+ api._show_deleted = False
|
|
2139
|
+ api._show_archived = True
|
|
2140
|
+ last_actives = api.get_last_active()
|
|
2141
|
+ assert len(last_actives) == 3
|
|
2142
|
+ assert last_actives[0]== normal
|
|
2143
|
+ assert last_actives[1] == archived
|
|
2144
|
+ assert last_actives[2] == main_folder
|
|
2145
|
+
|
|
2146
|
+ api._show_deleted = True
|
|
2147
|
+ api._show_archived = True
|
|
2148
|
+ last_actives = api.get_last_active()
|
|
2149
|
+ assert len(last_actives) == 4
|
|
2150
|
+ assert last_actives[0] == normal
|
|
2151
|
+ assert last_actives[1] == deleted
|
|
2152
|
+ assert last_actives[2] == archived
|
|
2153
|
+ assert last_actives[3] == main_folder
|
|
2154
|
+
|
2060
|
2155
|
def test_unit__get_last_active__ok__workspace_filter_workspace_full(self):
|
2061
|
2156
|
uapi = UserApi(
|
2062
|
2157
|
session=self.session,
|