<s> import os <EOL> import unittest <EOL> from zipfile import ZipFile <EOL> from gooddataclient . connection import Connection <EOL> from gooddataclient . exceptions import AuthenticationError <EOL> from gooddataclient . archiver import write_tmp_file <EOL> from tests . credentials import username , password <EOL> from tests import logger , examples <EOL> class TestConnection ( unittest . TestCase ) : <EOL> def test_login ( self ) : <EOL> if username == '<STR_LIT>' or password == '<STR_LIT>' : <EOL> raise AttributeError , '<STR_LIT>' <EOL> self . assertRaises ( AuthenticationError , Connection , '<STR_LIT>' , '<STR_LIT>' ) <EOL> connection = Connection ( username , password ) <EOL> self . assertEquals ( '<STR_LIT>' , connection . request ( '<STR_LIT>' ) . read ( ) ) <EOL> self . assert_ ( connection . webdav . request ( '<STR_LIT>' ) ) <EOL> for dir_name in ( ) : <EOL> connection . webdav . delete ( dir_name ) <EOL> def test_upload ( self ) : <EOL> example = examples . examples [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> connection = Connection ( username , password , debug = <NUM_LIT:0> ) <EOL> dir_name = connection . webdav . upload ( example . data_csv , example . sli_manifest ) <EOL> self . assert_ ( len ( dir_name ) > <NUM_LIT:0> ) <EOL> self . assert_ ( connection . webdav . request ( '<STR_LIT>' % dir_name ) ) <EOL> uploaded_file = connection . webdav . request ( '<STR_LIT>' % dir_name ) <EOL> tmp_file = write_tmp_file ( uploaded_file . read ( ) ) <EOL> zip_file = ZipFile ( tmp_file , "<STR_LIT:r>" ) <EOL> self . assertEquals ( None , zip_file . testzip ( ) ) <EOL> self . assertEquals ( zip_file . namelist ( ) , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> zip_file . close ( ) <EOL> os . remove ( tmp_file ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
