<s> import unittest <EOL> from . . test import TestCase <EOL> class TestPlatform ( TestCase ) : <EOL> def test_key ( self ) : <EOL> sdk = self . get_sdk ( ) <EOL> self . assertEqual ( '<STR_LIT>' , sdk . platform ( ) . _api_key ( ) ) <EOL> def test_login ( self ) : <EOL> sdk = self . get_sdk ( ) <EOL> self . assertTrue ( sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> def test_refresh_with_outdated_token ( self ) : <EOL> sdk = self . get_sdk ( ) <EOL> sdk . mock_registry ( ) . refresh_mock ( ) <EOL> sdk . platform ( ) . auth ( ) . set_data ( { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:1> <EOL> } ) <EOL> self . assertEqual ( <NUM_LIT:1> , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> caught = False <EOL> try : <EOL> sdk . platform ( ) . refresh ( ) <EOL> except Exception as e : <EOL> caught = True <EOL> self . assertEqual ( '<STR_LIT>' , e . message ) <EOL> self . assertTrue ( caught ) <EOL> def test_manual_refresh ( self ) : <EOL> sdk = self . get_sdk ( ) <EOL> sdk . mock_registry ( ) . refresh_mock ( ) . generic_mock ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) <EOL> self . assertEqual ( '<STR_LIT>' , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> sdk . platform ( ) . refresh ( ) <EOL> self . assertEqual ( '<STR_LIT>' , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> def test_automatic_refresh ( self ) : <EOL> sdk = self . get_sdk ( ) <EOL> sdk . mock_registry ( ) . refresh_mock ( ) . generic_mock ( '<STR_LIT:GET>' , '<STR_LIT>' , { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) <EOL> self . assertEqual ( '<STR_LIT>' , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> sdk . platform ( ) . auth ( ) . set_data ( { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:1> <EOL> } ) <EOL> self . assertEqual ( <NUM_LIT:1> , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT:bar>' , sdk . platform ( ) . get ( '<STR_LIT>' ) . json ( ) . foo ) <EOL> self . assertEqual ( '<STR_LIT>' , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> def test_logout ( self ) : <EOL> sdk = self . get_sdk ( ) <EOL> sdk . mock_registry ( ) . logout_mock ( ) <EOL> self . assertEqual ( '<STR_LIT>' , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> sdk . platform ( ) . logout ( ) <EOL> self . assertEqual ( '<STR_LIT>' , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , sdk . platform ( ) . auth ( ) . data ( ) [ '<STR_LIT>' ] ) <EOL> def test_api_url ( self ) : <EOL> sdk = self . get_sdk ( ) <EOL> exp1 = '<STR_LIT>' <EOL> act1 = sdk . platform ( ) . create_url ( '<STR_LIT>' , add_server = True , add_method = '<STR_LIT:POST>' , add_token = True ) <EOL> self . assertEqual ( exp1 , act1 ) <EOL> exp2 = '<STR_LIT>' <EOL> url2 = '<STR_LIT>' <EOL> act2 = sdk . platform ( ) . create_url ( url2 , add_server = True , add_method = '<STR_LIT:POST>' , add_token = True ) <EOL> self . assertEqual ( exp2 , act2 ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
