Skip to content

Commit

Permalink
add queue to test
Browse files Browse the repository at this point in the history
  • Loading branch information
Am K committed Sep 21, 2024
1 parent e0dd28a commit 2fefa67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from zcache import Cache, SmartRequest
from zcache import Cache, SmartRequest, Queue
import requests
import time
import unittest
Expand Down Expand Up @@ -46,6 +46,18 @@ def test_request(self):
cache_path='/tmp/request2.cache')
self.assertEqual(r.response["body"], s.response["body"])

def test_queue(self):
q = Queue()
id = q.put("test")
self.assertEqual(q.exists(id), True)
self.assertEqual(q.peek(), "test")
self.assertEqual(q.size(), 1)
self.assertEqual(q.empty(), False)
self.assertEqual(q.get(), "test")
self.assertEqual(q.size(), 0)
self.assertEqual(q.empty(), True)
self.assertEqual(q.exists(id), False)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion zcache/Extras/SmartRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SmartRequest:
A class for making Smart HTTP requests with caching capabilities using PyZCache.
"""

def __init__(self, url, cache_path=None, cache_time=120, offline_ttl=604800, **kwargs):
def __init__(self, url, cache_path="smartrequest.json", cache_time=120, offline_ttl=604800, **kwargs):
if not isinstance(url, str):
cache_name = url.url
else:
Expand Down

0 comments on commit 2fefa67

Please sign in to comment.