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())
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())
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())
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())
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"), )
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())
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")))
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')))
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')))
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")))
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'))
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'))
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)
def test_contains(self): refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED)) self.assertIn(b"refs/heads/master", refs) self.assertNotIn(b"refs/heads/bar", refs)