Skip to content

Commit 5e2269d

Browse files
committed
Added superlike tests
1 parent 174217f commit 5e2269d

File tree

2 files changed

+161
-18
lines changed

2 files changed

+161
-18
lines changed

PyMatcha.postman_collection.json

Lines changed: 160 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,6 +3566,15 @@
35663566
"request": {
35673567
"method": "POST",
35683568
"header": [],
3569+
"body": {
3570+
"mode": "raw",
3571+
"raw": "{\n \"is_superlike\": false\n}",
3572+
"options": {
3573+
"raw": {
3574+
"language": "json"
3575+
}
3576+
}
3577+
},
35693578
"url": {
35703579
"raw": "{{host}}/like/-1",
35713580
"host": [
@@ -3607,6 +3616,15 @@
36073616
"request": {
36083617
"method": "POST",
36093618
"header": [],
3619+
"body": {
3620+
"mode": "raw",
3621+
"raw": "{\n \"is_superlike\": false\n}",
3622+
"options": {
3623+
"raw": {
3624+
"language": "json"
3625+
}
3626+
}
3627+
},
36103628
"url": {
36113629
"raw": "{{host}}/like/{{user_id}}",
36123630
"host": [
@@ -3699,6 +3717,15 @@
36993717
"request": {
37003718
"method": "POST",
37013719
"header": [],
3720+
"body": {
3721+
"mode": "raw",
3722+
"raw": "{\n \"is_superlike\": false\n}",
3723+
"options": {
3724+
"raw": {
3725+
"language": "json"
3726+
}
3727+
}
3728+
},
37023729
"url": {
37033730
"raw": "{{host}}/like/like_me",
37043731
"host": [
@@ -3740,6 +3767,15 @@
37403767
"request": {
37413768
"method": "POST",
37423769
"header": [],
3770+
"body": {
3771+
"mode": "raw",
3772+
"raw": "{\n \"is_superlike\": false\n}",
3773+
"options": {
3774+
"raw": {
3775+
"language": "json"
3776+
}
3777+
}
3778+
},
37433779
"url": {
37443780
"raw": "{{host}}/like/like_me",
37453781
"host": [
@@ -3926,6 +3962,103 @@
39263962
"protocolProfileBehavior": {},
39273963
"_postman_isSubFolder": true
39283964
},
3965+
{
3966+
"name": "Superlike User",
3967+
"item": [
3968+
{
3969+
"name": "Superlike like_me user",
3970+
"event": [
3971+
{
3972+
"listen": "test",
3973+
"script": {
3974+
"id": "b09c0ee4-abcb-4fcc-9806-e1b48da225b3",
3975+
"exec": [
3976+
"var response = JSON.parse(responseBody);",
3977+
"",
3978+
"",
3979+
"pm.test(\"Status code is 200\", function () {",
3980+
" pm.response.to.have.status(200);",
3981+
"});",
3982+
"",
3983+
"tests[\"JSON return code is 200\"] = response.code == 200",
3984+
"",
3985+
"tests[\"success is true\"] = response.success == true",
3986+
"",
3987+
"tests[\"Messag is correct\"] = response.message == \"Superliked user.\""
3988+
],
3989+
"type": "text/javascript"
3990+
}
3991+
}
3992+
],
3993+
"request": {
3994+
"method": "POST",
3995+
"header": [],
3996+
"body": {
3997+
"mode": "raw",
3998+
"raw": "{\n \"is_superlike\": true\n}",
3999+
"options": {
4000+
"raw": {
4001+
"language": "json"
4002+
}
4003+
}
4004+
},
4005+
"url": {
4006+
"raw": "{{host}}/like/like_me",
4007+
"host": [
4008+
"{{host}}"
4009+
],
4010+
"path": [
4011+
"like",
4012+
"like_me"
4013+
]
4014+
}
4015+
},
4016+
"response": []
4017+
},
4018+
{
4019+
"name": "UnSuperlike like_me user",
4020+
"event": [
4021+
{
4022+
"listen": "test",
4023+
"script": {
4024+
"id": "77e4cefb-3d6f-481e-91ff-c63cfc37a6aa",
4025+
"exec": [
4026+
"var response = JSON.parse(responseBody);",
4027+
"",
4028+
"",
4029+
"pm.test(\"Status code is 200\", function () {",
4030+
" pm.response.to.have.status(200);",
4031+
"});",
4032+
"",
4033+
"tests[\"JSON return code is 200\"] = response.code == 200",
4034+
"",
4035+
"tests[\"success is true\"] = response.success == true",
4036+
""
4037+
],
4038+
"type": "text/javascript"
4039+
}
4040+
}
4041+
],
4042+
"request": {
4043+
"method": "POST",
4044+
"header": [],
4045+
"url": {
4046+
"raw": "{{host}}/unlike/like_me",
4047+
"host": [
4048+
"{{host}}"
4049+
],
4050+
"path": [
4051+
"unlike",
4052+
"like_me"
4053+
]
4054+
}
4055+
},
4056+
"response": []
4057+
}
4058+
],
4059+
"protocolProfileBehavior": {},
4060+
"_postman_isSubFolder": true
4061+
},
39294062
{
39304063
"name": "Match user",
39314064
"item": [
@@ -3995,6 +4128,15 @@
39954128
"request": {
39964129
"method": "POST",
39974130
"header": [],
4131+
"body": {
4132+
"mode": "raw",
4133+
"raw": "{\n \"is_superlike\": false\n}",
4134+
"options": {
4135+
"raw": {
4136+
"language": "json"
4137+
}
4138+
}
4139+
},
39984140
"url": {
39994141
"raw": "{{host}}/like/like_me",
40004142
"host": [
@@ -5714,92 +5856,92 @@
57145856
],
57155857
"variable": [
57165858
{
5717-
"id": "f7f62b2d-ca4f-4598-8b51-32df1933c988",
5859+
"id": "dff1a2e8-8383-4d1a-af74-6744539983c6",
57185860
"key": "host",
57195861
"value": "http://127.0.0.1:5000"
57205862
},
57215863
{
5722-
"id": "3703d537-e527-402c-bcc1-3378cc511cca",
5864+
"id": "2baf602e-1e34-4efc-957c-bbd23051fa18",
57235865
"key": "user_id",
57245866
"value": ""
57255867
},
57265868
{
5727-
"id": "8517da0b-fe71-4bbc-9323-fcf704175182",
5869+
"id": "dd71d2c4-7078-40ea-af2b-69ebed33895e",
57285870
"key": "user_email",
57295871
"value": "foo@example.org"
57305872
},
57315873
{
5732-
"id": "022a3d70-4602-4ec4-8b06-b713eb64c789",
5874+
"id": "2c6ace6d-9880-47c0-a303-d57c85c11826",
57335875
"key": "user_username",
57345876
"value": "foo"
57355877
},
57365878
{
5737-
"id": "00dc9fc9-4081-4ffc-9036-656c7ee26eb7",
5879+
"id": "27762741-f737-47db-9982-bb6382a1102d",
57385880
"key": "user_password",
57395881
"value": "admin"
57405882
},
57415883
{
5742-
"id": "d169f5ec-aa59-4f2f-902f-62cec84b7b3e",
5884+
"id": "32749353-1734-427a-b7e5-ea42f9bf0a81",
57435885
"key": "user_firstname",
57445886
"value": "Foo"
57455887
},
57465888
{
5747-
"id": "420f8b7d-f6c3-402c-a113-842a42ad643b",
5889+
"id": "dfd31259-5a05-45b5-9b15-00565a3621f6",
57485890
"key": "user_lastname",
57495891
"value": "Bar"
57505892
},
57515893
{
5752-
"id": "4a70641d-9661-44a4-9ebb-571e904760bb",
5894+
"id": "6fbac55b-72a7-4dda-9df6-a5b54b8e075a",
57535895
"key": "debug_token",
57545896
"value": "xX69jules69Xx"
57555897
},
57565898
{
5757-
"id": "84b5ef5d-4da9-47e9-96eb-16173643be25",
5899+
"id": "469a1742-e7ea-4784-8383-304e1a1254c8",
57585900
"key": "user_access_token",
57595901
"value": ""
57605902
},
57615903
{
5762-
"id": "58d485e5-54fd-48e2-b420-b685f01ec6d9",
5904+
"id": "b4e018f7-21e5-4cc8-aa5d-b44f1d3fe5aa",
57635905
"key": "user_refresh_token",
57645906
"value": ""
57655907
},
57665908
{
5767-
"id": "f49346f4-9cf4-485f-a9ff-e8c15cf52193",
5909+
"id": "35a30c5c-700b-4cac-a87f-e9b85b1d59d5",
57685910
"key": "expired_token",
57695911
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1OTAyNDIyNjQsIm5iZiI6MTU5MDI0MjI2NCwianRpIjoiNTM0ZGI5NzQtOWE4Ni00MGViLWE1NDEtMDg3N2ZmNzQ3NDVhIiwiZXhwIjoxNTkwMjQyMzI0LCJpZGVudGl0eSI6eyJpZCI6NTEyLCJlbWFpbCI6ImZvb0BleGFtcGxlLm9yZyIsInVzZXJuYW1lIjoiYmFyIiwiaXNfb25saW5lIjp0cnVlLCJkYXRlX2xhc3RzZWVuIjoiU2F0LCAyMyBNYXkgMjAyMCAxMzo1Nzo0NCBHTVQifSwiZnJlc2giOnRydWUsInR5cGUiOiJhY2Nlc3MifQ.NTp2P0WNkXDwzuzrcNIQdeAfizQ57HQgkzBLSvY1yHU"
57705912
},
57715913
{
5772-
"id": "7b6804b9-95bf-4ebd-9422-00a82dcb0da1",
5914+
"id": "f9cb0a56-3fe5-4a43-8c34-c370ea32d68c",
57735915
"key": "user_orientation",
57745916
"value": "heterosexual"
57755917
},
57765918
{
5777-
"id": "f3dcabd6-9135-4b98-9ae9-48754dffcc8e",
5919+
"id": "473c2ba6-4781-4074-8ab7-b2d593ba027f",
57785920
"key": "user_bio",
57795921
"value": "Lorem Ipsum is the single greatest threat. We are not - we are not keeping up with other websites. Lorem Ipsum best not make any more threats to your website. It will be met with fire and fury like the world has never seen. Does everybody know that pig named Lorem Ipsum? An ‘extremely credible source’ has called my office and told me that Barack Obama’s placeholder text is a fraud."
57805922
},
57815923
{
5782-
"id": "b36685e2-b7cb-4057-889d-4478975127fb",
5924+
"id": "aa576ca8-3df8-4aa9-9365-d97b17a2fae9",
57835925
"key": "user_gender",
57845926
"value": "male"
57855927
},
57865928
{
5787-
"id": "b90ce2a3-6bc8-4ea2-93d0-faaa3d937417",
5929+
"id": "7295072e-641d-4991-8d9e-5b4219ddcbe3",
57885930
"key": "user_birthdate",
57895931
"value": "06/04/1998"
57905932
},
57915933
{
5792-
"id": "061a7ca6-55dc-411a-8f4d-c256eadaf8a5",
5934+
"id": "dee264ed-d89e-4493-92c9-3329e0864680",
57935935
"key": "user_lat",
57945936
"value": "44.8404"
57955937
},
57965938
{
5797-
"id": "9ddd0f08-1bc5-457b-9d20-765668662af0",
5939+
"id": "1afbbe42-4c06-40e3-bc8c-775865907ec2",
57985940
"key": "user_lng",
57995941
"value": "-0.5805"
58005942
},
58015943
{
5802-
"id": "e2835d3f-b1ab-400c-9bad-66288f3ff0ee",
5944+
"id": "e8028fd5-ba0c-474c-99a6-99f6aef3dac1",
58035945
"key": "user_ip",
58045946
"value": "77.205.46.181"
58055947
}

backend/PyMatcha/routes/api/like.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def like_profile(uid):
3636
superlike_counter = int(redis.get(f"superlikes:{current_user.id}"))
3737
if superlike_counter <= 0:
3838
set_user_superlikes.apply_async(current_user.id, amount=5, eta=86400)
39+
# TODO: Test this in postman
3940
raise BadRequestError("No more superlikes today !", "Try later")
4041
else:
4142
redis.decr(f"superlikes:{current_user.id}")

0 commit comments

Comments
 (0)