<s> import json <EOL> from mechanize . _mechanize import LinkNotFoundError <EOL> from pytest import raises <EOL> from kotti . testing import BASE_URL <EOL> from kotti . testing import user <EOL> from kotti . views . edit . upload import UploadView <EOL> def test_upload_anonymous ( root , dummy_request , browser ) : <EOL> view = UploadView ( root , dummy_request ) <EOL> assert view . factories == [ ] <EOL> link = browser . getLink <EOL> browser . open ( u'<STR_LIT>' . format ( BASE_URL ) ) <EOL> with raises ( LinkNotFoundError ) : <EOL> link ( '<STR_LIT>' ) . click ( ) <EOL> browser . open ( u'<STR_LIT>' . format ( BASE_URL ) ) <EOL> assert browser . url . startswith ( u'<STR_LIT>' . format ( BASE_URL ) ) <EOL> browser . open ( u'<STR_LIT>' . format ( BASE_URL ) ) <EOL> assert browser . url . startswith ( u'<STR_LIT>' . format ( BASE_URL ) ) <EOL> @ user ( '<STR_LIT>' ) <EOL> def test_upload_authenticated_wo_mimetype ( root , dummy_request , browser ) : <EOL> with raises ( KeyError ) : <EOL> browser . open ( u'<STR_LIT>' . format ( BASE_URL ) ) <EOL> @ user ( '<STR_LIT>' ) <EOL> def test_upload_authenticated_text ( root , dummy_request , browser ) : <EOL> browser . open ( u'<STR_LIT>' . format ( BASE_URL ) ) <EOL> j = json . loads ( browser . contents ) <EOL> assert '<STR_LIT>' in j <EOL> types = j [ '<STR_LIT>' ] <EOL> assert len ( types ) == <NUM_LIT:1> <EOL> assert types [ <NUM_LIT:0> ] [ '<STR_LIT:name>' ] == u'<STR_LIT>' </s>
