Esempio n. 1
0
 def test_map_to_and_from_domain_when_no_mapper(self):
     f = Field(name="f1",  datatype=Decimal )
     bf = BoundField(f , StubModel())
     bf.set_value("123")
     bf.map_to_domain()
     bf.set_value("456")
     bf.map_from_domain()
     self.assertEqual(Decimal("456"), bf.value)
Esempio n. 2
0
 def test_map_to_and_from_domain_when_no_mapper(self):
     f = Field(name="f1", datatype=Decimal)
     bf = BoundField(f, StubModel())
     bf.set_value("123")
     bf.map_to_domain()
     bf.set_value("456")
     bf.map_from_domain()
     self.assertEqual(Decimal("456"), bf.value)
Esempio n. 3
0
 def test_map_to_and_from_domain_using_model_proxy(self):
     f = self.create_field()
     m = StubModel()
     bf = BoundField( f , m)
     bf.set_value("123")
     bf.map_to_domain()
     self.assertEqual(Decimal("123"), m.domain_value)
     m.domain_value = Decimal('456')
     bf.map_from_domain()
     self.assertEqual(Decimal("456"), bf.value)
Esempio n. 4
0
 def test_map_to_and_from_domain_using_model_proxy(self):
     f = self.create_field()
     m = StubModel()
     bf = BoundField(f, m)
     bf.set_value("123")
     bf.map_to_domain()
     self.assertEqual(Decimal("123"), m.domain_value)
     m.domain_value = Decimal('456')
     bf.map_from_domain()
     self.assertEqual(Decimal("456"), bf.value)
Esempio n. 5
0
    def test_map_to_and_from_domain_using_direct_syntax(self):
        class DomainObject:
            f1 = 'aaa'

        do = DomainObject()
        f = Field(name="f1", datatype=Decimal, domain_mapping="do.f1")
        m = StubModel()
        m.get_domain_object = lambda name: do
        bf = BoundField(f, m)
        bf.set_value("123")
        bf.map_to_domain()
        self.assertEqual(Decimal("123"), do.f1)
        do.f1 = Decimal("456")
        bf.map_from_domain()
        self.assertEqual(Decimal("456"), bf.value)
Esempio n. 6
0
 def test_map_to_and_from_domain_using_direct_syntax(self):
     
     class DomainObject:
         f1 = 'aaa'
         
     do = DomainObject()
     f = Field(name="f1",  datatype=Decimal, domain_mapping="do.f1" )
     m = StubModel()
     m.get_domain_object = lambda name: do
     bf = BoundField( f , m)
     bf.set_value("123")
     bf.map_to_domain()
     self.assertEqual(Decimal("123"), do.f1)
     do.f1 = Decimal("456")
     bf.map_from_domain()
     self.assertEqual(Decimal("456"), bf.value)