Esempio n. 1
0
    def test_update(self):
        a = dict2.from_dict({'a': {'b': 10}, 'b': 10})
        b = dict2.from_dict({'a': {'b': 20}})

        a.update(b)
        self.assertEqual(a, {'a': {'b': 20}, 'b': 10})

        a = dict2.from_dict({})
        b = dict2.from_dict({'a': {'b': 20}})

        a.update(b)
        self.assertEqual(a, {'a': {'b': 20}})
Esempio n. 2
0
    def init(self):
        self.query = dict2.from_dict(self.ctx.request.json)
        self.auth = self.ctx.modules.auth

        self.login_svc = self.auth.services.UserLoginService(
            username=self.query.username,
            password=self.query.password
        )
Esempio n. 3
0
    def init(self):
        self.query = dict2.from_dict(self.ctx.request.json)
        self.auth = self.ctx.modules.auth

        if not self.query.username:
            self.query.username = self.ctx.auth.user.username

        self.login_svc = self.auth.services.UserLoginService(
            username=self.query.username, password=self.query.password)

        self.change_pwd_svc = self.auth.services.UserChangePasswordService(
            username=self.query.username, password=self.query.new_password)
Esempio n. 4
0
    def test_conversion(self):
        obj = {
            'a': 100,
            'b': 'Hello',
            'c': [{
                'a': 3.14
            }, 'World'],
            'd': {
                'a': ['test'],
                'b': {
                    'a': 6.28,
                    'b': [1, 2]
                }
            }
        }

        obj2 = dict2.from_dict(obj).to_dict()
        self.assertEqual(obj, obj2)

        obj2 = dict2.from_dict(obj)
        obj2 = dict2.from_dict(obj2)
        self.assertEqual(obj, obj2)
Esempio n. 5
0
 def test_property(self):
     a = dict2.from_dict({'a': {'b': 10}})
     b = a.get_property('a.b')
     self.assertEqual(b, 10)
     self.assertIsNone(a.get_property('a.c'))
Esempio n. 6
0
 def test_conversion(self):
     a = {'a': ['b', 10, 20]}
     b = dict2.from_dict(a).to_dict()
     self.assertEqual(a, b)