def setUp(self): self.atomic = AtomicObject('meaning_of_life', 42) self.aggregation = AggregationObject( 'Car', **{ 'model': 1934, 'brand': 'Ford' }) self.referal = AtomicObject('Text', 'Hello World!') self.reference = ReferenceObject(self.referal)
def test_update_value_check_updated_at(self): atomic = AtomicObject('PersonaID', 34) created_at = atomic.get_metadata().created_at modified_at = atomic.get_metadata().modified_at atomic.value = 32 self.assertNotEqual(34, atomic.get_value()) self.assertEqual(32, atomic.get_value()) self.assertGreater(atomic.get_metadata().modified_at, modified_at) self.assertEqual(created_at, atomic.get_metadata().created_at)
def setUp(self): self.schema = Schema("TestSchema") self.atomic = AtomicObject('student_id', '244') self.aggregation = AggregationObject('Person', **{ 'name': 'Mark', 'age': 23 }) self.reference = ReferenceObject(self.atomic)
class TestMeltaObjectsTransaction(TestCase): def setUp(self): self.atomic = AtomicObject('meaning_of_life', 42) self.aggregation = AggregationObject( 'Car', **{ 'model': 1934, 'brand': 'Ford' }) self.referal = AtomicObject('Text', 'Hello World!') self.reference = ReferenceObject(self.referal) def test_atomic_transaction(self): self.atomic.start() self.atomic.stop() self.assertEqual(self.atomic.value, 42) def test_atomic_with_change(self): self.atomic.start() self.atomic.value = 34 self.atomic.commit() self.assertEqual(self.atomic.value, 34) def test_atomic_rollback(self): self.atomic.start() self.atomic.value = 53 self.assertEqual(self.atomic.value, 53) self.atomic.rollback() self.assertEqual(self.atomic.value, 42) def test_atomic_with_checkpoint(self): self.atomic.start() self.atomic.value = 34 self.atomic.checkpoint() self.assertEqual(self.atomic.value, 34) self.atomic.value = 55 self.atomic.rollback() self.assertEqual(self.atomic.value, 34) def test_atomic_propagation_to_meta(self): self.atomic.start() dirty = DIRTY_MELTAOBJECT_STATUS clean = self.atomic.metadata.object_status self.atomic.metadata.object_status = dirty self.atomic.commit() self.assertEqual(self.atomic.metadata.object_status, dirty) self.assertNotEqual(self.atomic.metadata.object_status, clean) def test_atomic_propagation_rollback(self): self.atomic.start() dirty = DIRTY_MELTAOBJECT_STATUS old_status = self.atomic.metadata.object_status self.atomic.metadata.object_status = dirty self.atomic.rollback() self.assertEqual(old_status, self.atomic.metadata.object_status) self.assertNotEqual(self.atomic.metadata.object_status, dirty) def test_atomic_propagation_checkpoint(self): self.atomic.start() dirty = DIRTY_MELTAOBJECT_STATUS clean = self.atomic.metadata.object_status self.atomic.metadata.object_status = dirty self.atomic.checkpoint() invalid = INVALID_MELTAOBJECT_STATUS self.atomic.metadata.object_status = invalid self.atomic.rollback() self.assertEqual(dirty, self.atomic.metadata.object_status) self.assertNotEqual(invalid, self.atomic.metadata.object_status) self.assertNotEqual(clean, self.atomic.metadata.object_status)
def test_create_valid_atomic_object(self): atomic = AtomicObject(None, 2) self.assertEqual(atomic.value, 2) self.assertTrue(atomic.instance_name.startswith('AtomicObject'))
def setUp(self): self.atomic = AtomicObject('Estudiante', 234) self.aggregated = AggregationObject(**{'name': 'John', 'age': 54})
def test_create_null_value_object(self): atomic = AtomicObject('PersonID') self.assertEqual(atomic.value, None) self.assertEqual(atomic.instance_name, 'PersonID')