def test_parse_author_5(self): actual_author = converters.parse_author(b"<only>") self.assertEqual(actual_author, { "name": None, "email": b"only", "fullname": b"<only>" })
def test_parse_author_no_bracket(self): actual_author = converters.parse_author(b"someone") self.assertEqual(actual_author, { "name": None, "email": None, "fullname": b"someone" })
def from_bytes(data: bytes) -> "HgAuthor": """Convert bytes to an HgAuthor named tuple. Expected format: "name <email>" """ from swh.loader.mercurial.converters import parse_author result = parse_author(data) return HgAuthor(fullname=result["fullname"], name=result["name"], email=result["email"])
def test_parse_author_normal(self): actual_author = converters.parse_author(b"someone <awesome>") self.assertEqual( actual_author, { "name": b"someone", "email": b"awesome", "fullname": b"someone <awesome>" }, )
def test_parse_author_6(self): actual_author = converters.parse_author(b" <something>") self.assertEqual( actual_author, { "name": b" ", "email": b"something", "fullname": b" <something>" }, )
def test_parse_author_3(self): actual_author = converters.parse_author(b"something >wicked") self.assertEqual( actual_author, { "name": None, "email": None, "fullname": b"something >wicked" }, )
def test_parse_author_no_email(self): self.assertIsNone(converters.parse_author(None))