<s> import sys <EOL> if sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:7> ) : <EOL> import unittest2 as unittest <EOL> else : <EOL> import unittest <EOL> from authy import AuthyException <EOL> from authy . api . resources import User <EOL> from authy . api . resources import Users <EOL> class UsersTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . resource = Users ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> def test_create_valid_user ( self ) : <EOL> user = self . resource . create ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . assertIsInstance ( user , User ) <EOL> self . assertTrue ( user . ok ( ) ) <EOL> self . assertTrue ( '<STR_LIT:user>' in user . content ) <EOL> self . assertIsNotNone ( user . id ) <EOL> self . assertEqual ( user . errors ( ) , { } ) <EOL> def test_create_invalid_user ( self ) : <EOL> user = self . resource . create ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . assertFalse ( user . ok ( ) ) <EOL> self . assertIsInstance ( user , User ) <EOL> self . assertEqual ( user . errors ( ) [ '<STR_LIT:email>' ] , '<STR_LIT>' ) <EOL> self . assertIsNone ( user . id ) <EOL> def test_request_sms_token ( self ) : <EOL> user = self . resource . create ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> sms = self . resource . request_sms ( user . id ) <EOL> self . assertTrue ( sms . ok ( ) ) <EOL> self . assertTrue ( sms . content [ '<STR_LIT:success>' ] ) <EOL> self . assertEqual ( sms . errors ( ) , { } ) <EOL> self . assertEqual ( user . errors ( ) , { } ) <EOL> def test_sms_ignored ( self ) : <EOL> user = self . resource . create ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> sms = self . resource . request_sms ( user . id ) <EOL> self . assertTrue ( sms . ok ( ) ) <EOL> sms . content [ '<STR_LIT>' ] = '<STR_LIT:true>' <EOL> self . assertTrue ( sms . ignored ( ) ) <EOL> def test_get_user_status ( self ) : <EOL> user = self . resource . create ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> status = self . resource . status ( user . id ) <EOL> self . assertTrue ( status . ok ( ) , msg = "<STR_LIT>" . format ( status . errors ( ) ) ) <EOL> self . assertTrue ( status . content [ '<STR_LIT:success>' ] ) <EOL> self . assertEqual ( status . errors ( ) , { } ) <EOL> def test_delete_user ( self ) : <EOL> user = self . resource . create ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> user = self . resource . delete ( user . id ) <EOL> self . assertTrue ( user . ok ( ) ) <EOL> self . assertTrue ( user . content [ '<STR_LIT:success>' ] ) <EOL> self . assertEqual ( user . errors ( ) , { } ) </s>
