<s> import unittest <EOL> import os , time <EOL> from nodemcu_uploader import Uploader <EOL> from serial import VERSION as serialversion <EOL> from distutils . version import LooseVersion <EOL> LOOPPORT = '<STR_LIT>' <EOL> SERIALPORT = os . environ . get ( '<STR_LIT>' , LOOPPORT ) <EOL> def is_real ( ) : <EOL> if SERIALPORT . strip ( ) == '<STR_LIT>' : <EOL> return False <EOL> return str ( SERIALPORT ) != str ( LOOPPORT ) <EOL> @ unittest . skipUnless ( LooseVersion ( serialversion ) >= LooseVersion ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> class UploaderFakeTestCase ( unittest . TestCase ) : <EOL> def test_init ( self ) : <EOL> uploader = Uploader ( SERIALPORT ) <EOL> uploader . close ( ) <EOL> @ unittest . skipUnless ( is_real ( ) , '<STR_LIT>' ) <EOL> class UploaderTestCase ( unittest . TestCase ) : <EOL> uploader = None <EOL> def setUp ( self ) : <EOL> self . uploader = Uploader ( SERIALPORT ) <EOL> def tearDown ( self ) : <EOL> if is_real ( ) : <EOL> self . uploader . node_restart ( ) <EOL> self . uploader . close ( ) <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> def test_upload_and_verify_raw ( self ) : <EOL> self . uploader . prepare ( ) <EOL> self . uploader . write_file ( '<STR_LIT>' , verify = '<STR_LIT>' ) <EOL> def test_upload_and_verify_sha1 ( self ) : <EOL> self . uploader . prepare ( ) <EOL> self . uploader . write_file ( '<STR_LIT>' , verify = '<STR_LIT>' ) <EOL> def test_upload_strange_file ( self ) : <EOL> self . uploader . prepare ( ) <EOL> self . uploader . write_file ( '<STR_LIT>' , verify = '<STR_LIT>' ) <EOL> def test_file_list ( self ) : <EOL> lst = self . uploader . file_list ( ) <EOL> self . assertIsInstance ( lst , type ( [ ] ) ) <EOL> self . assertGreaterEqual ( len ( lst ) , <NUM_LIT:1> ) <EOL> self . assertLess ( len ( lst ) , <NUM_LIT:50> ) <EOL> def test_node_heap ( self ) : <EOL> size = self . uploader . node_heap ( ) <EOL> self . assertGreater ( size , <NUM_LIT> ) <EOL> self . assertLess ( size , <NUM_LIT> ) </s>
