<s> """<STR_LIT>""" <EOL> from django import test <EOL> from django . core . files . uploadedfile import SimpleUploadedFile <EOL> from mock import patch <EOL> from omaha . models import Application , Channel , Platform , Version , Action , EVENT_DICT_CHOICES <EOL> from omaha . models import version_upload_to <EOL> from omaha . factories import ApplicationFactory , ChannelFactory , PlatformFactory , VersionFactory <EOL> from omaha . tests . utils import temporary_media_root <EOL> class ApplicationModelTest ( test . SimpleTestCase ) : <EOL> def test_factory ( self ) : <EOL> app = ApplicationFactory . create ( ) <EOL> self . assertTrue ( Application . objects . get ( id = app . id ) ) <EOL> class ChannelModelTest ( test . TestCase ) : <EOL> def test_factory ( self ) : <EOL> channel = ChannelFactory . create ( ) <EOL> self . assertTrue ( Channel . objects . get ( id = channel . id ) ) <EOL> class PlatformModelTest ( test . TestCase ) : <EOL> def test_factory ( self ) : <EOL> platform = PlatformFactory . create ( ) <EOL> self . assertTrue ( Platform . objects . get ( id = platform . id ) ) <EOL> class VersionModelTest ( test . TestCase ) : <EOL> @ temporary_media_root ( ) <EOL> def test_version_upload_to ( self ) : <EOL> version = VersionFactory . create ( file = SimpleUploadedFile ( '<STR_LIT>' , False ) ) <EOL> self . assertEqual ( version_upload_to ( version , '<STR_LIT>' ) , <EOL> '<STR_LIT>' . format ( <EOL> version . app . name , <EOL> version . channel . name , <EOL> version . platform . name , <EOL> version . version , <EOL> version . file . name , <EOL> ) ) <EOL> @ temporary_media_root ( ) <EOL> def test_factory ( self ) : <EOL> version = VersionFactory . create ( file = SimpleUploadedFile ( '<STR_LIT>' , False ) ) <EOL> self . assertTrue ( Version . objects . get ( id = version . id ) ) <EOL> @ temporary_media_root ( MEDIA_URL = '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , lambda o , f : f ) <EOL> def test_property ( self ) : <EOL> version = VersionFactory . create ( file = SimpleUploadedFile ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( version . file_absolute_url , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( version . file_package_name , '<STR_LIT>' ) <EOL> self . assertEqual ( version . file_url , <EOL> u'<STR_LIT>' ) <EOL> @ temporary_media_root ( ) <EOL> @ test . override_settings ( OMAHA_URL_PREFIX = '<STR_LIT>' ) <EOL> def test_property_default_storage ( self ) : <EOL> version = VersionFactory . create ( file = SimpleUploadedFile ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> _url = '<STR_LIT>' % ( version . app . name , version . channel . name , version . platform . name ) <EOL> self . assertEqual ( version . file_absolute_url , _url ) <EOL> self . assertEqual ( version . file_package_name , '<STR_LIT>' ) <EOL> _url = u'<STR_LIT>' % ( version . app . name , version . channel . name , version . platform . name ) <EOL> self . assertEqual ( version . file_url , _url ) <EOL> @ temporary_media_root ( MEDIA_URL = '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , lambda o , f : f ) <EOL> def test_property_s3_meta_data ( self ) : <EOL> version = VersionFactory . create ( file = SimpleUploadedFile ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEqual ( version . file_package_name , '<STR_LIT>' ) <EOL> self . assertEqual ( version . file_url , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( version . size , <NUM_LIT> ) <EOL> @ temporary_media_root ( ) <EOL> def test_pre_save_callbac ( self ) : <EOL> version = VersionFactory . create ( file = SimpleUploadedFile ( '<STR_LIT>' , b'<STR_LIT>' ) ) <EOL> self . assertEqual ( version . file . size , <NUM_LIT:0> ) <EOL> self . assertEqual ( version . file_hash , '<STR_LIT>' ) <EOL> class ActionModelTest ( test . TestCase ) : <EOL> @ temporary_media_root ( ) <EOL> def test_get_attributes ( self ) : <EOL> ver = VersionFactory . create ( file = SimpleUploadedFile ( '<STR_LIT>' , False ) ) <EOL> action = Action ( <EOL> version = ver , <EOL> arguments = '<STR_LIT>' , <EOL> event = EVENT_DICT_CHOICES [ '<STR_LIT>' ] , <EOL> run = '<STR_LIT>' <EOL> ) <EOL> self . assertDictEqual ( <EOL> action . get_attributes ( ) , <EOL> dict ( <EOL> arguments = '<STR_LIT>' , <EOL> run = '<STR_LIT>' , <EOL> ) ) <EOL> action = Action ( <EOL> version = ver , <EOL> terminateallbrowsers = True , <EOL> event = EVENT_DICT_CHOICES [ '<STR_LIT>' ] , <EOL> other = dict ( <EOL> version = '<STR_LIT>' , <EOL> onsuccess = '<STR_LIT>' ) <EOL> ) <EOL> self . assertDictEqual ( <EOL> action . get_attributes ( ) , <EOL> dict ( <EOL> terminateallbrowsers = '<STR_LIT:true>' , <EOL> version = '<STR_LIT>' , <EOL> onsuccess = '<STR_LIT>' , <EOL> ) <EOL> ) </s>
