Пример #1
0
    def test_create_or_modify_returns_modified_offerer_search_by_id(self, app):
        # Given
        offerer1 = Offerer(name="foo")
        ApiHandler.save(offerer1)

        # When
        offerer2 = Offerer.create_or_modify({
            '__SEARCH_BY__': 'id',
            'id': humanize(offerer1.id),
            'name': 'fee'
        })

        # Then
        assert offerer2.id == offerer1.id
        assert offerer2.name == "fee"
Пример #2
0
    def test_for_valid_many_to_many_relationship(self, app):
        # Given
        offerer = Offerer(name='foo', type='bar')
        user = User(email='*****@*****.**', publicName='bar')
        ApiHandler.save(user, offerer)
        user_offerer = UserOfferer(offerer=offerer, user=user)

        # When
        ApiHandler.save(user_offerer)

        # Then
        assert user_offerer.offererId == offerer.id
        assert user_offerer.userId == user.id
Пример #3
0
    def test_create_or_modify_returns_created_user_offerer_search_by_relationship_ids(
            self, app):
        # Given
        offerer = Offerer(name="foo")
        user = User(email="foo.marx@com", publicName="Foo Marx")
        ApiHandler.save(offerer, user)

        # When
        user_offerer = UserOfferer.create_or_modify({
            '__SEARCH_BY__': ['offererId', 'userId'],
            'rights':
            'admin',
            'offererId':
            humanize(offerer.id),
            'userId':
            humanize(user.id)
        })

        # Then
        assert user_offerer.offererId == offerer.id
        assert user_offerer.rights == 'admin'
        assert user_offerer.userId == user.id