From 6b81ef2f335184b26e603ef6441993c4757763cd Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Thu, 6 Jul 2017 00:14:04 -0300 Subject: [PATCH 01/21] Including travis support to execute tests. --- .travis.yml | 10 ++++++++++ tests/Dockerfile | 12 ++++++++++++ tests/prefs.db | Bin 0 -> 5120 bytes 3 files changed, 22 insertions(+) create mode 100644 .travis.yml create mode 100644 tests/Dockerfile create mode 100644 tests/prefs.db diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cae1ba7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +sudo: required +services: + - docker +language: python +python: + - "2.7" +install: + - docker build -f tests/Dockerfile -t txgio/anki-connect . +script: + - curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file diff --git a/tests/Dockerfile b/tests/Dockerfile new file mode 100644 index 0000000..2932c33 --- /dev/null +++ b/tests/Dockerfile @@ -0,0 +1,12 @@ +FROM txgio/anki + +RUN mkdir -p /home/anki-user/Documents/Anki/addons + +COPY AnkiConnect.py /home/anki-user/Documents/Anki/addons + +# Required if you want to access it from another IP address. +# RUN sed -i 's/127.0.0.1/0.0.0.0/' /home/anki-user/Documents/Anki/addons/AnkiConnect.py + +COPY tests/prefs.db /home/anki-user/Documents/Anki/prefs.db + +CMD /bin/bash -c "(/usr/bin/ibus-daemon -xd; /usr/bin/anki;)" \ No newline at end of file diff --git a/tests/prefs.db b/tests/prefs.db new file mode 100644 index 0000000000000000000000000000000000000000..eee5d703bf9e8dd3327d05e289a7717d1e875c6d GIT binary patch literal 5120 zcmeHK&u`N(6i%9s4NDU@rfHfKfl!CUMx3^5dZU}FZK50Ny1}KQavP^aO_Sg_Tgz=i z;>O>>AH)B_VRue&;JtL&!X&f<7c^qUvfuao{Nwxls=Cu|xsvNnAjVAUWu>U7s`5hD z6-8NqItMi^Ds+me0WI3Ml?7$}+x(*TQz>X8MH^{fZwtu%IRkf;fw$`X((0;u{y?(6 z$3qb~uE(RaEo>h(8^=xkxUto0>M2Urd^YB~k3H|{ z^TNHQ?NwEAeVb3B_a5YRkHs=b>|Q!!kET5hcrIdstJ)8wd~ViYH!nE@IRkf}fuc&_ zkOl2R(Jr*_cmKTk33CSiR|bf-te!+%=(IqzmHWM+7xbC82z030Lj}IP=4Fno*&!vJ(kT}u5}IVsAW^5}xFV8Au@6ugpadHT&Lp=1s*pWesn^R!&9qD$ zZgYplo@_CH2<|FO$1!vheQ^l?=6M8W4Q8SUMR6Dk9z`dK3p`f3hV4f9e6Sm~9rzei zCu?3vll46o$^8fypp@*bCo{RY9SXZPDYZ6hWz(t})UayRnguZ%N&YKe6#V|-^67P< zxcvFa?Dy+Zk7()-Uh*j%&m;%HnL7>xA@>8D0|c7Ph=f7=+;$mYAj*tgS@1d4ff)fqL1rs(CI;_z-AD!kHfLF;{r*t@N%gRO@PA8BBx(SDCZ%rj{2*F@?Fr+&%Xm?`Qp&H%Epbs{*h$Sud z(`r4+7yvr_%J#bxTD`I+hS{B1cE&N(;wv~xTKiJOT24>7iH7k(+zW`S}jD!FH literal 0 HcmV?d00001 From d7e32d4081954a9c5ed65e4561191d702e391992 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Thu, 6 Jul 2017 00:15:42 -0300 Subject: [PATCH 02/21] Forcing build. --- tests/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Dockerfile b/tests/Dockerfile index 2932c33..c4d2953 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -5,7 +5,7 @@ RUN mkdir -p /home/anki-user/Documents/Anki/addons COPY AnkiConnect.py /home/anki-user/Documents/Anki/addons # Required if you want to access it from another IP address. -# RUN sed -i 's/127.0.0.1/0.0.0.0/' /home/anki-user/Documents/Anki/addons/AnkiConnect.py +# RUN sed -i 's/127.0.0.1/0.0.0.0/' /home/anki-user/Documents/Anki/addons/AnkiConnect.py COPY tests/prefs.db /home/anki-user/Documents/Anki/prefs.db From 989c750a733d8c8c5206403f2eec05b00d02e517 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Thu, 6 Jul 2017 00:19:44 -0300 Subject: [PATCH 03/21] Fixing .yml. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cae1ba7..dc83438 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,10 @@ sudo: required +language: python services: - docker -language: python python: - "2.7" install: - docker build -f tests/Dockerfile -t txgio/anki-connect . -script: - - curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file +script: > + - `curl localhost:8765 -X POST -s -d '{"action": "version"}'` \ No newline at end of file From 8734bacac2486a3dbe6ef24b1320a4ac16bf498d Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Thu, 6 Jul 2017 00:22:51 -0300 Subject: [PATCH 04/21] Fixing another syntax error. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dc83438..b8035cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,4 @@ python: install: - docker build -f tests/Dockerfile -t txgio/anki-connect . script: > - - `curl localhost:8765 -X POST -s -d '{"action": "version"}'` \ No newline at end of file + - curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file From 4e94a358ac6e1b3ef980ccc150ebea7c63e467e8 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Thu, 6 Jul 2017 00:25:39 -0300 Subject: [PATCH 05/21] Trying to fix another error. --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b8035cf..d76ea34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,5 +6,4 @@ python: - "2.7" install: - docker build -f tests/Dockerfile -t txgio/anki-connect . -script: > - - curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file +script: > curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file From d4e521b17d33684ee87b3bfeb5e1933f03b1f0ea Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Thu, 6 Jul 2017 00:28:47 -0300 Subject: [PATCH 06/21] Another try. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d76ea34..fe00e3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,5 @@ python: - "2.7" install: - docker build -f tests/Dockerfile -t txgio/anki-connect . -script: > curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file +script: > + curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file From 6bec4bb5b6ae9224171d14d25197ca4ff570f16c Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Thu, 6 Jul 2017 00:53:54 -0300 Subject: [PATCH 07/21] Including entrypoint.sh to run xvfb to simulate an X Server. --- tests/Dockerfile | 15 ++++++++++++++- tests/entrypoint.sh | 8 ++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/entrypoint.sh diff --git a/tests/Dockerfile b/tests/Dockerfile index c4d2953..46f6001 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,12 +1,25 @@ FROM txgio/anki +USER root +RUN apt-get update +RUN apt-get install -y xvfb +USER anki-user + RUN mkdir -p /home/anki-user/Documents/Anki/addons COPY AnkiConnect.py /home/anki-user/Documents/Anki/addons # Required if you want to access it from another IP address. -# RUN sed -i 's/127.0.0.1/0.0.0.0/' /home/anki-user/Documents/Anki/addons/AnkiConnect.py +RUN sed -i 's/127.0.0.1/0.0.0.0/' /home/anki-user/Documents/Anki/addons/AnkiConnect.py COPY tests/prefs.db /home/anki-user/Documents/Anki/prefs.db +ADD tests/entrypoint.sh /entrypoint.sh + +USER root +RUN chmod +x /entrypoint.sh +USER anki-user + +ENTRYPOINT ["/entrypoint.sh"] + CMD /bin/bash -c "(/usr/bin/ibus-daemon -xd; /usr/bin/anki;)" \ No newline at end of file diff --git a/tests/entrypoint.sh b/tests/entrypoint.sh new file mode 100644 index 0000000..8285fb9 --- /dev/null +++ b/tests/entrypoint.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +# Start Xvfb +Xvfb -ac -screen scrn 1280x2000x24 :99.0 & +export DISPLAY=:99.0 + +exec "$@" \ No newline at end of file From b64c6e34ee10996c4d0aa77ee2f6969168ad5ade Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Thu, 6 Jul 2017 00:55:10 -0300 Subject: [PATCH 08/21] Running docker. --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe00e3a..cbf008e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,5 +6,7 @@ python: - "2.7" install: - docker build -f tests/Dockerfile -t txgio/anki-connect . -script: > - curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file +script: + - docker run -ti -d --rm -p 8765:8765 txgio/anki-connect + - > + curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file From fdabb37aaffe863f8f1b4a5465eef1bc975b5222 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Thu, 6 Jul 2017 00:59:42 -0300 Subject: [PATCH 09/21] Including a delay to start the test. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index cbf008e..30b971b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,6 @@ install: - docker build -f tests/Dockerfile -t txgio/anki-connect . script: - docker run -ti -d --rm -p 8765:8765 txgio/anki-connect + - sleep 5 - > curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file From 0c9cd00b9ca75fc9131945c6dcdc3c288d2baf57 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 00:18:10 -0300 Subject: [PATCH 10/21] Moving the docker stuff to another folder. --- .travis.yml | 2 +- tests/{ => docker}/Dockerfile | 7 +++---- tests/{ => docker}/entrypoint.sh | 0 tests/{ => docker}/prefs.db | Bin 4 files changed, 4 insertions(+), 5 deletions(-) rename tests/{ => docker}/Dockerfile (58%) rename tests/{ => docker}/entrypoint.sh (100%) rename tests/{ => docker}/prefs.db (100%) diff --git a/.travis.yml b/.travis.yml index 30b971b..44c576b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ services: python: - "2.7" install: - - docker build -f tests/Dockerfile -t txgio/anki-connect . + - docker build -f tests/docker/Dockerfile -t txgio/anki-connect . script: - docker run -ti -d --rm -p 8765:8765 txgio/anki-connect - sleep 5 diff --git a/tests/Dockerfile b/tests/docker/Dockerfile similarity index 58% rename from tests/Dockerfile rename to tests/docker/Dockerfile index 46f6001..e4c0e9e 100644 --- a/tests/Dockerfile +++ b/tests/docker/Dockerfile @@ -9,12 +9,11 @@ RUN mkdir -p /home/anki-user/Documents/Anki/addons COPY AnkiConnect.py /home/anki-user/Documents/Anki/addons -# Required if you want to access it from another IP address. -RUN sed -i 's/127.0.0.1/0.0.0.0/' /home/anki-user/Documents/Anki/addons/AnkiConnect.py +ENV ANKICONNECT_BIND_ADDRESS 0.0.0.0 -COPY tests/prefs.db /home/anki-user/Documents/Anki/prefs.db +COPY tests/docker/prefs.db /home/anki-user/Documents/Anki/prefs.db -ADD tests/entrypoint.sh /entrypoint.sh +ADD tests/docker/entrypoint.sh /entrypoint.sh USER root RUN chmod +x /entrypoint.sh diff --git a/tests/entrypoint.sh b/tests/docker/entrypoint.sh similarity index 100% rename from tests/entrypoint.sh rename to tests/docker/entrypoint.sh diff --git a/tests/prefs.db b/tests/docker/prefs.db similarity index 100% rename from tests/prefs.db rename to tests/docker/prefs.db From 86d6ff8b63935155059402f32e6c55fb43f8ed67 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 01:21:32 -0300 Subject: [PATCH 11/21] Including travis tests. --- .travis.yml | 5 ++--- tests/docker/Dockerfile | 22 ++++++---------------- tests/test_decks.py | 16 ++++++++++++++++ tests/test_misc.py | 10 ++++++++++ tests/util.py | 11 +++++++++++ 5 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 tests/test_decks.py create mode 100644 tests/test_misc.py create mode 100644 tests/util.py diff --git a/.travis.yml b/.travis.yml index 44c576b..2a1a2fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ python: install: - docker build -f tests/docker/Dockerfile -t txgio/anki-connect . script: - - docker run -ti -d --rm -p 8765:8765 txgio/anki-connect + - docker run -ti -d --rm -p 8888:8765 -e ANKICONNECT_BIND_ADDRESS=0.0.0.0 txgio/anki-connect - sleep 5 - - > - curl localhost:8765 -X POST -s -d '{"action": "version"}' \ No newline at end of file + - python -m unittest discover -v \ No newline at end of file diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index e4c0e9e..6d5a8fe 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -1,24 +1,14 @@ -FROM txgio/anki +FROM txgio/anki:2.0.45 -USER root -RUN apt-get update -RUN apt-get install -y xvfb -USER anki-user +RUN apt-get update && \ + apt-get install -y xvfb -RUN mkdir -p /home/anki-user/Documents/Anki/addons +COPY AnkiConnect.py /data/addons/AnkiConnect.py -COPY AnkiConnect.py /home/anki-user/Documents/Anki/addons - -ENV ANKICONNECT_BIND_ADDRESS 0.0.0.0 - -COPY tests/docker/prefs.db /home/anki-user/Documents/Anki/prefs.db +COPY tests/docker/prefs.db /data/prefs.db ADD tests/docker/entrypoint.sh /entrypoint.sh -USER root -RUN chmod +x /entrypoint.sh -USER anki-user - ENTRYPOINT ["/entrypoint.sh"] -CMD /bin/bash -c "(/usr/bin/ibus-daemon -xd; /usr/bin/anki;)" \ No newline at end of file +CMD ["anki", "-b", "/data"] \ No newline at end of file diff --git a/tests/test_decks.py b/tests/test_decks.py new file mode 100644 index 0000000..f4a79e8 --- /dev/null +++ b/tests/test_decks.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +import unittest +from unittest import TestCase +from util import callAnkiConnectEndpoint + +class TestDeckNames(TestCase): + + def test_deckNames(self): + response = callAnkiConnectEndpoint({'action': 'deckNames'}) + self.assertEqual(['Default'], response) + +class TestGetDeckConfig(TestCase): + + def test_getDeckConfig(self): + response = callAnkiConnectEndpoint({'action': 'getDeckConfig', 'params': {'deck': 'Default'}}) + self.assertDictContainsSubset({'name': 'Default', 'replayq': True}, response) \ No newline at end of file diff --git a/tests/test_misc.py b/tests/test_misc.py new file mode 100644 index 0000000..99d9448 --- /dev/null +++ b/tests/test_misc.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +import unittest +from unittest import TestCase +from util import callAnkiConnectEndpoint + +class TestVersion(TestCase): + + def test_version(self): + response = callAnkiConnectEndpoint({'action': 'version'}) + self.assertEqual(4, response) \ No newline at end of file diff --git a/tests/util.py b/tests/util.py new file mode 100644 index 0000000..bf121a0 --- /dev/null +++ b/tests/util.py @@ -0,0 +1,11 @@ +import json +import urllib +import urllib2 + +def callAnkiConnectEndpoint(data): + url = 'http://docker:8888' + dumpedData = json.dumps(data) + req = urllib2.Request(url, dumpedData) + response = urllib2.urlopen(req).read() + responseData = json.loads(response) + return responseData \ No newline at end of file From dad6ef54dd2f20a2d26b8ce038c98fb5c88e514c Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 01:24:55 -0300 Subject: [PATCH 12/21] Changing file permission. --- tests/docker/entrypoint.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tests/docker/entrypoint.sh diff --git a/tests/docker/entrypoint.sh b/tests/docker/entrypoint.sh old mode 100644 new mode 100755 From a78630f5e42fceddd2298332f8d8ba1e7a81e313 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 01:29:58 -0300 Subject: [PATCH 13/21] Changing start directory. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2a1a2fb..2404873 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,4 @@ install: script: - docker run -ti -d --rm -p 8888:8765 -e ANKICONNECT_BIND_ADDRESS=0.0.0.0 txgio/anki-connect - sleep 5 - - python -m unittest discover -v \ No newline at end of file + - python -m unittest discover -s tests \ No newline at end of file From 1642c48f0cec3b2d5dddd9478c08fc2c119f8070 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 01:34:08 -0300 Subject: [PATCH 14/21] Including the docker host. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2404873..5a6f3a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ sudo: required language: python +addons: + hosts: + - docker services: - docker python: From a9dcea9674b77b4d3263820f8d71b747db81cb46 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 01:49:13 -0300 Subject: [PATCH 15/21] Wating the AnkiConnect to be up to run the tests. --- .travis.yml | 4 ++-- tests/scripts/wait-up.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100755 tests/scripts/wait-up.sh diff --git a/.travis.yml b/.travis.yml index 5a6f3a0..de930d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,5 +11,5 @@ install: - docker build -f tests/docker/Dockerfile -t txgio/anki-connect . script: - docker run -ti -d --rm -p 8888:8765 -e ANKICONNECT_BIND_ADDRESS=0.0.0.0 txgio/anki-connect - - sleep 5 - - python -m unittest discover -s tests \ No newline at end of file + - ./tests/scripts/wait-up.sh http://docker:8888 + - python -m unittest discover -s tests -v \ No newline at end of file diff --git a/tests/scripts/wait-up.sh b/tests/scripts/wait-up.sh new file mode 100755 index 0000000..6491b19 --- /dev/null +++ b/tests/scripts/wait-up.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -e + +if [ $# -lt 1 ]; then + printf "First parameter URL required.\n" + exit 1 +fi + +COUNTER=0 +STEP_SIZE=1 +MAX_SECONDS=${2:-10} # Wait 10 seconds if parameter not provided +MAX_RETRIES=$(( $MAX_SECONDS / $STEP_SIZE)) + +URL=$1 + +printf "Waiting URL: "$URL"\n" + +until $(curl --insecure --output /dev/null --silent --fail $URL) || [ $COUNTER -eq $MAX_RETRIES ]; do + printf '.' + sleep $STEP_SIZE + COUNTER=$(($COUNTER + 1)) +done +if [ $COUNTER -eq $MAX_RETRIES ]; then + printf "\nTimeout after "$(( $COUNTER * $STEP_SIZE))" second(s).\n" + exit 2 +else + printf "\nUp successfully after "$(( $COUNTER * $STEP_SIZE))" second(s).\n" +fi \ No newline at end of file From 4ad5bd71b53cbdad0c76419c99e44b068a9c32f2 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 01:51:51 -0300 Subject: [PATCH 16/21] Testing failure case. --- tests/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index 6d5a8fe..af214b9 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -3,7 +3,7 @@ FROM txgio/anki:2.0.45 RUN apt-get update && \ apt-get install -y xvfb -COPY AnkiConnect.py /data/addons/AnkiConnect.py +#COPY AnkiConnect.py /data/addons/AnkiConnect.py COPY tests/docker/prefs.db /data/prefs.db From e59347a07124b66022721bffb0057cc236d6423a Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 01:54:41 -0300 Subject: [PATCH 17/21] Returning the addon include. --- tests/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/docker/Dockerfile b/tests/docker/Dockerfile index af214b9..6d5a8fe 100644 --- a/tests/docker/Dockerfile +++ b/tests/docker/Dockerfile @@ -3,7 +3,7 @@ FROM txgio/anki:2.0.45 RUN apt-get update && \ apt-get install -y xvfb -#COPY AnkiConnect.py /data/addons/AnkiConnect.py +COPY AnkiConnect.py /data/addons/AnkiConnect.py COPY tests/docker/prefs.db /data/prefs.db From 0b4948823b3aa1bf6017b38b1735bb2ed1099fe1 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 17:16:06 -0300 Subject: [PATCH 18/21] Including tests for the Anki 2.1.x version. --- .travis.yml | 10 +++++++--- tests/docker/{ => 2.0.x}/Dockerfile | 0 tests/docker/{ => 2.0.x}/entrypoint.sh | 0 tests/docker/{ => 2.0.x}/prefs.db | Bin tests/docker/2.1.x/Dockerfile | 14 ++++++++++++++ tests/docker/2.1.x/entrypoint.sh | 8 ++++++++ tests/docker/2.1.x/prefs21.db | Bin 0 -> 5120 bytes 7 files changed, 29 insertions(+), 3 deletions(-) rename tests/docker/{ => 2.0.x}/Dockerfile (100%) rename tests/docker/{ => 2.0.x}/entrypoint.sh (100%) rename tests/docker/{ => 2.0.x}/prefs.db (100%) create mode 100644 tests/docker/2.1.x/Dockerfile create mode 100755 tests/docker/2.1.x/entrypoint.sh create mode 100644 tests/docker/2.1.x/prefs21.db diff --git a/.travis.yml b/.travis.yml index de930d6..4cc34ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,12 @@ services: python: - "2.7" install: - - docker build -f tests/docker/Dockerfile -t txgio/anki-connect . + - docker build -f tests/docker/$ANKI_VERSION/Dockerfile -t txgio/anki-connect:$ANKI_VERSION . script: - - docker run -ti -d --rm -p 8888:8765 -e ANKICONNECT_BIND_ADDRESS=0.0.0.0 txgio/anki-connect + - docker run -ti -d --rm -p 8888:8765 -e ANKICONNECT_BIND_ADDRESS=0.0.0.0 txgio/anki-connect:$ANKI_VERSION - ./tests/scripts/wait-up.sh http://docker:8888 - - python -m unittest discover -s tests -v \ No newline at end of file + - python -m unittest discover -s tests -v + +env: + - ANKI_VERSION=2.0.x + - ANKI_VERSION=2.1.x \ No newline at end of file diff --git a/tests/docker/Dockerfile b/tests/docker/2.0.x/Dockerfile similarity index 100% rename from tests/docker/Dockerfile rename to tests/docker/2.0.x/Dockerfile diff --git a/tests/docker/entrypoint.sh b/tests/docker/2.0.x/entrypoint.sh similarity index 100% rename from tests/docker/entrypoint.sh rename to tests/docker/2.0.x/entrypoint.sh diff --git a/tests/docker/prefs.db b/tests/docker/2.0.x/prefs.db similarity index 100% rename from tests/docker/prefs.db rename to tests/docker/2.0.x/prefs.db diff --git a/tests/docker/2.1.x/Dockerfile b/tests/docker/2.1.x/Dockerfile new file mode 100644 index 0000000..58e9572 --- /dev/null +++ b/tests/docker/2.1.x/Dockerfile @@ -0,0 +1,14 @@ +FROM txgio/anki:2.1.0beta14 + +RUN apt-get update && \ + apt-get install -y xvfb + +COPY AnkiConnect.py /data/addons21/AnkiConnect.py + +COPY tests/docker/prefs21.db /data/prefs21.db + +ADD tests/docker/entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] + +CMD ["anki", "-b", "/data"] \ No newline at end of file diff --git a/tests/docker/2.1.x/entrypoint.sh b/tests/docker/2.1.x/entrypoint.sh new file mode 100755 index 0000000..8285fb9 --- /dev/null +++ b/tests/docker/2.1.x/entrypoint.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +# Start Xvfb +Xvfb -ac -screen scrn 1280x2000x24 :99.0 & +export DISPLAY=:99.0 + +exec "$@" \ No newline at end of file diff --git a/tests/docker/2.1.x/prefs21.db b/tests/docker/2.1.x/prefs21.db new file mode 100644 index 0000000000000000000000000000000000000000..dc4d505fe83bc0586426afba324103d21bddc15e GIT binary patch literal 5120 zcmeHKO>f*p7`E42QVps&a41og%7Vjg5efd-&l^b;r4gIZWK-vYx^mXDsadb>+T*m# zEkg8w#4msoNB&BM#DxPtp?7Yyg6AE7Y!WyZ5Nr8k=9!sy=KUDY^9~OOzTo;KN@lLm zZKbZLs`81hD~hs$=LVkgQc<9%ye^kZ?D}^_S%00}(q1VwZK`Nf?Zx#D%lgs+{}T&5 zQde%Tt*IC92=_GLaS~1ZfT!iRwtcj-dAy?^Z*C2C^b%#w(4BEz@Mi*;KXa40KIQX| zbk7xT4u_G@!z>8yeO!C%_V${p_@T$2rB4Fv>yev@NY+QC#F1H+G}ygP8(h_XCl}nv zKU7>^Z^8oVcdO6uJxqC`n@uk^*|3q$!||tl-e9rC4$@)6pT$uk_9Kr2ve}-=08*!Y z?)fgT7TYr<7`Um}j)EvlfVLs(1H+i0*r5?|!ZFJ^hv?JDO+4V;av(*>5E6m)N-X7W zGJbsDPeqi_V*0EZ#HK-_!fdwXj;C3i0yj;zXG_=(g6Qe}{lv34$_uy33;(4QNSaW2nF%9PAR(E=71e;DVRxnw=8ICZK*@IdX#VAIdcoMrz3E z$tIu0!k_tHlKsp+4A|=TZKG#fJyK?|lA&+~^|1^H+_-qG*6)0^J30%ZQ#UAlbI!@M zq#F&L_(>{`vJem{Cb4nCA%(09w_Kgc;}bUv#J~;D&`kc}G*o&gi?NwG*|Ty=n#JU^ z^r37*OQn>?eRbN=_yydn3$`h|k~Uwl13 zsnu7%ZTzRX^4IS|hi~pyIv|1yx=&Gb08dq9pMq#0y;pJloMwX3NgwA-Uj`5H{5*WF zvwT*?QOWTuhUr{k_?H4`LGSYzvSn~r>|TbFWV=qq?ST;~rll?TG%Z~(caD08HOHedGM{nEct{0+U5rzI z{rQDbqhPInh_mYiiR&-mus@=1p?;3~PpJP;hV$o{VHmE0(LDy^2|qMZ?lVDT|0uRh zDp~ZhsoH`bWhMeY6p0A-Y?X%qEz%GNSqN&BggA>F1V};GrLW2i1aKc-Z5u7a?%Hi> z*oDDl0s@qDF|bAdXbENjJMi Nr8d1fRPAE_{|SGCI$!_* literal 0 HcmV?d00001 From eabfb97e811deb1236374d18b8c1fa9e48741f72 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 17:19:21 -0300 Subject: [PATCH 19/21] Fixing some paths. --- tests/docker/2.0.x/Dockerfile | 4 ++-- tests/docker/2.1.x/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/docker/2.0.x/Dockerfile b/tests/docker/2.0.x/Dockerfile index 6d5a8fe..650c050 100644 --- a/tests/docker/2.0.x/Dockerfile +++ b/tests/docker/2.0.x/Dockerfile @@ -5,9 +5,9 @@ RUN apt-get update && \ COPY AnkiConnect.py /data/addons/AnkiConnect.py -COPY tests/docker/prefs.db /data/prefs.db +COPY tests/docker/2.0.x/prefs.db /data/prefs.db -ADD tests/docker/entrypoint.sh /entrypoint.sh +ADD tests/docker/2.0.x/entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/tests/docker/2.1.x/Dockerfile b/tests/docker/2.1.x/Dockerfile index 58e9572..9dbeda6 100644 --- a/tests/docker/2.1.x/Dockerfile +++ b/tests/docker/2.1.x/Dockerfile @@ -5,9 +5,9 @@ RUN apt-get update && \ COPY AnkiConnect.py /data/addons21/AnkiConnect.py -COPY tests/docker/prefs21.db /data/prefs21.db +COPY tests/docker/2.1.x/prefs21.db /data/prefs21.db -ADD tests/docker/entrypoint.sh /entrypoint.sh +ADD tests/docker/2.1.x/entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] From adcb09bf1e724893321ac2ac71f6763ddd5d3ec3 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Tue, 29 Aug 2017 18:16:47 -0300 Subject: [PATCH 20/21] Fixing the addon for the Anki 2.1.x by using it as a module. --- tests/docker/2.1.x/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/docker/2.1.x/Dockerfile b/tests/docker/2.1.x/Dockerfile index 9dbeda6..3438c74 100644 --- a/tests/docker/2.1.x/Dockerfile +++ b/tests/docker/2.1.x/Dockerfile @@ -3,7 +3,7 @@ FROM txgio/anki:2.1.0beta14 RUN apt-get update && \ apt-get install -y xvfb -COPY AnkiConnect.py /data/addons21/AnkiConnect.py +COPY AnkiConnect.py /data/addons21/AnkiConnect/__init__.py COPY tests/docker/2.1.x/prefs21.db /data/prefs21.db From 26ce24152beed6aa58b1aeb8e0d6deaf08be362a Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 29 Aug 2017 21:17:01 -0700 Subject: [PATCH 21/21] add zip script for anki 2.1 --- build_zip.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 build_zip.sh diff --git a/build_zip.sh b/build_zip.sh new file mode 100755 index 0000000..2f6d2ab --- /dev/null +++ b/build_zip.sh @@ -0,0 +1,5 @@ +#!/usr/bin/bash +rm AnkiConnect.zip +cp AnkiConnect.py __init__.py +7za a AnkiConnect.zip __init__.py +rm __init__.py