From ea65ac77f7637831bd8ee4db76cbcec94fdb5125 Mon Sep 17 00:00:00 2001 From: nicobo Date: Sun, 24 May 2020 07:26:53 +0200 Subject: [PATCH] ~ test/ renamed into tests/ --- .travis.yml | 2 +- README.md | 20 ++++++++++++------- {test => tests}/askbot-sample-conf/config.yml | 0 {test => tests}/askbot_sample_output.json | 0 test_askbot.py => tests/test_askbot.py | 0 .../transbot-sample-conf/config.yml | 0 .../goodbye.keywords.json | 0 .../transbot-sample-conf/hello.keywords.json | 0 .../transbot-sample-conf/i18n.en.yml | 0 .../transbot-sample-conf/i18n.fr.yml | 0 .../transbot-sample-conf/languages.en.json | 0 .../transbot-sample-conf/languages.fr.json | 0 .../transbot-sample-conf/likelySubtags.json | 0 {test => tests}/transbot_sample_output.json | 0 14 files changed, 14 insertions(+), 8 deletions(-) rename {test => tests}/askbot-sample-conf/config.yml (100%) rename {test => tests}/askbot_sample_output.json (100%) rename test_askbot.py => tests/test_askbot.py (100%) rename {test => tests}/transbot-sample-conf/config.yml (100%) rename {test => tests}/transbot-sample-conf/goodbye.keywords.json (100%) rename {test => tests}/transbot-sample-conf/hello.keywords.json (100%) rename {test => tests}/transbot-sample-conf/i18n.en.yml (100%) rename {test => tests}/transbot-sample-conf/i18n.fr.yml (100%) rename {test => tests}/transbot-sample-conf/languages.en.json (100%) rename {test => tests}/transbot-sample-conf/languages.fr.json (100%) rename {test => tests}/transbot-sample-conf/likelySubtags.json (100%) rename {test => tests}/transbot_sample_output.json (100%) diff --git a/.travis.yml b/.travis.yml index b5a0d40..49c6da0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,4 @@ python: install: - pip install -r requirements.txt script: - - python -m unittest discover + - python -m unittest discover -s tests diff --git a/README.md b/README.md index 77049ff..efe13e0 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ See below for *Signal* requirements. **Again, this is NOT STABLE code, there is absolutely no warranty it will work or not harm butterflies on the other side of the world... Use it at your own risk !** -The included sample configuration in `test/transbot-sample-conf`, demoes how to make it translate any message like `nicobot in chinese` or simply `nicobot ` (into the current language). +The included sample configuration in `tests/transbot-sample-conf`, demoes how to make it translate any message like `nicobot in chinese` or simply `nicobot ` (into the current language). It can also automatically translate messages containing keywords into a random language. The sample configuration shows how to make it translate any message containing "Hello" or "Goodbye" in many languages. @@ -52,15 +52,15 @@ The sample configuration shows how to make it translate any message containing " pip3 install -r requirements.txt ``` 2. [Create a *Language Translator* service instance on IBM Cloud](https://cloud.ibm.com/catalog/services/language-translator) and [get the URL and API key from your console](https://cloud.ibm.com/resources?groups=resource-instance) -3. Fill them into `test/transbot-sample-conf/config.yml` (`ibmcloud_url` and `ibmcloud_apikey`) -4. Run `python3 nicobot/transbot.py -C test/transbot-sample-conf` +3. Fill them into `tests/transbot-sample-conf/config.yml` (`ibmcloud_url` and `ibmcloud_apikey`) +4. Run `python3 nicobot/transbot.py -C tests/transbot-sample-conf` 5. Input `Hello world` in the console : the bot will print a random translation of "Hello World" 6. Input `Bye nicobot` : the bot will terminate If you want to send & receive messages through *Signal* instead of reading from the keyboard & printing to the console : 1. Install and configure `signal-cli` (see below for details) -2. Run `python3 nicobot/transbot.py -C test/transbot-sample-conf -b signal -U '+33123456789' -r '+34987654321'` with `-U +33123456789` your *Signal* number and `-r +33987654321` the one of the person you want to make the bot chat with +2. Run `python3 nicobot/transbot.py -C tests/transbot-sample-conf -b signal -U '+33123456789' -r '+34987654321'` with `-U +33123456789` your *Signal* number and `-r +33987654321` the one of the person you want to make the bot chat with See dedicated chapters below for more options... @@ -80,7 +80,7 @@ The **i18n.\.yml** file contains localization strings for your locale an - *Transbot* will say "Hello" when started and "Goodbye" before shutting down : you can configure those banners in this file. - It also defines the pattern that terminates the bot. -A sample configuration is available in the `test/transbot-sample-conf/` directory. +A sample configuration is available in the `tests/transbot-sample-conf/` directory. @@ -103,7 +103,7 @@ Below are the most important configuration options for this bot (please also che - **--max-count ** will define how many messages to read at maximum before exiting. This allows the recipient to send several messages in answer. However currently all of those messages are returned at once after they all have been read by the bot so they cannot be parsed on the fly. To give _x_ tries to the recipient, run _x_ times this bot instead. - **--pattern ** defines a pattern that will end the bot when matched. It takes 2 arguments : a symbolic name and a [regular expression pattern](https://docs.python.org/3/howto/regex.html#regex-howto) that will be tested against each message. It can be passed several times in the same command line, hence the `` argument, which will allow identifying which pattern(s) matched. -Sample configuration can be found in `test/askbot-sample-conf`. +Sample configuration can be found in `tests/askbot-sample-conf`. ### Example @@ -195,7 +195,7 @@ keywords_files: - 2.json ``` -See also sample configurations in the `test/` directory. +See also sample configurations in the `tests/` directory. Please first review [YAML syntax](https://yaml.org/spec/1.1/#id857168) if you don't know about YAML. @@ -237,6 +237,12 @@ Sample command line to run the bot with Signal : python3 nicobot/transbot.py -b signal -U +33612345678 -g "mABCDNVoEFGz0YeZM1234Q==" --ibmcloud-url https://api.eu-de.language-translator.watson.cloud.ibm.com/instances/a234567f-4321-abcd-efgh-1234abcd7890 --ibmcloud-apikey "f5sAznhrKQyvBFFaZbtF60m5tzLbqWhyALQawBg5TjRI" +## Development + +To run unit tests : + + python -m unittest discover -v -s tests + ## Resources diff --git a/test/askbot-sample-conf/config.yml b/tests/askbot-sample-conf/config.yml similarity index 100% rename from test/askbot-sample-conf/config.yml rename to tests/askbot-sample-conf/config.yml diff --git a/test/askbot_sample_output.json b/tests/askbot_sample_output.json similarity index 100% rename from test/askbot_sample_output.json rename to tests/askbot_sample_output.json diff --git a/test_askbot.py b/tests/test_askbot.py similarity index 100% rename from test_askbot.py rename to tests/test_askbot.py diff --git a/test/transbot-sample-conf/config.yml b/tests/transbot-sample-conf/config.yml similarity index 100% rename from test/transbot-sample-conf/config.yml rename to tests/transbot-sample-conf/config.yml diff --git a/test/transbot-sample-conf/goodbye.keywords.json b/tests/transbot-sample-conf/goodbye.keywords.json similarity index 100% rename from test/transbot-sample-conf/goodbye.keywords.json rename to tests/transbot-sample-conf/goodbye.keywords.json diff --git a/test/transbot-sample-conf/hello.keywords.json b/tests/transbot-sample-conf/hello.keywords.json similarity index 100% rename from test/transbot-sample-conf/hello.keywords.json rename to tests/transbot-sample-conf/hello.keywords.json diff --git a/test/transbot-sample-conf/i18n.en.yml b/tests/transbot-sample-conf/i18n.en.yml similarity index 100% rename from test/transbot-sample-conf/i18n.en.yml rename to tests/transbot-sample-conf/i18n.en.yml diff --git a/test/transbot-sample-conf/i18n.fr.yml b/tests/transbot-sample-conf/i18n.fr.yml similarity index 100% rename from test/transbot-sample-conf/i18n.fr.yml rename to tests/transbot-sample-conf/i18n.fr.yml diff --git a/test/transbot-sample-conf/languages.en.json b/tests/transbot-sample-conf/languages.en.json similarity index 100% rename from test/transbot-sample-conf/languages.en.json rename to tests/transbot-sample-conf/languages.en.json diff --git a/test/transbot-sample-conf/languages.fr.json b/tests/transbot-sample-conf/languages.fr.json similarity index 100% rename from test/transbot-sample-conf/languages.fr.json rename to tests/transbot-sample-conf/languages.fr.json diff --git a/test/transbot-sample-conf/likelySubtags.json b/tests/transbot-sample-conf/likelySubtags.json similarity index 100% rename from test/transbot-sample-conf/likelySubtags.json rename to tests/transbot-sample-conf/likelySubtags.json diff --git a/test/transbot_sample_output.json b/tests/transbot_sample_output.json similarity index 100% rename from test/transbot_sample_output.json rename to tests/transbot_sample_output.json