Пример #1
0
    def test_get_value(self):
        ds = SimpleDemoModelSource.as_datasource()
        col = CalcColumn(['integer1'])

        self.assertEqual(col.get_value(SimpleDemoModel(integer1=5), ds), 5)

        col.initial = 10
        self.assertEqual(col.get_value(SimpleDemoModel(integer1=5), ds), 15)
Пример #2
0
 def test_custom_column_from_string(self):
     G(SimpleDemoModel, n=2, char='abc', integer1=1, integer2=3)
     ds = Datasource.as_datasource(model=SimpleDemoModel,
                                   extra_column=lambda obj: 'extra_value',
                                   columns=[
                                       Column('integer1'), 'integer2',
                                       CalcColumn(['integer1', 'integer2'])
                                   ])
     self.assertSequenceEqual(ds, [(1, 3, 4), (1, 3, 4)])
Пример #3
0
 def test_custom_column(self):
     G(SimpleDemoModel, n=2, char='abc', integer1=1, integer2=3)
     ds = Datasource.as_datasource(model=SimpleDemoModel,
                                   columns=[
                                       Column('integer1'),
                                       Column('integer2'),
                                       CalcColumn(['integer1', 'integer2'])
                                   ])
     self.assertSequenceEqual(ds, [(1, 3, 4), (1, 3, 4)])
Пример #4
0
 def test_init(self):
     col = CalcColumn('char')
     self.assertEqual(col.attrs, 'char')