1
+ import os
2
+ import pytest
3
+ from merge import Merge
4
+ from merge .resources .knowledgebase .resources .articles .types .articles_list_request_expand import ArticlesListRequestExpand
5
+ from merge .resources .knowledgebase .resources .articles .types .articles_retrieve_request_expand import ArticlesRetrieveRequestExpand
6
+ from merge .resources .knowledgebase .resources .containers .types .containers_list_request_expand import ContainersListRequestExpand
7
+ from merge .resources .knowledgebase .resources .containers .types .containers_retrieve_request_expand import ContainersRetrieveRequestExpand
8
+ from merge .resources .knowledgebase .resources .groups .types .groups_list_request_expand import GroupsListRequestExpand
9
+ from merge .resources .knowledgebase .resources .groups .types .groups_retrieve_request_expand import GroupsRetrieveRequestExpand
10
+
11
+
12
+ @pytest .fixture
13
+ def client ():
14
+ account_token = os .environ ["SDK_TESTING_KNOWLEDGEBASE_ACCOUNT_TOKEN" ]
15
+ api_key = os .environ ["SDK_TESTING_KEY" ]
16
+
17
+ return Merge (
18
+ account_token = account_token ,
19
+ api_key = api_key ,
20
+ )
21
+
22
+ def test_articles_list (client ):
23
+ response = client .knowledgebase .articles .list ()
24
+ assert response is not None
25
+ assert hasattr (response , 'results' )
26
+ assert isinstance (response .results , list )
27
+
28
+
29
+ def test_articles_retrieve (client ):
30
+ articles_response = client .knowledgebase .articles .list (page_size = 1 )
31
+
32
+ assert articles_response .results , "No articles available to test retrieve"
33
+
34
+ article_id = articles_response .results [0 ].id
35
+ article = client .knowledgebase .articles .retrieve (id = article_id )
36
+
37
+ assert article is not None
38
+ assert article .id == article_id
39
+
40
+ def test_articles_list_with_expand_author (client ):
41
+ response = client .knowledgebase .articles .list (expand = ArticlesListRequestExpand .AUTHOR )
42
+ assert response is not None
43
+ assert hasattr (response , 'results' )
44
+ assert isinstance (response .results , list )
45
+
46
+ def test_articles_list_with_expand_attachments (client ):
47
+ response = client .knowledgebase .articles .list (expand = ArticlesListRequestExpand .ATTACHMENTS )
48
+ assert response is not None
49
+ assert hasattr (response , 'results' )
50
+ assert isinstance (response .results , list )
51
+
52
+ def test_articles_list_with_expand_permissions (client ):
53
+ response = client .knowledgebase .articles .list (expand = ArticlesListRequestExpand .PERMISSIONS )
54
+ assert response is not None
55
+ assert hasattr (response , 'results' )
56
+ assert isinstance (response .results , list )
57
+
58
+ def test_articles_retrieve_with_expand_author (client ):
59
+ articles_response = client .knowledgebase .articles .list (page_size = 1 )
60
+
61
+ if articles_response .results :
62
+ article_id = articles_response .results [0 ].id
63
+ article = client .knowledgebase .articles .retrieve (id = article_id , expand = ArticlesRetrieveRequestExpand .AUTHOR )
64
+ assert article is not None
65
+ assert article .id == article_id
66
+
67
+ def test_articles_retrieve_with_expand_attachments (client ):
68
+ articles_response = client .knowledgebase .articles .list (page_size = 1 )
69
+
70
+ if articles_response .results :
71
+ article_id = articles_response .results [0 ].id
72
+ article = client .knowledgebase .articles .retrieve (id = article_id , expand = ArticlesRetrieveRequestExpand .ATTACHMENTS )
73
+ assert article is not None
74
+ assert article .id == article_id
75
+
76
+ def test_attachments_list (client ):
77
+ response = client .knowledgebase .attachments .list ()
78
+ assert response is not None
79
+ assert hasattr (response , 'results' )
80
+ assert isinstance (response .results , list )
81
+
82
+ def test_attachments_retrieve (client ):
83
+ attachments_response = client .knowledgebase .attachments .list (page_size = 1 )
84
+
85
+ if attachments_response .results :
86
+ attachment_id = attachments_response .results [0 ].id
87
+ attachment = client .knowledgebase .attachments .retrieve (id = attachment_id )
88
+ assert attachment is not None
89
+ assert attachment .id == attachment_id
90
+
91
+ def test_containers_list (client ):
92
+ response = client .knowledgebase .containers .list ()
93
+ assert response is not None
94
+ assert hasattr (response , 'results' )
95
+ assert isinstance (response .results , list )
96
+
97
+ def test_containers_retrieve (client ):
98
+ containers_response = client .knowledgebase .containers .list (page_size = 1 )
99
+
100
+ if containers_response .results :
101
+ container_id = containers_response .results [0 ].id
102
+ container = client .knowledgebase .containers .retrieve (id = container_id )
103
+ assert container is not None
104
+ assert container .id == container_id
105
+
106
+ def test_containers_list_with_expand_permissions (client ):
107
+ response = client .knowledgebase .containers .list (expand = ContainersListRequestExpand .PERMISSIONS )
108
+ assert response is not None
109
+ assert hasattr (response , 'results' )
110
+ assert isinstance (response .results , list )
111
+
112
+ def test_containers_list_with_expand_parent_container (client ):
113
+ response = client .knowledgebase .containers .list (expand = ContainersListRequestExpand .PARENT_CONTAINER )
114
+ assert response is not None
115
+ assert hasattr (response , 'results' )
116
+ assert isinstance (response .results , list )
117
+
118
+ def test_containers_retrieve_with_expand_permissions (client ):
119
+ containers_response = client .knowledgebase .containers .list (page_size = 1 )
120
+
121
+ if containers_response .results :
122
+ container_id = containers_response .results [0 ].id
123
+ container = client .knowledgebase .containers .retrieve (id = container_id , expand = ContainersRetrieveRequestExpand .PERMISSIONS )
124
+ assert container is not None
125
+ assert container .id == container_id
126
+
127
+ def test_containers_retrieve_with_expand_parent_container (client ):
128
+ containers_response = client .knowledgebase .containers .list (page_size = 1 )
129
+
130
+ if containers_response .results :
131
+ container_id = containers_response .results [0 ].id
132
+ container = client .knowledgebase .containers .retrieve (id = container_id , expand = ContainersRetrieveRequestExpand .PARENT_CONTAINER )
133
+ assert container is not None
134
+ assert container .id == container_id
135
+
136
+ def test_sync_status_list (client ):
137
+ response = client .knowledgebase .sync_status .list ()
138
+ assert response is not None
139
+ assert hasattr (response , 'results' )
140
+ assert isinstance (response .results , list )
141
+
142
+ def test_account_details_retrieve (client ):
143
+ account_details = client .knowledgebase .account_details .retrieve ()
144
+ assert account_details is not None
145
+ assert hasattr (account_details , 'id' )
146
+
147
+ def test_users_list (client ):
148
+ response = client .knowledgebase .users .list ()
149
+ assert response is not None
150
+ assert hasattr (response , 'results' )
151
+ assert isinstance (response .results , list )
152
+
153
+ def test_users_retrieve (client ):
154
+ users_response = client .knowledgebase .users .list (page_size = 1 )
155
+
156
+ if users_response .results :
157
+ user_id = users_response .results [0 ].id
158
+ user = client .knowledgebase .users .retrieve (id = user_id )
159
+
160
+ assert user is not None
161
+ assert user .id == user_id
162
+
163
+ def test_groups_list (client ):
164
+ response = client .knowledgebase .groups .list ()
165
+ assert response is not None
166
+ assert hasattr (response , 'results' )
167
+ assert isinstance (response .results , list )
168
+
169
+ def test_groups_list_with_expand_users (client ):
170
+ response = client .knowledgebase .groups .list (expand = GroupsListRequestExpand .USERS )
171
+ assert response is not None
172
+ assert hasattr (response , 'results' )
173
+ assert isinstance (response .results , list )
174
+
175
+ def test_groups_list_with_expand_parent_group (client ):
176
+ response = client .knowledgebase .groups .list (expand = GroupsListRequestExpand .PARENT_GROUP )
177
+ assert response is not None
178
+ assert hasattr (response , 'results' )
179
+ assert isinstance (response .results , list )
180
+
181
+ def test_groups_retrieve_with_expand_users (client ):
182
+ groups_response = client .knowledgebase .groups .list (page_size = 1 )
183
+
184
+ if groups_response .results :
185
+ group_id = groups_response .results [0 ].id
186
+ group = client .knowledgebase .groups .retrieve (id = group_id , expand = GroupsRetrieveRequestExpand .USERS )
187
+ assert group is not None
188
+ assert group .id == group_id
189
+
190
+ def test_groups_retrieve_with_expand_parent_group (client ):
191
+ groups_response = client .knowledgebase .groups .list (page_size = 1 )
192
+
193
+ if groups_response .results :
194
+ group_id = groups_response .results [0 ].id
195
+ group = client .knowledgebase .groups .retrieve (id = group_id , expand = GroupsRetrieveRequestExpand .PARENT_GROUP )
196
+ assert group is not None
197
+ assert group .id == group_id
198
+
199
+ def test_audit_trail_list (client ):
200
+ response = client .knowledgebase .audit_trail .list ()
201
+ assert response is not None
202
+ assert hasattr (response , 'results' )
203
+ assert isinstance (response .results , list )
204
+
205
+ def test_available_actions_retrieve (client ):
206
+ available_actions = client .knowledgebase .available_actions .retrieve ()
207
+
208
+ assert available_actions is not None
209
+
210
+ def test_linked_accounts_list (client ):
211
+ response = client .knowledgebase .linked_accounts .list ()
212
+
213
+ assert response is not None
214
+ assert hasattr (response , 'results' )
215
+ assert isinstance (response .results , list )
216
+
217
+ def test_scopes_default_scopes_retrieve (client ):
218
+ response = client .knowledgebase .scopes .default_scopes_retrieve ()
219
+
220
+ assert response is not None
221
+
222
+ def test_scopes_linked_account_scopes_retrieve (client ):
223
+ response = client .knowledgebase .scopes .linked_account_scopes_retrieve ()
224
+
225
+ assert response is not None
0 commit comments