-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from idealista/develop
Develop
- Loading branch information
Showing
13 changed files
with
162 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
language: python | ||
python: | ||
- "3.6" | ||
install: "pip install -r requirements.txt" | ||
script: python -m unittest discover tests |
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
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
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,21 @@ | ||
[loggers] | ||
keys=root | ||
|
||
[handlers] | ||
keys=stream_handler | ||
|
||
[formatters] | ||
keys=formatter | ||
|
||
[logger_root] | ||
level=%(log_level)s | ||
handlers=stream_handler | ||
|
||
[handler_stream_handler] | ||
class=StreamHandler | ||
level=%(log_level)s | ||
formatter=formatter | ||
args=(sys.stdout,) | ||
|
||
[formatter_formatter] | ||
format=%(asctime)s %(name)-4s %(levelname)-4s %(message)s |
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
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,7 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../app'))) | ||
|
||
import server | ||
import exceptions |
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,6 @@ | ||
[HTTP Server] | ||
Host: 1.1.1.1 | ||
Port: 9089 | ||
|
||
[Microsoft Teams] | ||
Connector=some_url |
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,2 @@ | ||
[Microsoft Teams] | ||
Connector=some_url |
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,51 @@ | ||
import unittest | ||
|
||
from context import server | ||
from context import exceptions | ||
|
||
|
||
class TestServer(unittest.TestCase): | ||
|
||
TEST_CONFIG_FILES_PATH = 'tests/data/' | ||
DEFAULT_CONFIG_RELATIVE_PATH = './config.ini' | ||
|
||
def test_get_config_with_invalid_path(self): | ||
invalid_relative_path = self.TEST_CONFIG_FILES_PATH + 'invalid_path' | ||
|
||
self.assertRaises(FileNotFoundError, | ||
server.get_config, | ||
self.DEFAULT_CONFIG_RELATIVE_PATH, | ||
invalid_relative_path) | ||
|
||
def test_get_config_without_required_keys_should_raise_exception(self): | ||
empty_config_relative_path = self.TEST_CONFIG_FILES_PATH + \ | ||
'empty_config.ini' | ||
|
||
self.assertRaises(exceptions.MissingConnectorConfigKeyException, | ||
server.get_config, | ||
self.DEFAULT_CONFIG_RELATIVE_PATH, | ||
empty_config_relative_path) | ||
|
||
def test_get_config_without_override(self): | ||
provided_config_relative_path = self.TEST_CONFIG_FILES_PATH + \ | ||
'without_overriding_defaults.ini' | ||
config = server.get_config(self.DEFAULT_CONFIG_RELATIVE_PATH, | ||
provided_config_relative_path) | ||
|
||
self.assertEqual(config.get('HTTP Server', 'Host'), '0.0.0.0') | ||
self.assertEqual(config.get('HTTP Server', 'Port'), '8089') | ||
self.assertTrue(config.get('Microsoft Teams', 'Connector')) | ||
|
||
def test_get_config_overriding_defaults(self): | ||
provided_config_relative_path = self.TEST_CONFIG_FILES_PATH + \ | ||
'overriding_defaults.ini' | ||
config = server.get_config(self.DEFAULT_CONFIG_RELATIVE_PATH, | ||
provided_config_relative_path) | ||
|
||
self.assertEqual(config.get('HTTP Server', 'Host'), '1.1.1.1') | ||
self.assertEqual(config.get('HTTP Server', 'Port'), '9089') | ||
self.assertTrue(config.get('Microsoft Teams', 'Connector')) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |