<s> from __future__ import absolute_import <EOL> import pytest <EOL> import tempfile <EOL> from . . fixtures import * <EOL> from ... backends . file import NonUnique <EOL> from blitzdb . tests . helpers . movie_data import Actor <EOL> def test_nonunique_file_backend_index ( file_backend ) : <EOL> file_backend . create_index ( Actor , fields = { '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> actor1 = Actor ( { '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> file_backend . save ( actor1 ) <EOL> actor2 = Actor ( { '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> file_backend . save ( actor2 ) <EOL> file_backend . commit ( ) <EOL> assert actor1 . pk != actor2 . pk <EOL> def test_unique_file_backend_index ( file_backend ) : <EOL> file_backend . create_index ( Actor , fields = { '<STR_LIT>' : <NUM_LIT:1> } , unique = True ) <EOL> actor1 = Actor ( { '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> file_backend . save ( actor1 ) <EOL> actor2 = Actor ( { '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> file_backend . save ( actor2 ) <EOL> with pytest . raises ( NonUnique ) : <EOL> file_backend . commit ( ) </s>
