예제 #1
0
    def test_invalid_dump(self):
        c = config.StringConfiguration("")
        a = c.root.add_group("a")
        with self.assertRaises(config.InvalidConfig):
            a.register("stuff")

        self.assertEquals("a:\n  stuff:  # Required value\n", c.dumps())
예제 #2
0
    def test_simple_change(self):
        c = config.StringConfiguration(SAMPLE_CONFIG)
        a = c.root.add_group("a")
        stuff = a.register("stuff", default=2)

        self.assertEquals(stuff(), 1)

        c._data['a']['stuff'] = 3

        self.assertEquals(stuff(), 3)
예제 #3
0
    def test_class(self):
        class A:
            def __init__(self, config):
                self.stuff = config.register("stuff")

        c = config.StringConfiguration(SAMPLE_CONFIG)
        a_group = c.root.add_group(utils.snakify(A.__name__))

        a = A(a_group)

        self.assertEquals(a.stuff(), 1)

        c._data['a']['stuff'] = 3

        self.assertEquals(a.stuff(), 3)
예제 #4
0
import asyncio
import copy
import random
import unittest

from dango import config
import discord
from dango.plugins import database
from dango.plugins import redis
from dango.plugins import tracking


conf = config.StringConfiguration("""
database:
  dsn: postgresql://@localhost/spootest
redis:
  db: 5
""")


def async_test(f):
    def wrapper(*args, **kwargs):
        coro = f(*args, **kwargs)
        loop = asyncio.get_event_loop()
        loop.run_until_complete(coro)
    return wrapper


def user():
    m = discord.Object(random.randint(1 << 10, 1 << 58))
    m.name = str(random.randint(1 << 20, 1 << 30))
예제 #5
0
    def test_default_dump(self):
        c = config.StringConfiguration("")
        a = c.root.add_group("a")
        a.register("stuff", default=2)

        self.assertEquals("a:\n  stuff: 2  # Default value\n", c.dumps())
예제 #6
0
    def test_default(self):
        c = config.StringConfiguration("")
        a = c.root.add_group("a")
        stuff = a.register("stuff", default=2)

        self.assertEquals(stuff(), 2)
예제 #7
0
    def test_unicode(self):
        c = config.StringConfiguration(SAMPLE_CONFIG)
        a = c.root.add_group("a")
        stuff = a.register("unicode", default=2)

        self.assertEquals(stuff(), "( ͡° ͜ʖ ͡°)")
예제 #8
0
    def test_simple(self):
        c = config.StringConfiguration(SAMPLE_CONFIG)
        a = c.root.add_group("a")
        stuff = a.register("stuff", default=2)

        self.assertEqual(stuff(), 1)