mirror of
https://github.com/simon987/hexlib.git
synced 2025-12-17 00:29:15 +00:00
Fix tests
This commit is contained in:
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
@@ -1,10 +1,15 @@
|
||||
from unittest import TestCase
|
||||
|
||||
from hexlib.db import VolatileState, VolatileBooleanState, VolatileQueue
|
||||
from hexlib.env import get_redis
|
||||
|
||||
|
||||
class TestVolatileState(TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
rdb = get_redis()
|
||||
rdb.delete("test1a", "test1b", "test1c", "test1:a", "test2b")
|
||||
|
||||
def test_get_set(self):
|
||||
s = VolatileState(prefix="test1")
|
||||
val = {
|
||||
@@ -53,6 +58,10 @@ class TestVolatileState(TestCase):
|
||||
|
||||
class TestVolatileBoolState(TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
rdb = get_redis()
|
||||
rdb.delete("test1a", "test1b", "test1c", "test1:a", "test2b")
|
||||
|
||||
def test_get_set(self):
|
||||
s = VolatileBooleanState(prefix="test1")
|
||||
|
||||
|
||||
@@ -2,12 +2,16 @@ import os
|
||||
from unittest import TestCase
|
||||
|
||||
from hexlib.web import download_file
|
||||
import warnings
|
||||
|
||||
|
||||
class TestDownloadFile(TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
warnings.filterwarnings(action="ignore", category=ResourceWarning)
|
||||
|
||||
def test_download_file(self):
|
||||
download_file("http://ovh.net/files/10Mb.dat", "/tmp/10Mb.dat")
|
||||
download_file("https://github.com/simon987/hexlib/raw/master/10MB.bin", "/tmp/10Mb.dat")
|
||||
self.assertTrue(os.path.exists("/tmp/10Mb.dat"))
|
||||
os.remove("/tmp/10Mb.dat")
|
||||
|
||||
@@ -22,8 +26,8 @@ class TestDownloadFile(TestCase):
|
||||
self.assertEqual(len(exceptions), 3)
|
||||
|
||||
def test_download_file_meta(self):
|
||||
download_file("http://ovh.net/files/10Mb.dat", "/tmp/10Mb.dat", save_meta=True)
|
||||
download_file("https://github.com/simon987/hexlib/raw/master/10MB.bin", "/tmp/10Mb.dat", save_meta=True)
|
||||
self.assertTrue(os.path.exists("/tmp/10Mb.dat"))
|
||||
self.assertTrue(os.path.exists("/tmp/10Mb.dat.meta"))
|
||||
os.remove("/tmp/10Mb.dat")
|
||||
# os.remove("/tmp/10Mb.dat.meta")
|
||||
os.remove("/tmp/10Mb.dat.meta")
|
||||
|
||||
Reference in New Issue
Block a user