Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
2,995 additions
and
2,342 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 |
---|---|---|
@@ -1,37 +1,61 @@ | ||
language: python | ||
|
||
services: | ||
- docker | ||
|
||
python: | ||
- "2.7" | ||
- "3.6" | ||
- "3.7" | ||
|
||
# command to install dependencies | ||
before_install: | ||
- docker build --force-rm=true --build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} --build-arg TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE} --build-arg TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG} --build-arg TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} -t kalliope-ubuntu1604 -f docker/ubuntu_16_04.dockerfile . | ||
- docker build --force-rm=true --build-arg TRAVIS_BRANCH=${TRAVIS_BRANCH} --build-arg TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE} --build-arg TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG} --build-arg TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} -t kalliope-debian8 -f docker/debian8.dockerfile . | ||
- sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse" | ||
- sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse" | ||
- sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse" | ||
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y | ||
- sudo apt-get update -q | ||
- sudo apt-get install $(cat install/files/deb-packages_requirements.txt) | ||
- sudo apt-get install gcc-4.9 libstdc++6 libpython3.4-dev | ||
- wget https://bootstrap.pypa.io/get-pip.py | ||
- sudo python get-pip.py | ||
env: | ||
global: | ||
- INSTALL_TYPE=setup | ||
|
||
install: | ||
- pip install -r install/files/python_requirements.txt | ||
- pip install coverage python-coveralls | ||
matrix: | ||
include: | ||
- name: Test in Docker Ubuntu 18.04 | ||
env: | ||
- INSTALL_TYPE=docker | ||
services: | ||
- docker | ||
before_install: | ||
- docker build --force-rm=true -t kalliope-ubuntu1804 -f docker/testing_ubuntu_18_04.dockerfile . | ||
script: | ||
- docker run -it --rm -e TRAVIS_BRANCH=${TRAVIS_BRANCH} -e TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE} -e TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG} -e TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} kalliope-ubuntu1804 | ||
|
||
# command to run tests | ||
script: | ||
# - pytest | ||
- docker run -it --rm kalliope-ubuntu1604 | ||
- docker run -it --rm kalliope-debian8 | ||
- coverage run --source=kalliope -m unittest discover | ||
- coverage report -m | ||
- name: Test in Docker Debian 10 | ||
env: | ||
- INSTALL_TYPE=docker | ||
services: | ||
- docker | ||
before_install: | ||
- docker build --force-rm=true -t kalliope-debian10 -f docker/testing_debian10.dockerfile . | ||
script: | ||
- docker run -it --rm -e TRAVIS_BRANCH=${TRAVIS_BRANCH} -e TRAVIS_EVENT_TYPE=${TRAVIS_EVENT_TYPE} -e TRAVIS_PULL_REQUEST_SLUG=${TRAVIS_PULL_REQUEST_SLUG} -e TRAVIS_PULL_REQUEST_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH} kalliope-debian10 | ||
|
||
|
||
before_install: | ||
- | | ||
if [ "${INSTALL_TYPE}" == "setup" ]; then | ||
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" | ||
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse" | ||
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse" | ||
sudo add-apt-repository -y ppa:deadsnakes/ppa # contains libpython3.6-dev | ||
sudo apt-get update -q | ||
sudo apt-get install $(cat install/files/deb-packages_requirements.txt) | ||
sudo apt-get install gcc-5 python3-dev libpython3.6-dev | ||
fi | ||
install: | ||
- | | ||
if [ "${INSTALL_TYPE}" == "setup" ]; then | ||
pip install -r install/files/python_requirements.txt; | ||
pip install coverage python-coveralls; | ||
fi | ||
script: | ||
- | | ||
if [ "${INSTALL_TYPE}" == "setup" ]; then | ||
coverage run --source=kalliope -m unittest discover; | ||
coverage report -m; | ||
fi | ||
after_success: | ||
- coveralls | ||
- | | ||
if [ "${INSTALL_TYPE}" == "setup" ]; then | ||
coveralls | ||
fi |
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
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
Empty file.
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,53 @@ | ||
import os | ||
|
||
from flask import Flask | ||
from flask_testing import LiveServerTestCase | ||
|
||
from kalliope.core import LifoManager | ||
from kalliope.core.ConfigurationManager import BrainLoader | ||
from kalliope.core.ConfigurationManager import SettingLoader | ||
from kalliope.core.Models import Singleton | ||
from kalliope.core.RestAPI.FlaskAPI import FlaskAPI | ||
|
||
|
||
class RestAPITestBase(LiveServerTestCase): | ||
|
||
def tearDown(self): | ||
Singleton._instances = {} | ||
# clean the lifo | ||
LifoManager.clean_saved_lifo() | ||
|
||
def create_app(self): | ||
""" | ||
executed once at the beginning of the test | ||
""" | ||
# be sure that the singleton haven't been loaded before | ||
Singleton._instances = {} | ||
current_path = os.getcwd() | ||
if "/Tests" in current_path: | ||
full_path_brain_to_test = current_path + os.sep + os.pardir + os.sep + "brains/brain_test_api.yml" | ||
self.audio_file = "files/bonjour.wav" | ||
else: | ||
full_path_brain_to_test = current_path + os.sep + "Tests/brains/brain_test_api.yml" | ||
self.audio_file = "Tests/files/bonjour.wav" | ||
|
||
# rest api config | ||
self.sl = SettingLoader() | ||
self.settings = self.sl.settings | ||
self.settings.rest_api.password_protected = False | ||
self.settings.active = True | ||
self.settings.port = 5000 | ||
self.settings.allowed_cors_origin = "*" | ||
self.settings.default_synapse = None | ||
self.settings.hooks["on_order_not_found"] = "order-not-found-synapse" | ||
|
||
# prepare a test brain | ||
brain_to_test = full_path_brain_to_test | ||
brain_loader = BrainLoader(file_path=brain_to_test) | ||
brain = brain_loader.brain | ||
|
||
self.app = Flask(__name__) | ||
self.app.config['TESTING'] = True | ||
self.flask_api = FlaskAPI(self.app, port=5000, brain=brain) | ||
self.client = self.app.test_client() | ||
return self.flask_api.app |
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 @@ | ||
import json | ||
import unittest | ||
|
||
from Tests.test_api.base import RestAPITestBase | ||
from kalliope._version import version_str | ||
|
||
|
||
class TestMainView(RestAPITestBase): | ||
|
||
def test_server_is_up_and_running(self): | ||
# response = urllib2.urlopen(self.get_server_url()) | ||
response = self.client.get(self.get_server_url()) | ||
self.assertEqual(response.status_code, 200) | ||
|
||
def test_get_main_page(self): | ||
url = self.get_server_url() + "/" | ||
response = self.client.get(url) | ||
expected_content = { | ||
"Kalliope version": "%s" % version_str | ||
} | ||
self.assertEqual(json.dumps(expected_content, sort_keys=True), | ||
json.dumps(json.loads(response.get_data().decode('utf-8')), sort_keys=True)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.