Skip to content

Commit 0620377

Browse files
committed
test: improve tests
test_cache_strategy was incorrectly reverting updates in test. There is an issue in permissions tests. The issue will be resolved later. For now, it is only documented. JIRA: TRIVIAL
1 parent 5dc666a commit 0620377

3 files changed

Lines changed: 26 additions & 197 deletions

File tree

gooddata-sdk/tests/catalog/fixtures/data_sources/demo_cache_strategy.yaml

Lines changed: 19 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -80,92 +80,9 @@ interactions:
8080
url: jdbc:postgresql://localhost:5432/demo
8181
username: demouser
8282
enableCaching: false
83-
type: POSTGRESQL
84-
schema: demo
8583
name: demo-test-ds
86-
links:
87-
self: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
88-
- request:
89-
method: GET
90-
uri: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
91-
body: null
92-
headers:
93-
Accept:
94-
- application/vnd.gooddata.api+json
95-
Accept-Encoding:
96-
- br, gzip, deflate
97-
X-GDC-VALIDATE-RELATIONS:
98-
- 'true'
99-
X-Requested-With:
100-
- XMLHttpRequest
101-
response:
102-
status:
103-
code: 200
104-
message: OK
105-
headers:
106-
Access-Control-Allow-Credentials:
107-
- 'true'
108-
Access-Control-Expose-Headers:
109-
- Content-Disposition, Content-Length, Content-Range, Set-Cookie
110-
Cache-Control:
111-
- no-cache, no-store, max-age=0, must-revalidate
112-
Connection:
113-
- keep-alive
114-
Content-Length:
115-
- '295'
116-
Content-Security-Policy:
117-
- 'default-src ''self'' *.wistia.com *.wistia.net; script-src ''self'' ''unsafe-inline''
118-
''unsafe-eval'' *.wistia.com *.wistia.net *.hsforms.net *.hsforms.com
119-
src.litix.io matomo.anywhere.gooddata.com *.jquery.com unpkg.com cdnjs.cloudflare.com;
120-
img-src * data: blob:; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com
121-
cdn.jsdelivr.net fast.fonts.net; font-src ''self'' data: fonts.gstatic.com
122-
*.alicdn.com *.wistia.com cdn.jsdelivr.net info.gooddata.com; frame-src
123-
''self'' *.hsforms.net *.hsforms.com; object-src ''none''; worker-src
124-
''self'' blob:; child-src blob:; connect-src ''self'' *.tiles.mapbox.com
125-
*.mapbox.com *.litix.io *.wistia.com *.hsforms.net *.hsforms.com embedwistia-a.akamaihd.net
126-
matomo.anywhere.gooddata.com; media-src ''self'' blob: data: *.wistia.com
127-
*.wistia.net embedwistia-a.akamaihd.net'
128-
Content-Type:
129-
- application/vnd.gooddata.api+json
130-
DATE: *id001
131-
Expires:
132-
- '0'
133-
GoodData-Deployment:
134-
- aio
135-
Permission-Policy:
136-
- geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera
137-
'none'; magnetometer 'none'; gyroscope 'none'; fullscreen 'none'; payment
138-
'none';
139-
Pragma:
140-
- no-cache
141-
Referrer-Policy:
142-
- no-referrer
143-
Server:
144-
- nginx
145-
Set-Cookie:
146-
- SPRING_REDIRECT_URI=; Path=/; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00
147-
GMT; HttpOnly; SameSite=Lax
148-
Vary:
149-
- Origin
150-
- Access-Control-Request-Method
151-
- Access-Control-Request-Headers
152-
X-Content-Type-Options:
153-
- nosniff
154-
X-GDC-TRACE-ID: *id001
155-
X-XSS-Protection:
156-
- 1 ; mode=block
157-
body:
158-
string:
159-
data:
160-
id: demo-test-ds
161-
type: dataSource
162-
attributes:
163-
url: jdbc:postgresql://localhost:5432/demo
164-
username: demouser
165-
enableCaching: false
16684
type: POSTGRESQL
16785
schema: demo
168-
name: demo-test-ds
16986
links:
17087
self: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
17188
- request:
@@ -256,93 +173,9 @@ interactions:
256173
username: demouser
257174
enableCaching: false
258175
cacheStrategy: NEVER
259-
type: POSTGRESQL
260-
schema: demo
261176
name: demo-test-ds
262-
links:
263-
self: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
264-
- request:
265-
method: GET
266-
uri: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
267-
body: null
268-
headers:
269-
Accept:
270-
- application/vnd.gooddata.api+json
271-
Accept-Encoding:
272-
- br, gzip, deflate
273-
X-GDC-VALIDATE-RELATIONS:
274-
- 'true'
275-
X-Requested-With:
276-
- XMLHttpRequest
277-
response:
278-
status:
279-
code: 200
280-
message: OK
281-
headers:
282-
Access-Control-Allow-Credentials:
283-
- 'true'
284-
Access-Control-Expose-Headers:
285-
- Content-Disposition, Content-Length, Content-Range, Set-Cookie
286-
Cache-Control:
287-
- no-cache, no-store, max-age=0, must-revalidate
288-
Connection:
289-
- keep-alive
290-
Content-Length:
291-
- '319'
292-
Content-Security-Policy:
293-
- 'default-src ''self'' *.wistia.com *.wistia.net; script-src ''self'' ''unsafe-inline''
294-
''unsafe-eval'' *.wistia.com *.wistia.net *.hsforms.net *.hsforms.com
295-
src.litix.io matomo.anywhere.gooddata.com *.jquery.com unpkg.com cdnjs.cloudflare.com;
296-
img-src * data: blob:; style-src ''self'' ''unsafe-inline'' fonts.googleapis.com
297-
cdn.jsdelivr.net fast.fonts.net; font-src ''self'' data: fonts.gstatic.com
298-
*.alicdn.com *.wistia.com cdn.jsdelivr.net info.gooddata.com; frame-src
299-
''self'' *.hsforms.net *.hsforms.com; object-src ''none''; worker-src
300-
''self'' blob:; child-src blob:; connect-src ''self'' *.tiles.mapbox.com
301-
*.mapbox.com *.litix.io *.wistia.com *.hsforms.net *.hsforms.com embedwistia-a.akamaihd.net
302-
matomo.anywhere.gooddata.com; media-src ''self'' blob: data: *.wistia.com
303-
*.wistia.net embedwistia-a.akamaihd.net'
304-
Content-Type:
305-
- application/vnd.gooddata.api+json
306-
DATE: *id001
307-
Expires:
308-
- '0'
309-
GoodData-Deployment:
310-
- aio
311-
Permission-Policy:
312-
- geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera
313-
'none'; magnetometer 'none'; gyroscope 'none'; fullscreen 'none'; payment
314-
'none';
315-
Pragma:
316-
- no-cache
317-
Referrer-Policy:
318-
- no-referrer
319-
Server:
320-
- nginx
321-
Set-Cookie:
322-
- SPRING_REDIRECT_URI=; Path=/; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00
323-
GMT; HttpOnly; SameSite=Lax
324-
Vary:
325-
- Origin
326-
- Access-Control-Request-Method
327-
- Access-Control-Request-Headers
328-
X-Content-Type-Options:
329-
- nosniff
330-
X-GDC-TRACE-ID: *id001
331-
X-XSS-Protection:
332-
- 1 ; mode=block
333-
body:
334-
string:
335-
data:
336-
id: demo-test-ds
337-
type: dataSource
338-
attributes:
339-
url: jdbc:postgresql://localhost:5432/demo
340-
username: demouser
341-
enableCaching: false
342-
cacheStrategy: NEVER
343177
type: POSTGRESQL
344178
schema: demo
345-
name: demo-test-ds
346179
links:
347180
self: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
348181
- request:
@@ -424,39 +257,46 @@ interactions:
424257
username: demouser
425258
enableCaching: false
426259
cacheStrategy: NEVER
260+
name: demo-test-ds
427261
type: POSTGRESQL
428262
schema: demo
429-
name: demo-test-ds
430263
links:
431264
self: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
432265
- request:
433266
method: PUT
434-
uri: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
267+
uri: http://localhost:3000/api/v1/layout/dataSources
435268
body:
436-
data:
437-
attributes:
269+
dataSources:
270+
- id: demo-test-ds
438271
name: demo-test-ds
439272
schema: demo
440273
type: POSTGRESQL
441274
url: jdbc:postgresql://localhost:5432/demo
442275
enableCaching: false
443-
id: demo-test-ds
444-
type: dataSource
276+
username: demouser
277+
permissions:
278+
- assignee:
279+
id: demo2
280+
type: user
281+
name: MANAGE
282+
- assignee:
283+
id: demoGroup
284+
type: userGroup
285+
name: USE
286+
password: demopass
445287
headers:
446-
Accept:
447-
- application/vnd.gooddata.api+json
448288
Accept-Encoding:
449289
- br, gzip, deflate
450290
Content-Type:
451-
- application/vnd.gooddata.api+json
291+
- application/json
452292
X-GDC-VALIDATE-RELATIONS:
453293
- 'true'
454294
X-Requested-With:
455295
- XMLHttpRequest
456296
response:
457297
status:
458-
code: 200
459-
message: OK
298+
code: 204
299+
message: No Content
460300
headers:
461301
Access-Control-Allow-Credentials:
462302
- 'true'
@@ -466,8 +306,6 @@ interactions:
466306
- no-cache, no-store, max-age=0, must-revalidate
467307
Connection:
468308
- keep-alive
469-
Content-Length:
470-
- '273'
471309
Content-Security-Policy:
472310
- 'default-src ''self'' *.wistia.com *.wistia.net; script-src ''self'' ''unsafe-inline''
473311
''unsafe-eval'' *.wistia.com *.wistia.net *.hsforms.net *.hsforms.com
@@ -480,8 +318,6 @@ interactions:
480318
*.mapbox.com *.litix.io *.wistia.com *.hsforms.net *.hsforms.com embedwistia-a.akamaihd.net
481319
matomo.anywhere.gooddata.com; media-src ''self'' blob: data: *.wistia.com
482320
*.wistia.net embedwistia-a.akamaihd.net'
483-
Content-Type:
484-
- application/vnd.gooddata.api+json
485321
DATE: *id001
486322
Expires:
487323
- '0'
@@ -510,15 +346,4 @@ interactions:
510346
X-XSS-Protection:
511347
- 1 ; mode=block
512348
body:
513-
string:
514-
data:
515-
id: demo-test-ds
516-
type: dataSource
517-
attributes:
518-
url: jdbc:postgresql://localhost:5432/demo
519-
enableCaching: false
520-
type: POSTGRESQL
521-
schema: demo
522-
name: demo-test-ds
523-
links:
524-
self: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
349+
string: ''

gooddata-sdk/tests/catalog/test_catalog_data_source.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,16 @@ def test_declarative_data_sources(test_config):
511511
def test_cache_strategy(test_config: dict):
512512
sdk = GoodDataSdk.create(host_=test_config["host"], token_=test_config["token"])
513513
data_source_id = test_config["data_source"]
514-
515-
original = sdk.catalog_data_source.get_data_source(data_source_id=data_source_id)
514+
path = _current_dir / "expected" / "declarative_data_sources.json"
515+
credentials_path = _current_dir / "load" / "data_source_credentials" / "data_sources_credentials.yaml"
516516

517517
try:
518518
sdk.catalog_data_source.patch_data_source_attributes(data_source_id, {"cache_strategy": "NEVER"})
519519
updated = sdk.catalog_data_source.get_data_source(data_source_id=data_source_id)
520520
assert updated.cache_strategy == "NEVER"
521521
finally:
522-
sdk.catalog_data_source.create_or_update_data_source(original)
522+
data_sources_o = CatalogDeclarativeDataSources.from_dict(load_json(path))
523+
sdk.catalog_data_source.put_declarative_data_sources(data_sources_o, credentials_path)
523524

524525

525526
@gd_vcr.use_cassette(str(_fixtures_dir / "demo_test_scan_model.yaml"))

gooddata-sdk/tests/catalog/test_catalog_user_service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@ def test_user_replace_user_groups(test_config):
503503

504504
@gd_vcr.use_cassette(str(_fixtures_dir / "test_get_user_permissions.yaml"))
505505
def test_get_user_permissions(test_config):
506+
"""
507+
TODO: tests above corrupts result for permissions tests – the fix is required
508+
"""
506509
sdk = GoodDataSdk.create(host_=test_config["host"], token_=test_config["token"])
507510
user_id = test_config["test_user"]
508511
workspace_id = test_config["workspace"]

0 commit comments

Comments
 (0)