Beispiel #1
0
 def test_context(self):
     c = get_c()
     dotkeys = ['a']
     v = View(c, dotkeys)
     with v.context({'b': 77}):
         self.assertEqual(v['b'], 77)
     self.assertEqual(v['b'], 5)
Beispiel #2
0
 def test_refresh_attr(self):
     c = get_c()
     dotkeys = ['a']
     v = View(c, dotkeys)
     del v.b
     v.refresh()
     res = v.b
     expected = 5
     self.assertEqual(res, expected)
Beispiel #3
0
    def __init__(self, set_name):
        dotkeys = ['alias']
        self.params = View(get_c(), dotkeys)
        self.set_name = set_name
        self.prepare_sequence_names = []
        self.finish_sequence_names = []
        self.prepare_method_names = []
        self.finish_method_names = []
        self.method_a_calls = []
        self.method_b_calls = []
        self.method_c_calls = []
        self.method_d_calls = []

        def get_methods_dct():
            return {
                'method_a': [],
                'method_b': [],
                'method_c': [],
                'method_d': []
            }

        def get_dct():
            return {
                'seq_1': get_methods_dct(),
                'seq_2': get_methods_dct(),
                'seq_3': get_methods_dct(),
                'seq_4': get_methods_dct()
            }

        self.alias_one_history = get_dct()
        self.alias_two_history = get_dct()
        self.alias_three_history = get_dct()
        self.alias_four_history = get_dct()
Beispiel #4
0
 def test_get_attr(self):
     c = get_c()
     dotkeys = ['a']
     v = View(c, dotkeys)
     res = v.b
     expected = 5
     self.assertEqual(res, expected)
Beispiel #5
0
 def test_live_local(self):
     c = get_c()
     dotkeys = ['a']
     v = View(c, dotkeys)
     v.live = False
     v['b'] = 99
     res = c['a.b']
     expected = 5
     self.assertEqual(res, expected)
     res2 = v['b']
     expected2 = 99
     self.assertEqual(res2, expected2)
     v.live = True
     res3 = v['b']
     expected3 = 5
     self.assertEqual(res3, expected3)
Beispiel #6
0
 def test_new_key(self):
     c = get_c()
     dotkeys = ['a']
     v = View(c, dotkeys)
     c['a.new'] = 99
     res = v['new']
     expected = 99
     self.assertEqual(res, expected)
Beispiel #7
0
 def test_nested_set(self):
     c = get_c()
     c['a.g.h'] = 55
     dotkeys = ['a']
     v = View(c, dotkeys)
     v['g.h'] = 99
     res = v['g']
     expected = {'h': 99}
     self.assertDictEqual(res, expected)
Beispiel #8
0
 def test_live_settings(self):
     c = get_c()
     dotkeys = ['a']
     settings.LIVE_VIEWS = False
     v = View(c, dotkeys)
     # v.live = False
     settings.LIVE_VIEWS = True
     c['a.b'] = 99
     res = v['b']
     expected = 5
     self.assertEqual(res, expected)
     res2 = c['a.b']
     expected2 = 99
     self.assertEqual(res2, expected2)
     v.live = True
     res3 = v['b']
     expected3 = 99
     self.assertEqual(res3, expected3)
Beispiel #9
0
 def test_set(self):
     c = get_c()
     dotkeys = ['a']
     v = View(c, dotkeys)
     v['b'] = 99
     res = v['b']
     expected = 99
     self.assertEqual(res, expected)
     res2 = c['a.b']
     self.assertEqual(res2, expected)
Beispiel #10
0
 def test_refresh(self):
     c = get_c()
     dotkeys = ['a']
     v = View(c, dotkeys)
     v.clear()
     v.refresh()
     v.refresh()
     res = v['b']
     expected = 5
     self.assertEqual(res, expected)
Beispiel #11
0
 def test_init_dot(self):
     c = get_c()
     v = View(c, dotkeys=['.'])
     expected = {'a': {'b': 5}, 'b': {'c': 7}}
     self.assertDictEqual(v, expected)
Beispiel #12
0
 def test_init(self):
     c = get_c()
     dotkeys = ['a']
     v = View(c, dotkeys)
     self.assertTrue(isinstance(v, dict))