-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Since I still use debspawn, I can't use autopkgtest, see lkhq/debspawn#13 so instead, just add cram3 &c to the build-deps and use pybuild --test-custom
- Loading branch information
Showing
4 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# Tests with constructed index files. | ||
|
||
## setup | ||
|
||
Find the built version (we haven't done the install step yet) and add | ||
that to `PATH`. | ||
|
||
$ SCRIPTSBUILTDIR=$(realpath ${TESTDIR}/../build/scripts-*) | ||
$ export PATH=${SCRIPTSBUILTDIR}:$PATH | ||
|
||
## basic index | ||
|
||
### Empty file, no tags. | ||
|
||
$ cat > /tmp/kpa-empty-idx.xml <<'KPA' | ||
> <?xml version="1.0" encoding="UTF-8"?> | ||
> <KPhotoAlbum version="10" compressed="0"> | ||
> <Categories> | ||
> </Categories> | ||
> <images> | ||
> </images> | ||
> </KPhotoAlbum> | ||
> KPA | ||
|
||
Confirm that it parses. | ||
|
||
$ kpa-grep --index /tmp/kpa-empty-idx.xml | ||
|
||
Confirm that dump-tags handles it. | ||
|
||
$ kpa-grep --index /tmp/kpa-empty-idx.xml --dump-tags | ||
|
||
Confirm that a nonexistent tag doesn't break. | ||
|
||
$ kpa-grep --index /tmp/kpa-empty-idx.xml --tag fred | ||
|
||
### Two images, one keyword applied to one of them. | ||
|
||
$ cat > /tmp/kpa-idx.xml <<'KPA' | ||
> <?xml version="1.0" encoding="UTF-8"?> | ||
> <KPhotoAlbum version="10" compressed="0"> | ||
> <Categories> | ||
> <Category name="Keywords"> | ||
> <value value="test" id="1"/> | ||
> </Category> | ||
> </Categories> | ||
> <images> | ||
> <image file="test_img_1.jpg" label="" startDate="1980-01-01T00:00:10"> | ||
> <options> | ||
> <option name="Keywords"> | ||
> <value value="test"/> | ||
> </option> | ||
> </options> | ||
> </image> | ||
> <image file="test_img_2.jpg" label="" startDate="1980-01-02T00:00:10"> | ||
> <options/> | ||
> </image> | ||
> </images> | ||
> </KPhotoAlbum> | ||
> KPA | ||
|
||
No filters should give all of the files. | ||
|
||
$ kpa-grep --index /tmp/kpa-idx.xml | ||
/tmp/test_img_1.jpg | ||
/tmp/test_img_2.jpg | ||
|
||
Dump tags should work. | ||
|
||
$ kpa-grep --index /tmp/kpa-idx.xml --dump-tags | ||
Keywords test | ||
|
||
The files are explicitly ancient (1980) so "since last week" should | ||
not produce them. | ||
|
||
$ kpa-grep --index /tmp/kpa-idx.xml --dump-tags --since "last week" | ||
|
||
Known tag path gets printed. | ||
|
||
$ kpa-grep --index /tmp/kpa-idx.xml --tag test | ||
/tmp/test_img_1.jpg | ||
|
||
Known tag generates expected json output. | ||
|
||
$ kpa-grep --index /tmp/kpa-idx.xml --tag test --json | ||
{"file": "test_img_1.jpg", "label": "", "startDate": "1980-01-01T00:00:10", "Keywords": ["test"]} | ||
|
||
Get a second opinion on the validity of the json output. | ||
|
||
$ kpa-grep --index /tmp/kpa-idx.xml --tag test --json | jq -r .file | ||
test_img_1.jpg | ||
|
||
xml whitespace should probably be better, not just for the test, see | ||
<https://github.com/eichin/thok-kphotoalbum-grep/issues/3> about | ||
making it more completely valid/useful. | ||
|
||
$ kpa-grep --index /tmp/kpa-idx.xml --tag test --xml | ||
<image file="test_img_1.jpg" label="" startDate="1980-01-01T00:00:10"> | ||
<options> | ||
<option name="Keywords"> | ||
<value value="test" /> | ||
</option> | ||
</options> | ||
</image> | ||
(no-eol) | ||
|
||
Test that `--exclude` gives us the other filename. | ||
|
||
$ kpa-grep --index /tmp/kpa-idx.xml --exclude test | ||
/tmp/test_img_2.jpg | ||
|
||
Confirm that `--path` picks out an explicit file. | ||
|
||
$ kpa-grep --index /tmp/kpa-idx.xml --path test_img_1.jpg | ||
/tmp/test_img_1.jpg | ||
|
||
Confirm that `--path` with a full path also works (the paths stored in | ||
the XML file are relative to it - the above path worked with the exact | ||
match, this is testing the "strip off the common prefix" feature.) | ||
|
||
$ kpa-grep --index /tmp/kpa-idx.xml --path /tmp/test_img_1.jpg | ||
/tmp/test_img_1.jpg | ||
|
||
TODO: switch these to files that are in the cramtests dir... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Make sure `kpa-grep` runs at all. | ||
|
||
## setup | ||
|
||
Find the built version (we haven't done the install step yet) and add | ||
that to `PATH`. | ||
|
||
$ SCRIPTSBUILTDIR=$(realpath ${TESTDIR}/../build/scripts-*) | ||
$ export PATH=${SCRIPTSBUILTDIR}:$PATH | ||
|
||
|
||
Run it with `--help` which should always work, even without an index. | ||
|
||
$ kpa-grep --help 1>/dev/null | ||
|
||
Make sure it fails cleanly without an index. | ||
|
||
$ kpa-grep --dump-tags | ||
No kphotoalbum index given (with --index or in kphotoalbumrc) | ||
[1] | ||
|
||
Make sure it fails cleanly with an index arg that is missing. | ||
|
||
$ kpa-grep --index /tmp/missing-index.xml | ||
kphotoalbum index /tmp/missing-index.xml not found | ||
[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,23 @@ Source: kpa-grep | |
Section: unknown | ||
Priority: extra | ||
Maintainer: Mark Eichin <[email protected]> | ||
Build-Depends: debhelper (>= 10), dh-python, python3 | ||
Build-Depends: | ||
debhelper (>= 10), | ||
dh-python, | ||
python3, | ||
# test deps | ||
python3-cram, | ||
jq, | ||
# duplicates of install-deps so we can run also tests at build time | ||
python3-dateutil, | ||
python3-parsedatetime, | ||
Standards-Version: 3.9.1 | ||
|
||
Package: kpa-grep | ||
Architecture: all | ||
Depends: ${misc:Depends}, python3-dateutil, python3-parsedatetime | ||
Depends: ${misc:Depends}, | ||
python3-dateutil, | ||
python3-parsedatetime, | ||
Description: Simple CLI tool for pulling subsets of photos out of KPhotoAlbum | ||
kpa-grep scans the index.xml directly. Base example: | ||
. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters