def testBranchXorPull(self):
     """Either branch or pull specified, not both."""
     with Stub(bootstrap, 'call', Bomb), Stub(os, 'chdir', Bomb):
         with self.assertRaises(ValueError):
           bootstrap.checkout(REPO, None, None)
         with self.assertRaises(ValueError):
           bootstrap.checkout(REPO, BRANCH, PULL)
Esempio n. 2
0
 def testBranchXorPull(self):
     """Either branch or pull specified, not both."""
     with Stub(bootstrap, 'call', Bomb), Stub(os, 'chdir', Bomb):
         with self.assertRaises(ValueError):
             bootstrap.checkout(REPO, None, None)
         with self.assertRaises(ValueError):
             bootstrap.checkout(REPO, BRANCH, PULL)
Esempio n. 3
0
    def testRepo(self):
        """checkout initializes and fetches the right repo."""
        with Stub(bootstrap, 'call', FakeSubprocess()) as fake:
            with Stub(os, 'chdir', Pass):
                bootstrap.checkout(REPO, BRANCH, None)

        expected_uri = 'https://%s' % REPO
        self.assertTrue(any(
            expected_uri in cmd for cmd, _, _ in fake.calls if 'fetch' in cmd))
Esempio n. 4
0
    def testBranch(self):
        """checkout fetches the right ref for a branch."""
        with Stub(bootstrap, 'call', FakeSubprocess()) as fake:
            with Stub(os, 'chdir', Pass):
                bootstrap.checkout(REPO, BRANCH, None)

        expected_ref = BRANCH
        self.assertTrue(any(
            expected_ref in cmd for cmd, _, _ in fake.calls if 'fetch' in cmd))
Esempio n. 5
0
    def testPull(self):
        """checkout fetches the right ref for a pull."""
        with Stub(bootstrap, 'call', FakeSubprocess()) as fake:
            with Stub(os, 'chdir', Pass):
                bootstrap.checkout(REPO, None, PULL)

        expected_ref = bootstrap.pull_ref(PULL)[0][0]
        self.assertTrue(any(
            expected_ref in cmd for cmd, _, _ in fake.calls if 'fetch' in cmd))
Esempio n. 6
0
    def testHappy(self):
        """checkout sanity check."""
        with Stub(bootstrap, 'call', FakeSubprocess()) as fake:
            with Stub(os, 'chdir', Pass):
                bootstrap.checkout(REPO, BRANCH, None)

        self.assertTrue(
            any('--tags' in cmd for cmd, _, _ in fake.calls if 'fetch' in cmd))
        self.assertTrue(
            any('FETCH_HEAD' in cmd for cmd, _, _ in fake.calls
                if 'checkout' in cmd))
    def testHappy(self):
        """checkout sanity check."""
        with Stub(bootstrap, 'call', FakeSubprocess()) as fake:
            with Stub(os, 'chdir', Pass):
                bootstrap.checkout(REPO, BRANCH, None)

        self.assertTrue(any(
            '--tags' in cmd for cmd, _, _ in fake.calls if 'fetch' in cmd))
        self.assertTrue(any(
            'FETCH_HEAD' in cmd for cmd, _, _ in fake.calls
            if 'checkout' in cmd))
Esempio n. 8
0
 def testFetchRetries(self):
     self.tries = 0
     expected_attempts = 3
     def ThirdTimeCharm(cmd, *a, **kw):
         if 'fetch' not in cmd:  # init/checkout are unlikely to fail
             return
         self.tries += 1
         if self.tries != expected_attempts:
             raise subprocess.CalledProcessError(128, cmd, None)
     with Stub(bootstrap, 'call', ThirdTimeCharm):
         with Stub(os, 'chdir', Pass):
             with Stub(time, 'sleep', Pass):
                 bootstrap.checkout(REPO, None, PULL)
     self.assertEquals(expected_attempts, self.tries)