<s> import unittest <EOL> from collections import namedtuple <EOL> import os <EOL> import os . path <EOL> from pwman import set_xsel <EOL> from pwman . data import factory <EOL> from pwman . data . database import __DB_FORMAT__ <EOL> from pwman import ( get_conf , get_conf_options , get_db_version ) <EOL> from . test_tools import SetupTester <EOL> dummyfile = """<STR_LIT>""" <EOL> testdb = os . path . abspath ( os . path . join ( os . path . dirname ( __file__ ) , <EOL> "<STR_LIT>" ) ) <EOL> class TestFactory ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> SetupTester ( ) . clean ( ) <EOL> class TestInit ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as d : <EOL> d . write ( dummyfile ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> for item in ( '<STR_LIT>' , testdb ) : <EOL> try : <EOL> os . unlink ( item ) <EOL> except OSError : <EOL> continue <EOL> def setUp ( self ) : <EOL> "<STR_LIT>" <EOL> self . dbtype = '<STR_LIT>' <EOL> self . db = factory . createdb ( '<STR_LIT>' + os . path . abspath ( testdb ) , <EOL> __DB_FORMAT__ ) <EOL> self . tester = SetupTester ( __DB_FORMAT__ , dburi = testdb ) <EOL> self . tester . create ( ) <EOL> def test_get_db_version ( self ) : <EOL> v = get_db_version ( self . tester . configp , '<STR_LIT>' ) <EOL> self . assertEqual ( v , u"<STR_LIT>" ) <EOL> v = get_db_version ( self . tester . configp , '<STR_LIT>' ) <EOL> self . assertEqual ( v , u"<STR_LIT>" ) <EOL> os . unlink ( testdb ) <EOL> def test_set_xsel ( self ) : <EOL> Args = namedtuple ( '<STR_LIT:args>' , '<STR_LIT>' ) <EOL> args = Args ( cfile = '<STR_LIT>' , dbase = '<STR_LIT>' , algo = '<STR_LIT>' ) <EOL> xsel , dbtype , configp = get_conf_options ( args , '<STR_LIT:True>' ) <EOL> set_xsel ( configp , False ) <EOL> set_xsel ( configp , True ) <EOL> def test_get_conf_file ( self ) : <EOL> Args = namedtuple ( '<STR_LIT:args>' , '<STR_LIT>' ) <EOL> args = Args ( cfile = '<STR_LIT>' ) <EOL> get_conf ( args ) <EOL> def test_get_conf_options ( self ) : <EOL> Args = namedtuple ( '<STR_LIT:args>' , '<STR_LIT>' ) <EOL> args = Args ( cfile = '<STR_LIT>' , dbase = '<STR_LIT>' , algo = '<STR_LIT>' ) <EOL> xsel , dburi , configp = get_conf_options ( args , '<STR_LIT:True>' ) <EOL> self . assertEqual ( dburi , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> try : <EOL> unittest . main ( verbosity = <NUM_LIT:2> , failfast = True ) <EOL> except SystemExit : <EOL> if os . path . exists ( testdb ) : <EOL> os . remove ( testdb ) </s>
