Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
chatbot/config_test.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (20 sloc)
832 Bytes
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
# pylint: disable=C0414,C0111,W0104 | |
import unittest | |
import os.path as path | |
from frozen import FrozenException | |
from config import Configuration | |
class ConfigurationTestCase(unittest.TestCase): | |
def setUp(self): | |
dirname = path.dirname(__file__) | |
self.config_file = path.join(dirname, "config.example.json") | |
self.config = Configuration(self.config_file) | |
def test_mutation(self): | |
with self.assertRaises(FrozenException): | |
self.config.discord.token = "hello" | |
def test_missing_attr(self): | |
with self.assertRaises(AttributeError): | |
self.config.not_here | |
def test_working_attr(self): | |
self.assertTrue(self.config.discord.token, "TOKEN_HERE") | |
def test_working_subscript(self): | |
self.assertTrue(self.config["discord"]["token"], "TOKEN_HERE") |