2021-12-01 12:20:01 +01:00
|
|
|
from unittest import TestCase
|
|
|
|
import sys
|
|
|
|
import pytest
|
2021-11-22 18:30:29 +01:00
|
|
|
from halfapi.halfapi import HalfAPI
|
|
|
|
|
2021-12-01 12:20:01 +01:00
|
|
|
class TestConf(TestCase):
|
|
|
|
def setUp(self):
|
2021-12-03 17:25:57 +01:00
|
|
|
self.args = {
|
2021-12-01 12:20:01 +01:00
|
|
|
'domain': {
|
2021-12-03 17:25:57 +01:00
|
|
|
'dummy_domain': {
|
|
|
|
'name': 'dummy_domain',
|
|
|
|
'router': '.routers'
|
|
|
|
}
|
2021-12-01 12:20:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
def tearDown(self):
|
|
|
|
pass
|
2021-11-22 18:30:29 +01:00
|
|
|
|
2021-12-01 12:20:01 +01:00
|
|
|
def test_conf_production_default(self):
|
|
|
|
halfapi = HalfAPI({
|
|
|
|
**self.args
|
|
|
|
})
|
|
|
|
assert halfapi.PRODUCTION is True
|
2021-11-22 18:30:29 +01:00
|
|
|
|
2021-12-01 12:20:01 +01:00
|
|
|
def test_conf_production_true(self):
|
|
|
|
halfapi = HalfAPI({
|
|
|
|
**self.args,
|
|
|
|
'production': True,
|
|
|
|
})
|
|
|
|
assert halfapi.PRODUCTION is True
|
2021-11-22 18:30:29 +01:00
|
|
|
|
2021-12-01 12:20:01 +01:00
|
|
|
def test_conf_production_false(self):
|
|
|
|
halfapi = HalfAPI({
|
|
|
|
**self.args,
|
|
|
|
'production': False,
|
|
|
|
})
|
|
|
|
assert halfapi.PRODUCTION is False
|
2021-11-29 06:21:19 +01:00
|
|
|
|
2021-12-01 12:20:01 +01:00
|
|
|
def test_conf_variables(self):
|
|
|
|
from halfapi.conf import (
|
|
|
|
CONFIG,
|
|
|
|
SCHEMA,
|
|
|
|
SECRET,
|
|
|
|
PROJECT_NAME,
|
|
|
|
HOST,
|
|
|
|
PORT,
|
|
|
|
CONF_DIR
|
|
|
|
)
|
|
|
|
|
|
|
|
assert isinstance(CONFIG, dict)
|
|
|
|
assert isinstance(SCHEMA, dict)
|
|
|
|
assert isinstance(SECRET, str)
|
|
|
|
assert isinstance(PROJECT_NAME, str)
|
|
|
|
assert isinstance(HOST, str)
|
2021-12-03 17:25:57 +01:00
|
|
|
assert isinstance(PORT, int)
|
|
|
|
assert int(str(int(PORT))) == PORT
|
2021-12-01 12:20:01 +01:00
|
|
|
assert isinstance(CONF_DIR, str)
|