def test_get_authors_works_with_good_url(mock_run): mock_run.return_value = (0, "it worked") expected = mock_run.return_value assert expected == remote_git.get_authors("[email protected]:yelp-main", "a", "b") mock_run.assert_called_once_with( command="ssh [email protected] authors-of-changeset yelp-main a b", timeout=5.0, )
def get_authors_to_be_notified(self): ret, authors = remote_git.get_authors( git_url=self.git_url, from_sha=self.old_commit, to_sha=self.commit, ) if ret == 0: if authors == "": return "" else: slacky_authors = ", ".join([f"<@{a}>" for a in authors.split()]) log.debug(f"Authors: {slacky_authors}") return f"Authors: {slacky_authors}" else: return f"(Could not get authors: {authors})"
def get_authors_to_be_notified(git_url, from_sha, to_sha): if from_sha is None: return "" ret, authors = remote_git.get_authors( git_url=git_url, from_sha=from_sha, to_sha=to_sha ) if ret == 0: if authors == "": return "" else: slacky_authors = ", ".join({f"<@{a}>" for a in authors.split()}) log.debug(f"Authors: {slacky_authors}") return f"^ {slacky_authors}" else: return f"(Could not get authors: {authors})"
def test_get_authors_fails_with_unknown(mock_run): url = "[email protected]:something.git" expected = 1, mock.ANY assert expected == remote_git.get_authors(url, "a", "b")
def test_get_authors_fails_with_bad_url(mock_run): expected = 1, mock.ANY assert expected == remote_git.get_authors("bad", "a", "b")