Skip to content

Commit

Permalink
Updated tests 2
Browse files Browse the repository at this point in the history
  • Loading branch information
croqaz committed Jan 7, 2025
1 parent 8059750 commit 8bda8c8
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 12 deletions.
8 changes: 6 additions & 2 deletions cli/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from imgdb.log import log


async def main():
def main():
parser = argparse.ArgumentParser(prog='ImageAdd')
parser.add_argument('inputs', nargs='+')
parser.add_argument('--dbname', default='imgdb.htm', help='DB file name')
Expand Down Expand Up @@ -43,6 +43,10 @@ async def main():
parser.add_argument('--shuffle', action='store_true', help='randomize files before import')

args = parser.parse_args()
asyncio.run(add(args))


async def add(args):
file_start = timeit.default_timer()

dargs = vars(args)
Expand Down Expand Up @@ -98,4 +102,4 @@ async def _add_img(p: Path):


if __name__ == '__main__':
asyncio.run(main())
main()
4 changes: 4 additions & 0 deletions cli/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ def main():
parser.add_argument('--thumb-sz', default=96, type=int, help='DB thumb size')
parser.add_argument('--thumb-qual', default=70, type=int, help='DB thumb quality')
parser.add_argument('--thumb-type', default='webp', help='DB thumb type')

args = parser.parse_args()
info(args)


def info(args):
file_start = timeit.default_timer()
cfg = config.Config(**vars(args))

Expand Down
2 changes: 1 addition & 1 deletion imgdb/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ def __attrs_post_init__(self):
JSON_SAFE = (
'deep',
'exts',
'hashes',
'metadata',
'shuffle',
'sym_links',
'thumb_qual',
'thumb_sz',
'thumb_type',
'top_color_cut',
'c_hashes',
'v_hashes',
'wrap_at',
)
Expand Down
1 change: 1 addition & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from tempfile import TemporaryDirectory

import pytest


Expand Down
5 changes: 3 additions & 2 deletions test/test_add.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from os import listdir, mkdir

from imgdb.__main__ import add
from imgdb.config import g_config, Config
from imgdb.config import Config, g_config
from imgdb.db import *
from os import mkdir, listdir

IMGS = listdir('test/pics')

Expand Down
5 changes: 3 additions & 2 deletions test/test_gallery.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from os import listdir

from imgdb.__main__ import add, gallery
from imgdb.config import g_config, Config
from imgdb.config import Config, g_config
from imgdb.db import *
from imgdb.gallery import *
from os import listdir

IMGS = listdir('test/pics')

Expand Down
5 changes: 3 additions & 2 deletions test/test_img.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from bs4 import BeautifulSoup
from PIL import Image

from imgdb.algorithm import *
from imgdb.config import Config
from imgdb.img import *
from PIL import Image
from bs4 import BeautifulSoup


def test_img_meta():
Expand Down
5 changes: 3 additions & 2 deletions test/test_links.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from os import listdir

from imgdb.__main__ import add, links
from imgdb.config import g_config, Config
from imgdb.config import Config, g_config
from imgdb.db import *
from imgdb.gallery import *
from os import listdir

IMGS = listdir('test/pics')

Expand Down
3 changes: 2 additions & 1 deletion test/test_rename.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from imgdb.__main__ import rename
from os import listdir, makedirs
from shutil import copytree

from imgdb.__main__ import rename

IMGS = listdir('test/pics')


Expand Down

0 comments on commit 8bda8c8

Please sign in to comment.