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