parent
1bfa912241
commit
98ee396ea7
@ -1,13 +1,14 @@ |
||||
#!/bin/bash |
||||
ran=0 |
||||
SECONDS=0 ; |
||||
SECONDS=0 ; |
||||
close () { |
||||
exit 10; |
||||
} |
||||
|
||||
for f in tests/*.py; do |
||||
python3 "$f" || close # if needed |
||||
python3 "$f" || close & # if needed |
||||
let "ran++" |
||||
done |
||||
echo "ran $ran test files successfully in $SECONDS seconds" |
||||
rm -f *.dat |
||||
rm -rf /tmp/imgin* |
@ -1,7 +0,0 @@ |
||||
import unittest |
||||
class TestBasic(unittest.TestCase): |
||||
|
||||
def test_basic(self): |
||||
self.assertTrue(True) |
||||
|
||||
unittest.main() |
@ -0,0 +1,26 @@ |
||||
import unittest |
||||
import os |
||||
from glob import glob |
||||
|
||||
from imgin import get |
||||
|
||||
CACHE_DIR = '/tmp/imgin-imgur-images-album/' |
||||
|
||||
class TestAlbum(unittest.TestCase): |
||||
|
||||
def test_album_a(self): |
||||
code = 'ethCwFv' |
||||
get(f"https://imgur.com/a/{code}", CACHE_DIR) |
||||
files = glob(CACHE_DIR + '*') |
||||
for i in files: |
||||
if i.endswith('m_a_ethCwFv'): |
||||
continue |
||||
print(f'got tests/test_images/album/{i[-11:]} checking if it is an image we should have') |
||||
self.assertTrue(os.path.exists(f'tests/test_images/album/{i[-11:]}')) |
||||
|
||||
try: |
||||
os.mkdir(CACHE_DIR) |
||||
except FileExistsError: |
||||
pass |
||||
|
||||
unittest.main() |
@ -0,0 +1,22 @@ |
||||
import unittest |
||||
import os |
||||
|
||||
from imgin import get |
||||
|
||||
CACHE_DIR = '/tmp/imgin-imgur-images-single/' |
||||
|
||||
class TestSingleImage(unittest.TestCase): |
||||
|
||||
def test_single_image(self): |
||||
img = "7TiLluI.jpg" |
||||
get(f"https://imgur.com/{img}", CACHE_DIR) |
||||
with open(f"tests/test_images/{img}", "rb") as expected: |
||||
with open(CACHE_DIR + img, "rb") as actual: |
||||
self.assertEqual(actual.read(), expected.read()) |
||||
|
||||
try: |
||||
os.mkdir(CACHE_DIR) |
||||
except FileExistsError: |
||||
pass |
||||
|
||||
unittest.main() |
Loading…
Reference in new issue