1{ image
2, invisible-watermark
3, opencv4
4, python3
5, runCommand
6, stdenvNoCC
7}:
8
9# This test checks if the python code shown in the README works correctly
10
11let
12 message = "fnörd1";
13 method = "dwtDct";
14
15 pythonWithPackages = python3.withPackages (pp: with pp; [ invisible-watermark opencv4 ]);
16 pythonInterpreter = pythonWithPackages.interpreter;
17
18 encode = stdenvNoCC.mkDerivation {
19 name = "encode";
20 realBuilder = pythonInterpreter;
21 args = [ ./encode.py ];
22 inherit image message method;
23 };
24
25 decode = stdenvNoCC.mkDerivation {
26 name = "decode";
27 realBuilder = pythonInterpreter;
28 args = [ ./decode.py ];
29 inherit method;
30 image = "${encode}/test_wm.png";
31 num_bits = (builtins.stringLength message) * 8;
32 };
33in
34runCommand "invisible-watermark-test-python" { } ''
35 decoded_message="$(cat '${decode}')"
36 if [ '${message}' != "$decoded_message" ]; then
37 echo "invisible-watermark did not decode the watermark correctly."
38 echo "The original message was ${message} but the decoded message was $decoded_message."
39 exit 1
40 fi
41 touch "$out"
42''