Exemplo n.º 1
0
 def test_invalid_refname(self):
     text = _TEST_REFS_SERIALIZED + b'00' * 20 + b'\trefs/stash\n'
     refs = InfoRefsContainer(BytesIO(text))
     expected_refs = dict(_TEST_REFS)
     del expected_refs[b'HEAD']
     expected_refs[b'refs/stash'] = b'00' * 20
     self.assertEqual(expected_refs, refs.as_dict())
Exemplo n.º 2
0
 def test_invalid_refname(self):
     text = _TEST_REFS_SERIALIZED + b"00" * 20 + b"\trefs/stash\n"
     refs = InfoRefsContainer(BytesIO(text))
     expected_refs = dict(_TEST_REFS)
     del expected_refs[b"HEAD"]
     expected_refs[b"refs/stash"] = b"00" * 20
     self.assertEqual(expected_refs, refs.as_dict())
Exemplo n.º 3
0
 def test_as_dict(self):
     refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
     # refs/heads/loop does not show up even if it exists
     expected_refs = dict(_TEST_REFS)
     del expected_refs[b'HEAD']
     del expected_refs[b'refs/heads/loop']
     self.assertEqual(expected_refs, refs.as_dict())
Exemplo n.º 4
0
 def test_as_dict(self):
     refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
     # refs/heads/loop does not show up even if it exists
     expected_refs = dict(_TEST_REFS)
     del expected_refs[b'HEAD']
     del expected_refs[b'refs/heads/loop']
     self.assertEqual(expected_refs, refs.as_dict())
Exemplo n.º 5
0
 def test_invalid_refname(self):
     text = _TEST_REFS_SERIALIZED + '00' * 20 + '\trefs/stash\n'
     refs = InfoRefsContainer(StringIO(text))
     expected_refs = dict(_TEST_REFS)
     del expected_refs['HEAD']
     expected_refs["refs/stash"] = "00" * 20
     self.assertEqual(expected_refs, refs.as_dict())
Exemplo n.º 6
0
 def test_get_peeled(self):
     refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
     # refs/heads/loop does not show up even if it exists
     self.assertEqual(
         _TEST_REFS[b"refs/heads/master"],
         refs.get_peeled(b"refs/heads/master"),
     )
Exemplo n.º 7
0
 def test_invalid_refname(self):
     text = _TEST_REFS_SERIALIZED + b'00' * 20 + b'\trefs/stash\n'
     refs = InfoRefsContainer(BytesIO(text))
     expected_refs = dict(_TEST_REFS)
     del expected_refs[b'HEAD']
     expected_refs[b'refs/stash'] = b'00' * 20
     self.assertEqual(expected_refs, refs.as_dict())
Exemplo n.º 8
0
 def test_invalid_refname(self):
     text = _TEST_REFS_SERIALIZED + b"00" * 20 + b"\trefs/stash\n"
     refs = InfoRefsContainer(BytesIO(text))
     expected_refs = dict(_TEST_REFS)
     del expected_refs[b"HEAD"]
     expected_refs[b"refs/stash"] = b"00" * 20
     del expected_refs[b"refs/heads/loop"]
     self.assertEqual(expected_refs, refs.as_dict())
Exemplo n.º 9
0
    def test_keys(self):
        refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
        actual_keys = set(refs.keys())
        self.assertEqual(set(refs.allkeys()), actual_keys)
        # ignore the symref loop if it exists
        actual_keys.discard(b"refs/heads/loop")
        expected_refs = dict(_TEST_REFS)
        del expected_refs[b"HEAD"]
        self.assertEqual(set(expected_refs.keys()), actual_keys)

        actual_keys = refs.keys(b"refs/heads")
        actual_keys.discard(b"loop")
        self.assertEqual([b"40-char-ref-aaaaaaaaaaaaaaaaaa", b"master", b"packed"], sorted(actual_keys))
        self.assertEqual([b"refs-0.1", b"refs-0.2"], sorted(refs.keys(b"refs/tags")))
Exemplo n.º 10
0
    def test_keys(self):
        refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
        actual_keys = set(refs.keys())
        self.assertEqual(set(refs.allkeys()), actual_keys)
        expected_refs = dict(_TEST_REFS)
        del expected_refs[b'HEAD']
        del expected_refs[b'refs/heads/loop']
        self.assertEqual(set(expected_refs.keys()), actual_keys)

        actual_keys = refs.keys(b'refs/heads')
        actual_keys.discard(b'loop')
        self.assertEqual(
            [b'40-char-ref-aaaaaaaaaaaaaaaaaa', b'master', b'packed'],
            sorted(actual_keys))
        self.assertEqual([b'refs-0.1', b'refs-0.2'],
                         sorted(refs.keys(b'refs/tags')))
Exemplo n.º 11
0
    def test_keys(self):
        refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
        actual_keys = set(refs.keys())
        self.assertEqual(set(refs.allkeys()), actual_keys)
        expected_refs = dict(_TEST_REFS)
        del expected_refs[b'HEAD']
        del expected_refs[b'refs/heads/loop']
        self.assertEqual(set(expected_refs.keys()), actual_keys)

        actual_keys = refs.keys(b'refs/heads')
        actual_keys.discard(b'loop')
        self.assertEqual(
            [b'40-char-ref-aaaaaaaaaaaaaaaaaa', b'master', b'packed'],
            sorted(actual_keys))
        self.assertEqual([b'refs-0.1', b'refs-0.2'],
                         sorted(refs.keys(b'refs/tags')))
Exemplo n.º 12
0
    def test_keys(self):
        refs = InfoRefsContainer(StringIO(_TEST_REFS_SERIALIZED))
        actual_keys = set(refs.keys())
        self.assertEqual(set(refs.allkeys()), actual_keys)
        # ignore the symref loop if it exists
        actual_keys.discard('refs/heads/loop')
        expected_refs = dict(_TEST_REFS)
        del expected_refs['HEAD']
        self.assertEqual(set(expected_refs.iterkeys()), actual_keys)

        actual_keys = refs.keys('refs/heads')
        actual_keys.discard('loop')
        self.assertEqual(
            ['40-char-ref-aaaaaaaaaaaaaaaaaa', 'master', 'packed'],
            sorted(actual_keys))
        self.assertEqual(['refs-0.1', 'refs-0.2'],
                         sorted(refs.keys('refs/tags')))
Exemplo n.º 13
0
    def test_keys(self):
        refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
        actual_keys = set(refs.keys())
        self.assertEqual(set(refs.allkeys()), actual_keys)
        expected_refs = dict(_TEST_REFS)
        del expected_refs[b"HEAD"]
        del expected_refs[b"refs/heads/loop"]
        self.assertEqual(set(expected_refs.keys()), actual_keys)

        actual_keys = refs.keys(b"refs/heads")
        actual_keys.discard(b"loop")
        self.assertEqual(
            [b"40-char-ref-aaaaaaaaaaaaaaaaaa", b"master", b"packed"],
            sorted(actual_keys),
        )
        self.assertEqual([b"refs-0.1", b"refs-0.2"],
                         sorted(refs.keys(b"refs/tags")))
Exemplo n.º 14
0
 def test_get_peeled(self):
     refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
     # refs/heads/loop does not show up even if it exists
     self.assertEqual(
         _TEST_REFS[b'refs/heads/master'],
         refs.get_peeled(b'refs/heads/master'))
Exemplo n.º 15
0
 def test_get_peeled(self):
     refs = InfoRefsContainer(StringIO(_TEST_REFS_SERIALIZED))
     # refs/heads/loop does not show up even if it exists
     self.assertEqual(
         _TEST_REFS['refs/heads/master'],
         refs.get_peeled('refs/heads/master'))
Exemplo n.º 16
0
 def test_contains(self):
     refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
     self.assertTrue(b'refs/heads/master' in refs)
     self.assertFalse(b'refs/heads/bar' in refs)
Exemplo n.º 17
0
 def test_contains(self):
     refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
     self.assertIn(b"refs/heads/master", refs)
     self.assertNotIn(b"refs/heads/bar", refs)