def test_ssh_get(self, run_cmd): ssh_get('user@remote', 'foo/bar*', 'mydestdir') run_cmd.assert_called_with(['scp', '-q', '-oStrictHostKeyChecking=no', '-oUserKnownHostsFile=/dev/null', 'user@remote:foo/bar*', '.'], cwd='mydestdir')
def test_ssh_run_cmd_with_remote_cwd(self, run_cmd): ssh_run_cmd('user@remote', ['touch', '"#'], remote_cwd='workspace') run_cmd.assert_called_with(['ssh', '-q', '-oStrictHostKeyChecking=no', '-oUserKnownHostsFile=/dev/null', 'user@remote', 'mkdir -p workspace ; cd workspace ; touch \'"#\''])
def test_ssh_run_cmd(self, run_cmd): ssh_run_cmd('user@remote', ['touch', '"#']) run_cmd.assert_called_with(['ssh', '-q', '-oStrictHostKeyChecking=no', '-oUserKnownHostsFile=/dev/null', 'user@remote', 'touch \'"#\''])
def test_poll_changes(self, run_cmd): run_cmd.return_value = b'cdf46dc0-a49c-11e5-b00a-c712eaff3d7c refs/heads/master\n' ps = PackageSource.objects.get(id=1) self.assertTrue(ps.poll()) run_cmd.assert_called_with([ 'git', 'ls-remote', 'https://github.com/eric/project0', 'refs/heads/master' ])
def test_poll_fails(self, run_cmd): run_cmd.side_effect = CommandFailed("['git', 'ls-remote', u'https://github.com/eric/project0', u'refs/heads/master'] " "returned 128. Output: fatal: could not read Username for 'https://github.com': " "No such device or address\n", ['git', 'ls-remote', u'https://github.com/eric/project0', u'refs/heads/master'], 128, "fatal: could not read Username for 'https://github.com': No such device or address\n") ps = PackageSource.objects.get(id=1) self.assertFalse(ps.poll()) run_cmd.assert_called_with(['git', 'ls-remote', 'https://github.com/eric/project0', 'refs/heads/master']) self.assertTrue(ps.disabled) self.assertTrue(ps.last_failure_time) self.assertEquals(ps.last_failure, "fatal: could not read Username for 'https://github.com': No such device or address\n")
def test_poll_fails(self, run_cmd): run_cmd.side_effect = CommandFailed( "['git', 'ls-remote', u'https://github.com/eric/project0', u'refs/heads/master'] " "returned 128. Output: fatal: could not read Username for 'https://github.com': " "No such device or address\n", [ 'git', 'ls-remote', u'https://github.com/eric/project0', u'refs/heads/master' ], 128, "fatal: could not read Username for 'https://github.com': No such device or address\n" ) ps = PackageSource.objects.get(id=1) self.assertFalse(ps.poll()) run_cmd.assert_called_with([ 'git', 'ls-remote', 'https://github.com/eric/project0', 'refs/heads/master' ]) self.assertTrue(ps.disabled) self.assertTrue(ps.last_failure_time) self.assertEquals( ps.last_failure, "fatal: could not read Username for 'https://github.com': No such device or address\n" )
def test_poll_changes(self, run_cmd): run_cmd.return_value = b'cdf46dc0-a49c-11e5-b00a-c712eaff3d7c refs/heads/master\n' ps = PackageSource.objects.get(id=1) self.assertTrue(ps.poll()) run_cmd.assert_called_with(['git', 'ls-remote', 'https://github.com/eric/project0', 'refs/heads/master'])