<s> import gitli <EOL> import unittest <EOL> import tempfile <EOL> import shutil <EOL> import os <EOL> from subprocess import call <EOL> from collections import namedtuple <EOL> def read_file ( file_type ) : <EOL> content = '<STR_LIT>' <EOL> with open ( os . path . join ( gitli . GITLIDIR , file_type ) ) as f : <EOL> content = f . read ( ) <EOL> return content <EOL> def read_lines ( file_type ) : <EOL> content = [ ] <EOL> with open ( os . path . join ( gitli . GITLIDIR , file_type ) ) as f : <EOL> content = f . readlines ( ) <EOL> return content <EOL> def exists ( file_type ) : <EOL> return os . path . exists ( os . path . join ( gitli . GITLIDIR , file_type ) ) <EOL> class TestGitli ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . tempdirpath = tempfile . mkdtemp ( ) <EOL> os . chdir ( self . tempdirpath ) <EOL> self . gitlipath = os . path . join ( self . tempdirpath , gitli . GITLIDIR ) <EOL> self . Options = namedtuple ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . bcolor = gitli . BColors ( ) <EOL> self . bcolor . disable ( ) <EOL> def tearDown ( self ) : <EOL> shutil . rmtree ( self . tempdirpath ) <EOL> def test_init ( self ) : <EOL> call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> gitli . main ( None , [ '<STR_LIT>' , ] , None ) <EOL> self . assertTrue ( exists ( gitli . ISSUES ) ) <EOL> self . assertTrue ( exists ( gitli . OPEN ) ) <EOL> self . assertTrue ( exists ( gitli . LAST ) ) <EOL> self . assertTrue ( exists ( gitli . CURRENT ) ) <EOL> self . assertTrue ( exists ( gitli . COMMENTS ) ) <EOL> self . assertEqual ( read_file ( gitli . CURRENT ) , '<STR_LIT>' ) <EOL> self . assertEqual ( read_file ( gitli . LAST ) , '<STR_LIT:0>' ) <EOL> def test_new ( self ) : <EOL> options = self . Options ( edit = False , up = False ) <EOL> call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> gitli . main ( None , [ '<STR_LIT>' , ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> lines = read_lines ( gitli . ISSUES ) <EOL> self . assertEqual ( '<STR_LIT:1>' , lines [ <NUM_LIT:0> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , lines [ <NUM_LIT:1> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT:1>' , lines [ <NUM_LIT:2> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , lines [ <NUM_LIT:3> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT:1>' , read_file ( gitli . LAST ) ) <EOL> lines = read_lines ( gitli . OPEN ) <EOL> self . assertEqual ( '<STR_LIT:1>' , lines [ <NUM_LIT:0> ] . strip ( ) ) <EOL> def test_remove ( self ) : <EOL> options = self . Options ( edit = False , up = False ) <EOL> call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> gitli . main ( None , [ '<STR_LIT>' , ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT:2>' ] , None ) <EOL> lines = read_lines ( gitli . ISSUES ) <EOL> self . assertEqual ( '<STR_LIT:1>' , lines [ <NUM_LIT:0> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT:3>' , lines [ <NUM_LIT:4> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT:3>' , read_file ( gitli . LAST ) ) <EOL> lines = read_lines ( gitli . OPEN ) <EOL> self . assertEqual ( '<STR_LIT:1>' , lines [ <NUM_LIT:0> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT:3>' , lines [ <NUM_LIT:1> ] . strip ( ) ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT:3>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT:1>' ] , None ) <EOL> self . assertEqual ( '<STR_LIT>' , read_file ( gitli . ISSUES ) . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT:3>' , read_file ( gitli . LAST ) . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , read_file ( gitli . OPEN ) . strip ( ) ) <EOL> def test_list_issues ( self ) : <EOL> options = self . Options ( edit = False , up = False ) <EOL> call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> gitli . main ( None , [ '<STR_LIT>' , ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT:2>' ] , None ) <EOL> issues = gitli . list_issues ( self . gitlipath , [ ] , self . bcolor ) <EOL> self . assertEqual ( <NUM_LIT:3> , len ( issues ) ) <EOL> issues = gitli . list_issues ( self . gitlipath , [ '<STR_LIT:all>' ] , self . bcolor ) <EOL> self . assertEqual ( <NUM_LIT:3> , len ( issues ) ) <EOL> issues = gitli . list_issues ( self . gitlipath , [ '<STR_LIT>' ] , self . bcolor ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( issues ) ) <EOL> issues = gitli . list_issues ( self . gitlipath , [ '<STR_LIT>' ] , self . bcolor ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( issues ) ) <EOL> def test_list_issues_default ( self ) : <EOL> options = self . Options ( edit = False , up = False ) <EOL> call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> gitli . main ( None , [ '<STR_LIT>' , ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT:2>' ] , None ) <EOL> issues = gitli . list_issues ( self . gitlipath , [ ] , self . bcolor ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( issues ) ) <EOL> issues = gitli . list_issues ( self . gitlipath , [ '<STR_LIT:all>' ] , self . bcolor ) <EOL> self . assertEqual ( <NUM_LIT:3> , len ( issues ) ) <EOL> issues = gitli . list_issues ( self . gitlipath , [ '<STR_LIT>' ] , self . bcolor ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( issues ) ) <EOL> issues = gitli . list_issues ( self . gitlipath , [ '<STR_LIT>' ] , self . bcolor ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( issues ) ) <EOL> def test_set_milestone ( self ) : <EOL> options = self . Options ( edit = False , up = False ) <EOL> call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> gitli . main ( None , [ '<STR_LIT>' , ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT:2>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> lines = read_lines ( gitli . ISSUES ) <EOL> self . assertEqual ( '<STR_LIT>' , lines [ <NUM_LIT:3> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , lines [ <NUM_LIT:7> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , lines [ <NUM_LIT:11> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , read_file ( gitli . CURRENT ) ) <EOL> def test_up ( self ) : <EOL> options = self . Options ( edit = False , up = True ) <EOL> call ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> call ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> gitli . main ( None , [ '<STR_LIT>' , ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT:2>' ] , None ) <EOL> gitli . main ( options , [ '<STR_LIT>' , '<STR_LIT>' ] , None ) <EOL> lines = read_lines ( gitli . ISSUES ) <EOL> self . assertEqual ( '<STR_LIT>' , lines [ <NUM_LIT:3> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , lines [ <NUM_LIT:7> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , lines [ <NUM_LIT:11> ] . strip ( ) ) <EOL> self . assertEqual ( '<STR_LIT>' , read_file ( gitli . CURRENT ) ) </s>
