<s> from io import StringIO <EOL> import pytest <EOL> from doit . cmd_resetdep import ResetDep <EOL> from doit . dependency import TimestampChecker , get_md5 , get_file_md5 <EOL> from doit . exceptions import InvalidCommand <EOL> from doit . task import Task <EOL> from tests . conftest import tasks_sample , CmdFactory , get_abspath <EOL> class TestCmdResetDep ( object ) : <EOL> def test_execute ( self , depfile , dependency1 ) : <EOL> output = StringIO ( ) <EOL> tasks = tasks_sample ( ) <EOL> cmd_reset = CmdFactory ( ResetDep , outstream = output , task_list = tasks , <EOL> dep_manager = depfile ) <EOL> cmd_reset . _execute ( ) <EOL> got = [ line . strip ( ) for line in output . getvalue ( ) . split ( '<STR_LIT:\n>' ) if line ] <EOL> expected = [ "<STR_LIT>" % t . name for t in tasks ] <EOL> assert sorted ( expected ) == sorted ( got ) <EOL> def test_file_dep ( self , depfile , dependency1 ) : <EOL> my_task = Task ( "<STR_LIT>" , [ "<STR_LIT>" ] , file_dep = [ '<STR_LIT>' ] ) <EOL> output = StringIO ( ) <EOL> cmd_reset = CmdFactory ( ResetDep , outstream = output , task_list = [ my_task ] , <EOL> dep_manager = depfile ) <EOL> cmd_reset . _execute ( ) <EOL> got = output . getvalue ( ) <EOL> assert "<STR_LIT>" == got <EOL> dep = list ( my_task . file_dep ) [ <NUM_LIT:0> ] <EOL> timestamp , size , md5 = depfile . _get ( my_task . name , dep ) <EOL> assert get_file_md5 ( get_abspath ( "<STR_LIT>" ) ) == md5 <EOL> def test_file_dep_up_to_date ( self , depfile , dependency1 ) : <EOL> my_task = Task ( "<STR_LIT>" , [ "<STR_LIT>" ] , file_dep = [ '<STR_LIT>' ] ) <EOL> depfile . save_success ( my_task ) <EOL> output = StringIO ( ) <EOL> cmd_reset = CmdFactory ( ResetDep , outstream = output , task_list = [ my_task ] , <EOL> dep_manager = depfile ) <EOL> cmd_reset . _execute ( ) <EOL> got = output . getvalue ( ) <EOL> assert "<STR_LIT>" == got <EOL> def test_file_dep_change_checker ( self , depfile , dependency1 ) : <EOL> my_task = Task ( "<STR_LIT>" , [ "<STR_LIT>" ] , file_dep = [ '<STR_LIT>' ] ) <EOL> depfile . save_success ( my_task ) <EOL> depfile . checker = TimestampChecker ( ) <EOL> output = StringIO ( ) <EOL> cmd_reset = CmdFactory ( ResetDep , outstream = output , task_list = [ my_task ] , <EOL> dep_manager = depfile ) <EOL> cmd_reset . _execute ( ) <EOL> got = output . getvalue ( ) <EOL> assert "<STR_LIT>" == got <EOL> def test_filter ( self , depfile , dependency1 ) : <EOL> output = StringIO ( ) <EOL> tasks = tasks_sample ( ) <EOL> cmd_reset = CmdFactory ( ResetDep , outstream = output , task_list = tasks , <EOL> dep_manager = depfile ) <EOL> cmd_reset . _execute ( pos_args = [ '<STR_LIT>' ] ) <EOL> got = output . getvalue ( ) <EOL> assert "<STR_LIT>" == got <EOL> def test_invalid_task ( self , depfile ) : <EOL> output = StringIO ( ) <EOL> tasks = tasks_sample ( ) <EOL> cmd_reset = CmdFactory ( ResetDep , outstream = output , task_list = tasks , <EOL> dep_manager = depfile ) <EOL> pytest . raises ( InvalidCommand , cmd_reset . _execute , pos_args = [ '<STR_LIT>' ] ) <EOL> def test_missing_file_dep ( self , depfile ) : <EOL> my_task = Task ( "<STR_LIT>" , [ "<STR_LIT>" ] , file_dep = [ '<STR_LIT>' ] ) <EOL> output = StringIO ( ) <EOL> cmd_reset = CmdFactory ( ResetDep , outstream = output , task_list = [ my_task ] , <EOL> dep_manager = depfile ) <EOL> cmd_reset . _execute ( ) <EOL> got = output . getvalue ( ) <EOL> assert ( "<STR_LIT>" <EOL> "<STR_LIT>" ) == got <EOL> def test_values_and_results ( self , depfile , dependency1 ) : <EOL> my_task = Task ( "<STR_LIT>" , [ "<STR_LIT>" ] , file_dep = [ '<STR_LIT>' ] ) <EOL> my_task . result = "<STR_LIT:result>" <EOL> my_task . values = { '<STR_LIT:x>' : <NUM_LIT:5> , '<STR_LIT:y>' : <NUM_LIT:10> } <EOL> depfile . save_success ( my_task ) <EOL> depfile . checker = TimestampChecker ( ) <EOL> reseted = Task ( "<STR_LIT>" , [ "<STR_LIT>" ] , file_dep = [ '<STR_LIT>' ] ) <EOL> output = StringIO ( ) <EOL> cmd_reset = CmdFactory ( ResetDep , outstream = output , task_list = [ reseted ] , <EOL> dep_manager = depfile ) <EOL> cmd_reset . _execute ( ) <EOL> got = output . getvalue ( ) <EOL> assert "<STR_LIT>" == got <EOL> assert { '<STR_LIT:x>' : <NUM_LIT:5> , '<STR_LIT:y>' : <NUM_LIT:10> } == depfile . get_values ( reseted . name ) <EOL> assert get_md5 ( '<STR_LIT:result>' ) == depfile . get_result ( reseted . name ) </s>
