Exemplo n.º 1
0
    def test_get_lookup_value_returns_tuple_for_objects_single_pk(self):
        instance = HyperlinkedRelatedField(view_name='user-detail')
        session = SESSION()

        user = session.query(self.TestHyperlinkedRelatedFieldUserModel) \
                      .filter_by(name='admin').first()
        self.assertEqual(instance.get_lookup_value(user), (user.id, ))

        session.close()
Exemplo n.º 2
0
    def test_get_lookup_value_returns_tuple_for_objects_composite_pk(self):
        instance = HyperlinkedRelatedField(view_name='user-detail')
        session = SESSION()

        user = session\
            .query(self.TestHyperlinkedRelatedFieldCompositePkModel) \
            .filter_by(id=1, name='test_user').first()
        self.assertEqual(set(instance.get_lookup_value(user)),
                         {user.id, user.name})

        session.close()