<s> from __future__ import absolute_import <EOL> import mock <EOL> from changes . config import db <EOL> from changes . jobs . update_local_repos import update_local_repos <EOL> from changes . models import RepositoryBackend , RepositoryStatus <EOL> from changes . testutils import TestCase <EOL> from changes . vcs . base import CommandError , Vcs <EOL> class UpdateLocalReposTest ( TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_simple ( self , get_vcs_backend ) : <EOL> vcs_backend = mock . MagicMock ( spec = Vcs ) <EOL> get_vcs_backend . return_value = vcs_backend <EOL> vcs_backend . update = mock . Mock ( ) <EOL> num_active_repos = <NUM_LIT:2> <EOL> for i in range ( num_active_repos ) : <EOL> self . create_repo ( backend = RepositoryBackend . git ) <EOL> inactive_repo = self . create_repo ( backend = RepositoryBackend . git ) <EOL> inactive_repo . status = RepositoryStatus . inactive <EOL> unknown_backend_repo = self . create_repo ( backend = RepositoryBackend . unknown ) <EOL> unknown_backend_repo . get_vcs = lambda : None <EOL> db . session . commit ( ) <EOL> update_local_repos ( ) <EOL> assert vcs_backend . update . call_count == num_active_repos <EOL> vcs_backend = mock . MagicMock ( spec = Vcs ) <EOL> get_vcs_backend . return_value = vcs_backend <EOL> vcs_backend . update = mock . Mock ( side_effect = CommandError ( '<STR_LIT>' , <NUM_LIT:1> ) ) <EOL> update_local_repos ( ) <EOL> assert vcs_backend . update . call_count == num_active_repos </s>
