Пример #1
0
 def test_checkout(self):
     repo = Hg('https://bitbucket.org/olauzanne/pyquery',
               target=self.test_dir)
     repo.download()
     repo.tag = 'manipulating'
     with repo:
         assert repo.src_hash == '3c7ab75c2eea'
Пример #2
0
 def test_valid_uri(self):
     assert Hg.valid_uri(self.repo.uri)
     assert not Hg.valid_uri("www.google.com")
Пример #3
0
 def setup(self):
     self.test_dir = os.path.join(tc.CONF.path_to("source"), "hg")
     hg_url = os.path.join(tc.STAGING, "hg")
     self.repo = Hg(hg_url, target=self.test_dir, tag="0.2")
Пример #4
0
class TestHg(object):
    def setup(self):
        self.test_dir = os.path.join(tc.CONF.path_to("source"), "hg")
        hg_url = os.path.join(tc.STAGING, "hg")
        self.repo = Hg(hg_url, target=self.test_dir, tag="0.2")

    def teardown(self):
        tc.delete_it(self.test_dir)

    def test_hash(self):
        assert self.repo.src_hash == "a6ec48f03985"

    def test_download_with_tag(self):
        with self.repo:
            assert os.path.exists(os.path.join(self.repo.target, ".hg"))

    def test_download_with_branch(self):
        repo = Hg(self.repo.uri, target=self.test_dir)
        with repo:
            assert os.path.exists(os.path.join(repo.target, ".hg"))
            assert repo.on_branch
            assert repo.branch == "default"

    def test_ready(self):
        assert not self.repo.ready
        with self.repo:
            assert self.repo.ready

    def test_checkout(self):
        repo = Hg("https://bitbucket.org/olauzanne/pyquery", target=self.test_dir)
        repo.download()
        repo.tag = "manipulating"
        with repo:
            assert repo.src_hash == "3c7ab75c2eea"

    def test_reset(self):
        temp_file = os.path.join(self.repo.target, "tempf")
        with self.repo:
            assert not os.path.exists(temp_file)
            with open(temp_file, "wb") as fout:
                fout.write("hello".encode())
        assert not os.path.exists(temp_file)

    def test_update(self):
        def get_hash(target):
            """
            Required because with now forces right commit
            """
            cmd = Command("hg identify", target)
            cmd.wait()
            return cmd.output()[0].split()[0]

        self.repo.branch = "default"
        with self.repo:
            # Lop off history to ensure updateable
            latest_hash = self.repo.src_hash
            cmd = Command("hg strip tip", self.repo.target)
            cmd.wait()
            assert get_hash(self.repo.target) != latest_hash
            self.repo.update()
            assert get_hash(self.repo.target) == latest_hash

    def test_valid_uri(self):
        assert Hg.valid_uri(self.repo.uri)
        assert not Hg.valid_uri("www.google.com")
Пример #5
0
 def setup(self):
     self.test_dir = os.path.join(tc.CONF.path_to('source'), 'hg')
     hg_url = os.path.join(tc.STAGING, 'hg')
     self.repo = Hg(hg_url, target=self.test_dir, tag='0.2')
Пример #6
0
class TestHg(object):
    def setup(self):
        self.test_dir = os.path.join(tc.CONF.path_to('source'), 'hg')
        hg_url = os.path.join(tc.STAGING, 'hg')
        self.repo = Hg(hg_url, target=self.test_dir, tag='0.2')

    def teardown(self):
        tc.delete_it(self.test_dir)

    def test_hash(self):
        assert self.repo.src_hash == 'a6ec48f03985'

    def test_download_with_tag(self):
        with self.repo:
            assert os.path.exists(os.path.join(self.repo.target, '.hg'))

    def test_download_with_branch(self):
        repo = Hg(self.repo.uri, target=self.test_dir)
        with repo:
            assert os.path.exists(os.path.join(repo.target, '.hg'))
            assert repo.on_branch
            assert repo.branch == 'default'

    def test_ready(self):
        assert not self.repo.ready
        with self.repo:
            assert self.repo.ready

    def test_checkout(self):
        repo = Hg('https://bitbucket.org/olauzanne/pyquery',
                  target=self.test_dir)
        repo.download()
        repo.tag = 'manipulating'
        with repo:
            assert repo.src_hash == '3c7ab75c2eea'

    def test_reset(self):
        temp_file = os.path.join(self.repo.target, 'tempf')
        with self.repo:
            assert not os.path.exists(temp_file)
            with open(temp_file, 'wb') as fout:
                fout.write('hello'.encode())
        assert not os.path.exists(temp_file)

    def test_update(self):
        def get_hash(target):
            """
            Required because with now forces right commit
            """
            cmd = Command('hg identify', target)
            cmd.wait()
            return cmd.output()[0].split()[0]

        self.repo.branch = 'default'
        with self.repo:
            # Lop off history to ensure updateable
            latest_hash = self.repo.src_hash
            cmd = Command('hg strip tip', self.repo.target)
            cmd.wait()
            assert get_hash(self.repo.target) != latest_hash
            self.repo.update()
            assert get_hash(self.repo.target) == latest_hash

    def test_valid_uri(self):
        assert Hg.valid_uri(self.repo.uri)
        assert not Hg.valid_uri('www.google.com')