From 706d14df79ebdd0c6e5a6d5c302e60de1208dafc Mon Sep 17 00:00:00 2001 From: rbi-aap Date: Tue, 6 Aug 2024 11:33:14 +1000 Subject: [PATCH] test --- tests/test_wire.py | 74 +++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/tests/test_wire.py b/tests/test_wire.py index 35026807..9438a374 100644 --- a/tests/test_wire.py +++ b/tests/test_wire.py @@ -91,43 +91,43 @@ def test_bookmarks(client, app): assert 0 == get_bookmarks_count(client, user_id) -# def test_bookmarks_by_section(client, app): -# products = [ -# { -# "_id": 1, -# "name": "Service A", -# "query": "service.code: a", -# "is_enabled": True, -# "description": "Service A", -# "companies": ['1'], -# "sd_product_id": None, -# "product_type": "wire" -# } -# ] -# -# app.data.insert('products', products) -# product_id = app.data.find_all('products')[0]['_id'] -# assert product_id == 1 -# -# with client.session_transaction() as session: -# session['user'] = '59b4c5c61d41c8d736852fbf' -# session['user_type'] = 'public' -# -# assert 0 == get_bookmarks_count(client, PUBLIC_USER_ID) -# -# resp = client.post('/wire_bookmark', data=json.dumps({ -# 'items': [items[0]['_id']], -# }), content_type='application/json') -# assert resp.status_code == 200 -# -# assert 1 == get_bookmarks_count(client, PUBLIC_USER_ID) -# -# client.delete('/wire_bookmark', data=json.dumps({ -# 'items': [items[0]['_id']], -# }), content_type='application/json') -# assert resp.status_code == 200 -# -# assert 0 == get_bookmarks_count(client, PUBLIC_USER_ID) +def test_bookmarks_by_section(client, app): + products = [ + { + "_id": 1, + "name": "Service A", + "query": "service.code: a", + "is_enabled": True, + "description": "Service A", + "companies": ['1'], + "sd_product_id": None, + "product_type": "wire" + } + ] + + app.data.insert('products', products) + product_id = app.data.find_all('products')[0]['_id'] + assert product_id == 1 + + with client.session_transaction() as session: + session['user'] = '59b4c5c61d41c8d736852fbf' + session['user_type'] = 'public' + + assert 0 == get_bookmarks_count(client, PUBLIC_USER_ID) + + resp = client.post('/wire_bookmark', data=json.dumps({ + 'items': [items[0]['_id']], + }), content_type='application/json') + assert resp.status_code == 200 + + assert 1 == get_bookmarks_count(client, PUBLIC_USER_ID) + + client.delete('/wire_bookmark', data=json.dumps({ + 'items': [items[0]['_id']], + }), content_type='application/json') + assert resp.status_code == 200 + + assert 0 == get_bookmarks_count(client, PUBLIC_USER_ID) def test_item_copy(client, app):