<s> from datetime import datetime <EOL> from mock import MagicMock , call <EOL> from pygit2 import GIT_SORT_TIME <EOL> from gitfs . cache . commits import Commit , CommitCache <EOL> class TestCommit ( object ) : <EOL> def test_commit ( self ) : <EOL> commit = Commit ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> new_commit = Commit ( <NUM_LIT:2> , <NUM_LIT:2> , "<STR_LIT>" ) <EOL> assert new_commit > commit <EOL> assert repr ( new_commit ) == "<STR_LIT>" <EOL> class TestCommitCache ( object ) : <EOL> def test_cache ( self ) : <EOL> mocked_repo = MagicMock ( ) <EOL> mocked_commit = MagicMock ( ) <EOL> mocked_repo . lookup_reference ( ) . resolve ( ) . target = "<STR_LIT>" <EOL> mocked_repo . walk . return_value = [ mocked_commit ] <EOL> mocked_commit . commit_time = <NUM_LIT> <EOL> mocked_commit . hex = '<STR_LIT>' <EOL> cache = CommitCache ( mocked_repo ) <EOL> cache . update ( ) <EOL> cache [ '<STR_LIT>' ] = Commit ( <NUM_LIT:1> , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> assert sorted ( cache . keys ( ) ) == [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> asserted_time = datetime . fromtimestamp ( mocked_commit . commit_time ) <EOL> asserted_time = "<STR_LIT>" . format ( asserted_time . hour , asserted_time . minute , <EOL> asserted_time . second ) <EOL> assert repr ( cache [ '<STR_LIT>' ] ) == '<STR_LIT>' % asserted_time <EOL> del cache [ '<STR_LIT>' ] <EOL> for commit_date in cache : <EOL> assert commit_date == '<STR_LIT>' <EOL> mocked_repo . lookup_reference . has_calls ( [ call ( "<STR_LIT>" ) ] ) <EOL> mocked_repo . walk . assert_called_once_with ( "<STR_LIT>" , GIT_SORT_TIME ) <EOL> assert mocked_repo . lookup_reference ( ) . resolve . call_count == <NUM_LIT:2> </s>
