Including travis tests.
This commit is contained in:
parent
0c9cd00b9c
commit
86d6ff8b63
@ -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"}'
|
||||
- python -m unittest discover -v
|
@ -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;)"
|
||||
CMD ["anki", "-b", "/data"]
|
16
tests/test_decks.py
Normal file
16
tests/test_decks.py
Normal file
@ -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)
|
10
tests/test_misc.py
Normal file
10
tests/test_misc.py
Normal file
@ -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)
|
11
tests/util.py
Normal file
11
tests/util.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user