Browse Source

Merge branch 'dev' into patch-2

Monf 8 years ago
parent
commit
21b6fa4da5

+ 6 - 1
Docs/installation.md

@@ -53,6 +53,11 @@ Install the project using the local environment:
 venv/bin/pip install --editable .
 ```
 
+Activate the local environment:
+```bash
+source venv/bin/activate
+```
+
 ### Method 4 - Developer, dependencies install only
 
 Clone the project:
@@ -63,7 +68,7 @@ cd kalliope
 
 Install the python dependencies directly:
 ```bash
-sudo pip install -r install/python_requirements.txt
+sudo pip install -r install/files/python_requirements.txt
 ```
 
 ## Test your env

+ 16 - 14
Docs/neuron_list.md

@@ -19,21 +19,23 @@ A neuron is a module that will perform some actions attached to an order. You ca
 ## Community neuron
 
 | Name                                                                                 | Description                                                                             |
-|--------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
-| [gmail_checker](https://github.com/kalliope-project/kalliope_neuron_gmail)           | Get the number of unread email and their subjects from a gmail account                     |
-| [google agenda](https://github.com/bacardi55/kalliope-google-calendar)               | Get your next meetings on google calendar                                                |
-| [list available orders](https://github.com/bacardi55/kalliope-list-available-orders) | Let kalliope tell you what she how she can help                                            |
-| [MPD](https://github.com/bacardi55/kalliope-mpd)                                     | Play music via an MPD server                                                               |
-| [openweathermap](https://github.com/kalliope-project/kalliope_neuron_openweathermap) | Get the weather of a location                                                               |
-| [pi camera](https://github.com/bacardi55/kalliope-picamera)                          | Take picture with your picamera                                                             |
+|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|
+| [gmail_checker](https://github.com/kalliope-project/kalliope_neuron_gmail)           | Get the number of unread email and their subjects from a gmail account                  |
+| [google agenda](https://github.com/bacardi55/kalliope-google-calendar)               | Get your next meetings on google calendar                                               |
+| [list available orders](https://github.com/bacardi55/kalliope-list-available-orders) | Let kalliope tell you what she how she can help                                         |
+| [MPD](https://github.com/bacardi55/kalliope-mpd)                                     | Play music via an MPD server                                                            |
+| [openweathermap](https://github.com/kalliope-project/kalliope_neuron_openweathermap) | Get the weather of a location                                                           |
+| [pi camera](https://github.com/bacardi55/kalliope-picamera)                          | Take picture with your picamera                                                         |
 | [pushetta](https://github.com/kalliope-project/kalliope_neuron_pushetta)             | Send a push message to a remote device like Android/iOS/Windows Phone or Chrome browser |
-| [repeat](https://github.com/bacardi55/kalliope-repeat)                               | Make kalliope say whatever you want                                                                   |
-| [rss_reader](https://github.com/kalliope-project/kalliope_neuron_rss_reader)         | Get rss feed from website                                                                   |
-| [tasker](https://github.com/kalliope-project/kalliope_neuron_tasker)                 | Send a message to Android tasker app                                                         |
-| [twitter](https://github.com/kalliope-project/kalliope_neuron_twitter)               | Send a Twit from kalliope                                                                   |
-| [wake_on_lan](https://github.com/kalliope-project/kalliope_neuron_wake_on_lan)       | Wake on lan a computer                                                                       |
-| [web scraper](https://github.com/bacardi55/kalliope-web-scraper)                     | Read web pages that don't provide RSS feed or APIs (by scraping html)                                                    |
-| [wikipedia](https://github.com/kalliope-project/kalliope_neuron_wikipedia)           | Search for a page on Wikipedia                                                               |
+| [repeat](https://github.com/bacardi55/kalliope-repeat)                               | Make kalliope say whatever you want                                                     |
+| [rss_reader](https://github.com/kalliope-project/kalliope_neuron_rss_reader)         | Get rss feed from website                                                               |
+| [tasker](https://github.com/kalliope-project/kalliope_neuron_tasker)                 | Send a message to Android tasker app                                                    |
+| [twitter](https://github.com/kalliope-project/kalliope_neuron_twitter)               | Send a Twit from kalliope                                                               |
+| [wake_on_lan](https://github.com/kalliope-project/kalliope_neuron_wake_on_lan)       | Wake on lan a computer                                                                  |
+| [web scraper](https://github.com/bacardi55/kalliope-web-scraper)                     | Read web pages that don't provide RSS feed or APIs (by scraping html)                   |                            |
+| [wikipedia](https://github.com/kalliope-project/kalliope_neuron_wikipedia)           | Search for a page on Wikipedia                                                          |
+| [slack](https://github.com/kalliope-project/kalliope_neuron_slack)                   | Post and Read message on Slack                                                          |
+
 
 Wanna add your neuron in the list? Open [an issue](../../issues) with the link of your neuron or send a pull request to update the list directly.
 

+ 53 - 0
Tests/test_order_listener.py

@@ -0,0 +1,53 @@
+import unittest
+
+from mock import mock
+
+from kalliope.core import OrderListener
+from kalliope.core.Models import Resources
+from kalliope.core.Models.Stt import Stt
+
+
+class TestOrderListener(unittest.TestCase):
+
+    """Test case for the OrderListener Class"""
+
+    def setUp(self):
+        pass
+
+    def test_load_stt_plugin(self):
+
+        # Test getting default stt
+        ol = OrderListener()
+
+        stt1 = Stt(name="default-stt",
+                   parameters=dict())
+
+        stt2 = Stt(name="second-stt",
+                   parameters=dict())
+
+        stt3 = Stt(name="third-stt",
+                   parameters=dict())
+
+        resources = Resources(stt_folder="/tmp")
+        ol.settings = mock.MagicMock(default_stt_name="default-stt",
+                                     stts=[stt1,stt2,stt3],
+                                     resources=resources)
+
+        callback = mock.MagicMock()
+
+        ol.callback = callback
+
+        with mock.patch("kalliope.core.Utils.get_dynamic_class_instantiation") as mock_get_dynamic_class_instantiation:
+            mock_get_dynamic_class_instantiation.return_value = 'class_instance'
+            self.assertEquals(ol.load_stt_plugin(),
+                              "class_instance",
+                              "Fail getting the proper value")
+
+            mock_get_dynamic_class_instantiation.assert_called_once_with(package_name= "stt",
+                                                                         module_name= "Default-stt",
+                                                                         parameters={'callback' : callback},
+                                                                         resources_dir= "/tmp")
+
+
+if __name__ == '__main__':
+    unittest.main()

+ 2 - 1
Tests/test_resources_manager.py

@@ -147,8 +147,9 @@ class TestResourcesmanager(unittest.TestCase):
                                                                   supported_versions=supported_version))
 
         # version non ok, user does not config
+        # Testing with integer values instead of string
         current_version = '0.4.0'
-        supported_version = ['0.3', '0.2']
+        supported_version = [0.3, 0.2]
 
         with mock.patch('kalliope.Utils.query_yes_no', return_value=True):
             self.assertTrue(ResourcesManager._check_supported_version(current_version=current_version,

+ 1 - 1
kalliope/core/MainController.py

@@ -55,7 +55,7 @@ class MainController:
         self.on_ready_notification_played_once = False
 
         # Initialize the state machine
-        self.machine = Machine(model=self, states=MainController.states, initial='init')
+        self.machine = Machine(model=self, states=MainController.states, initial='init', queued=True)
 
         # define transitions
         self.machine.add_transition('start_trigger', 'init', 'starting_trigger')

+ 0 - 7
kalliope/templates/en_rss.j2

@@ -1,7 +0,0 @@
-Here's the news from {{ feed }}
-
-{% set count = 1 %}
-{% for item in items %}
-News {{ count }}. {{ item.title }}.
-{% set count = count + 1 %}
-{% endfor %}

+ 0 - 50
kalliope/templates/en_systemdate_template_example.j2

@@ -1,50 +0,0 @@
-{% set day_of_week = {
-    "0": "sunday",
-    "1": "monday",
-    "2": "tuesday",
-    "3": "wednesday",
-    "4": "thursday",
-    "5": "friday",
-    "6": "saturday"
-    }[weekday] | default("")
--%}
-
-{% set month_word = {"1": "january", "2": "february", "3": "march", "4": "april", "5": "may", "6": "june", "7": "july", "8": "august", "9": "september", "10": "october", "11": "november", "12": "december"}[month] | default("") -%}
-
-{% set day_month_formated = {
-    "1": "first",
-    "2": "second",
-    "3": "third",
-    "4": "fourth",
-    "5": "fifth",
-    "6": "sixth",
-    "7": "seventh",
-    "8": "eighth",
-    "9": "ninth",
-    "10": "tenth",
-    "11": "eleventh",
-    "12": "twelfth",
-    "13": "thirteenth",
-    "14": "fourteenth",
-    "15": "fifteenth",
-    "16": "sixteenth",
-    "17": "seventeenth",
-    "18": "eighteenth",
-    "19": "nineteenth",
-    "20": "twentieth",
-    "21": "twenty-first",
-    "22": "twenty-second",
-    "23": "twenty-third",
-    "24": "twenty-fourth",
-    "25": "twenty-fifth",
-    "26": "twenty-sixth",
-    "27": "twenty-seventh",
-    "28": "twenty-eighth",
-    "29": "twenty-ninth",
-    "30": "thirtieth",
-    "31": "thirty-first",
-
-}[day_month] | default("") -%}
-
-It' {{ hours }} hours and {{ minutes }} minutes.
-We are the {{ day_of_week }} {{ month_word }} the {{ day_month_formated }} {{ year }}

+ 0 - 12
kalliope/templates/fr_gmail.j2

@@ -1,12 +0,0 @@
-{% if unread == 0 %}
-    Vous n'avez aucun email
-{% else %}
-    Vous avez {{ unread }} email.
-    {% set count = 1 %}
-    {% if unread > 0 %}
-        {% for subject in subjects %}
-         i-maile {{ count }}. {{ subject }}.
-         {% set count = count + 1 %}
-        {% endfor %}
-    {% endif %}
-{% endif %}

+ 0 - 5
kalliope/templates/fr_gmail_count_unread.j2

@@ -1,5 +0,0 @@
-{% if unread == 0 %}
-    Vous n'avez aucun email.
-{% else %}
-    Vous avez {{ unread }} email.
-{% endif %}

+ 0 - 7
kalliope/templates/fr_rss.j2

@@ -1,7 +0,0 @@
-Voici les nouvelles de {{ feed }}
-
-{% set count = 1 %}
-{% for item in items %}
-Nouvelle {{ count }}. {{ item.title }}.
-{% set count = count + 1 %}
-{% endfor %}

+ 0 - 5
kalliope/templates/fr_systemdate_template_example.j2

@@ -1,5 +0,0 @@
-{% set day_of_week = {"0": "dimanche", "1": "lundi", "2": "mardi", "3": "mercredi", "4": "jeudi", "5": "vendredi", "6": "samedi"}[weekday] | default("") -%}
-{% set month_word = {"1": "janvier", "2": "février", "3": "mars", "4": "avril", "5": "mai", "6": "juin", "7": "juillet", "8": "août", "9": "septembre", "10": "octobre", "11": "novembre", "12": "décembre"}[month] | default("") -%}
-
-Il est {{ hours }} heures et {{ minutes }} minutes.
-Nous sommes le {{ day_of_week }} {{ day_month }} {{ month_word }} {{ year }}

+ 0 - 5
kalliope/templates/remove_file.j2

@@ -1,5 +0,0 @@
-{% if returncode == 0 %}
-    The command has succeeded
-{% else %}
-    The command has failed
-{% endif %}

+ 0 - 12
kalliope/templates/wikipedia_returned_value.j2

@@ -1,12 +0,0 @@
-{% if returncode == "DisambiguationError" %}
-    Veuillez etre plus précis. La recherche que vous venez d'éffectuez peut correspondre au page Wikipédia suivante:
-    {% if may_refer is not none %}
-        {% for el in may_refer %}
-            {{ el }}
-        {% endfor %}
-    {% endif %}
-{% elif returncode == "PageError" %}
-    Je n'ai rien trouvé la dessus
-{% else %}
-    {{ summary }}
-{% endif %}