def test_one_to_many_plain(self):
        child = OneToManyChild('child')
        self.session.add(child)
        parent = OneToManyParent('parent')
        parent.child = child
        self.session.add(parent)
        self.session.commit()

        parent.fromdict(
            {
                'name': 'Parent new name',
                'child': {
                    'name': 'Child new name'
                }
            },
            follow=['child'])
        result = parent.asdict(follow=['child'])
        expected = {
            'id': parent.id,
            'name': 'Parent new name',
            'child': {
                'id': child.id,
                'name': 'Child new name'
            }
        }

        assert result == expected, "%r == %r" % (result, expected)
Ejemplo n.º 2
0
 def test_one_to_many_plain(self):
     child = OneToManyChild('child')
     parent = OneToManyParent('parent')
     parent.child = child
     self.session.add(parent)
     self.session.commit()
     assert parent.asdict() == {'id': parent.id, 'name': parent.name}
Ejemplo n.º 3
0
 def test_one_to_many_follow_with_parent(self):
     child = OneToManyChild('child')
     parent = OneToManyParent('parent')
     parent.child = child
     self.session.add(parent)
     self.session.commit()
     assert parent.asdict(follow={
         'child': {
             'parent': 'relationships',
         },
     }) == {
         'id': parent.id,
         'name': parent.name,
         'relationships': {
             'child': child.asdict(),
         },
     }
Ejemplo n.º 4
0
    def test_one_to_many_plain(self):
        child = OneToManyChild('child')
        self.session.add(child)
        parent = OneToManyParent('parent')
        parent.child = child
        self.session.add(parent)
        self.session.commit()

        parent.fromdict({'name': 'Parent new name',
                         'child': {'name': 'Child new name'}},
                        follow=['child'])
        result = parent.asdict(follow=['child'])
        expected = {'id': parent.id,
                    'name': 'Parent new name',
                    'child': {'id': child.id, 'name': 'Child new name'}}

        assert result == expected, "%r == %r" % (result, expected)