How to use get_repo method in avocado

Best Python code snippet using avocado_python

tests.py

Source:tests.py Github

copy

Full Screen

...19 self.label.name = "Website"20 self.label1 = Mock()21 self.label1.color = "171717"22 self.label1.name = "API"23 self.gh().get_user().get_repo().get_labels.return_value = [self.label, self.label1]24 # set up mocked issue25 self.issue = Mock()26 self.issue.created_at = datetime.now()27 self.issue.state = "open"28 self.issue_label = Mock()29 self.issue_label.color = "FF4D4D"30 self.issue_label.name = "major outage"31 self.issue.get_labels.return_value = [self.issue_label, self.label]32 self.issue.user.login = "some-dude"33 self.comment = Mock()34 self.comment.user.login = "some-dude"35 self.issue.get_comments.return_value = [self.comment, ]36 self.issue1 = Mock()37 self.issue1.created_at = datetime.now()38 self.issue1.state = "open"39 self.issue1.user.login = "some-dude"40 self.issue1.get_labels.return_value = [self.issue_label, self.label1]41 self.issue1.get_comments.return_value = [self.comment, ]42 self.gh().get_user().get_repo().get_issues.return_value = [self.issue, self.issue1]43 self.template = Mock()44 self.template.decoded_content = b"some foo"45 self.template.content = codecs.encode(b"some other foo", "base64")46 self.gh().get_user().get_repo().get_contents.return_value = self.template47 self.gh().get_organization().get_repo().get_contents.return_value = self.template48 self.collaborator = Mock()49 self.collaborator.login = "some-dude"50 self.gh().get_user().get_repo().get_collaborators.return_value = [self.collaborator,]51 self.gh().get_organization().get_repo().get_collaborators.return_value = [self.collaborator,]52 def tearDown(self):53 self.patcher.stop()54 @patch("statuspage.run_update")55 def test_create(self, run_update):56 label = Mock()57 self.gh().get_user().create_repo().get_labels.return_value = [label,]58 runner = CliRunner()59 result = runner.invoke(60 create,61 ["--name", "testrepo", "--token", "token", "--systems", "sys1,sys2"]62 )63 self.assertEqual(result.exit_code, 0)64 self.gh.assert_called_with("token")65 @patch("statuspage.run_update")66 def test_create_org(self, run_update):67 runner = CliRunner()68 result = runner.invoke(69 create,70 ["--name", "testrepo",71 "--token", "token",72 "--systems", "sys1,sys2",73 "--org", "some"]74 )75 self.assertEqual(result.exit_code, 0)76 self.gh.assert_called_with("token")77 self.gh().get_organization.assert_called_with("some")78 def test_update(self):79 """80 runner = CliRunner()81 result = runner.invoke(update, ["--name", "testrepo", "--token", "token"])82 self.assertEqual(result.exit_code, 0)83 self.gh.assert_called_with("token")84 self.gh().get_user().get_repo.assert_called_with(name="testrepo")85 self.gh().get_user().get_repo().get_labels.assert_called_once_with()86 """87 def test_dont_update_when_nothing_changes(self):88 """89 runner = CliRunner()90 self.template.content = codecs.encode(b"some foo", "base64")91 result = runner.invoke(update, ["--name", "testrepo", "--token", "token"])92 self.assertEqual(result.exit_code, 0)93 self.gh.assert_called_with("token")94 self.gh().get_user().get_repo.assert_called_with(name="testrepo")95 self.gh().get_user().get_repo().get_labels.assert_called_once_with()96 self.gh().get_user().get_repo().update_file.assert_not_called()97 """98 def test_update_org(self):99 runner = CliRunner()100 result = runner.invoke(update, ["--name", "testrepo", "--token", "token", "--org", "some"])101 self.assertEqual(result.exit_code, 0)102 self.gh.assert_called_with("token")103 self.gh().get_organization().get_repo.assert_called_with(name="testrepo")104 self.gh().get_organization().get_repo().get_labels.assert_called_once_with()105 def test_update_index_does_not_exist(self):106 """107 self.gh().get_user().get_repo().update_file.side_effect = UnknownObjectException(status=404, data="foo")108 runner = CliRunner()109 result = runner.invoke(update, ["--name", "testrepo", "--token", "token"])110 self.assertEqual(result.exit_code, 0)111 self.gh.assert_called_with("token")112 self.gh().get_user().get_repo.assert_called_with(name="testrepo")113 self.gh().get_user().get_repo().get_labels.assert_called_once_with()114 self.gh().get_user().get_repo().create_file.assert_called_once_with(115 branch='gh-pages',116 content='some foo',117 message='initial',118 path='/index.html'119 )120 """121 def test_update_non_labeled_issue_not_displayed(self):122 """123 self.issue.get_labels.return_value = []124 runner = CliRunner()125 result = runner.invoke(update, ["--name", "testrepo", "--token", "token"])126 self.assertEqual(result.exit_code, 0)127 # make sure that get_comments is not called for the first issue but for the second128 self.issue.get_comments.assert_not_called()129 self.issue1.get_comments.assert_called_once_with()130 """131 def test_update_non_colaborator_issue_not_displayed(self):132 """133 self.issue.user.login = "some-other-dude"134 runner = CliRunner()135 result = runner.invoke(update, ["--name", "testrepo", "--token", "token"])136 self.assertEqual(result.exit_code, 0)137 # make sure that get_comments is not called for the first issue but for the second138 self.issue.get_comments.assert_not_called()139 self.issue1.get_comments.assert_called_once_with()140 """141 def test_dont_upgrade_when_nothing_changes(self):142 runner = CliRunner()143 self.template.content = codecs.encode(b"some foo", "base64")144 result = runner.invoke(upgrade, ["--name", "testrepo", "--token", "token"])145 self.assertEqual(result.exit_code, 0)146 self.gh.assert_called_with("token")147 self.gh().get_user().get_repo.assert_called_with(name="testrepo")148 self.gh().get_user().get_repo().update_file.assert_not_called()149class UtilTestCase(TestCase):150 def test_iter_systems(self):151 label1 = Mock()152 label2 = Mock()153 label1.name = "website"154 label1.color = SYSTEM_LABEL_COLOR155 self.assertEqual(156 list(iter_systems([label1, label2])),157 ["website", ]158 )159 self.assertEqual(160 list(iter_systems([label2])),161 []162 )...

Full Screen

Full Screen

render.py

Source:render.py Github

copy

Full Screen

...70 f"{topics_display}"71 f"\n\n"72 )73def _display_description(ghw, name) -> str:74 repo = ghw.get_repo(name)75 if repo.description is None:76 return f"{name}"77 else:78 assert repo.name is not None79 if repo.description.lower().startswith(repo.name.lower()) or f"{repo.name.lower()}:" in repo.description.lower():80 return f"{repo.description}"81 else:82 return f"{repo.name}: {repo.description}"83def process(df_input, token) -> pd.DataFrame:84 ghw = GithubWrapper(token)85 df = df_input.copy()86 df["_repopath"] = df["githuburl"].apply(lambda x: urlparse(x).path.lstrip("/"))87 df["_reponame"] = df["_repopath"].apply(lambda x: ghw.get_repo(x).name)88 df["_stars"] = df["_repopath"].apply(lambda x: ghw.get_repo(x).stargazers_count)89 df["_forks"] = df["_repopath"].apply(lambda x: ghw.get_repo(x).forks_count)90 df["_watches"] = df["_repopath"].apply(lambda x: ghw.get_repo(x).subscribers_count)91 df["_topics"] = df["_repopath"].apply(lambda x: ghw.get_repo(x).get_topics())92 df["_language"] = df["_repopath"].apply(lambda x: ghw.get_repo(x).language)93 df["_homepage"] = df["_repopath"].apply(lambda x: ghw.get_repo(x).homepage)94 df["_description"] = df["_repopath"].apply(95 lambda x: _display_description(ghw, x)96 )97 df["_organization"] = df["_repopath"].apply(98 lambda x: x.split("/")[0]99 )100 df["_updated_at"] = df["_repopath"].apply(101 lambda x: ghw.get_repo(x).updated_at.date()102 )103 df["_last_commit_date"] = df["_repopath"].apply(104 # E.g. Sat, 18 Jul 2020 17:14:09 GMT105 lambda x: datetime.strptime(106 ghw.get_repo(x).get_commits().get_page(0)[0].last_modified,107 "%a, %d %b %Y %H:%M:%S %Z",108 ).date()109 )110 df["_created_at"] = df["_repopath"].apply(111 lambda x: ghw.get_repo(x).created_at.date()112 )113 df["_age_weeks"] = df["_repopath"].apply(114 lambda x: (datetime.now().date() - ghw.get_repo(x).created_at.date()).days // 7115 )116 df["_stars_per_week"] = df["_repopath"].apply(117 lambda x: ghw.get_repo(x).stargazers_count * 7 / (datetime.now().date() - ghw.get_repo(x).created_at.date()).days118 )119 return df.sort_values("_stars", ascending=False)120def lines_header(count, category="") -> List[str]:121 category_line = f"A selection of {count} curated Python libraries and frameworks ordered by stars. \n"122 if len(category) > 0:123 category_line = f"A selection of {count} curated {category} Python libraries and frameworks ordered by stars. \n"124 return [125 f"# Crazy Awesome Python",126 category_line,127 f"Checkout the interactive version that you can filter and sort: ",128 f"[https://www.awesomepython.org/](https://www.awesomepython.org/) \n\n",129 ]130def add_markdown(df) -> pd.DataFrame:131 df["_doclines_main"] = df.apply(...

Full Screen

Full Screen

git.py

Source:git.py Github

copy

Full Screen

...17 ire[dire] = score18 sorted_ire = sorted(ire.iteritems(), key=operator.itemgetter(1), reverse=True)19 return sorted_ire20def get_lead_maintainer(issue):21 repo = get_repo()22 p = repo.get_pull(issue)23 files = p.get_files()24 lead_maintainer_file = rank_file_changes(files)[0][0]25 maintainer_handle = _maintainer_from_path(lead_maintainer_file)26 return maintainer_handle27def get_all_maintainers(issue):28 repo = get_repo()29 p = repo.get_pull(issue)30 files = p.get_files()31 maintainers = []32 for f in files:33 fpath = posixpath.dirname(f.filename)34 if fpath == '':35 fpath = '/'36 maintainer = _maintainer_from_path(fpath)37 print maintainer38 if maintainer not in maintainers:39 maintainers.append(maintainer)40 return maintainers41def check_pull_request_commits(number):42 repo = get_repo()43 pull = repo.get_pull(number)44 for commit in pull.get_commits():45 email = commit.commit.author.email46 real_name = commit.commit.author.name47 message = commit.commit.message48 signed = 'Signed-off-by: {0} <{1}>'.format(real_name, email) in message49 if signed:50 commit.create_status('success', description='Commit has been properly signed.')51 else:52 commit.create_status('error', description='This commit has not been properly signed. Please rebase with a proper commit message.')53 54def _maintainer_from_path(path):55 repo_name = properties.get('GITHUB_REPO')56 base_url = "http://raw.github.com/{0}/master".format(repo_name)57 print('base_url is {0}'.format(base_url))58 # based on a path, traverse it backward until you find the maintainer.59 url = '{0}/{1}/MAINTAINERS'.format(base_url, path)60 print url61 maintainer = urlopen(url).readline()62 try:63 print maintainer64 maintainer_handle = maintainer.split('@')[2].strip()[:-1]65 print('read MAINTAINER from {0} and maintainer handle is {1}'.format(url, maintainer_handle))66 return maintainer_handle67 except:68 print('unable to parse maintainer file. invalid format.')69 return _maintainer_from_path('/'.join(path.split('/')[:-1]))70def auth_git():71 return git(properties.get('GITHUB_USERNAME'), properties.get('GITHUB_PASSWORD'), timeout=3000)72def get_repo():73 g = auth_git()74 print('getting repo {0}'.format(properties.get('GITHUB_REPO')))75 docker_repo = g.get_repo(properties.get('GITHUB_REPO'))76 return docker_repo77def create_comment(number, body, *args, **kwargs):78 repo = get_repo()79 pull = repo.get_issue(number)80 pull.create_comment(body, *args, **kwargs)81 82def assign_issue(number, user):83 g = auth_git()84 r = g.get_repo(properties.get('GITHUB_REPO'))85 i = r.get_issue(number)86 print('assigning issue#{0} to {1} on repo {2}'.format(number, user, properties.get('GITHUB_REPO')))87 u = g.get_user(user)88 i.edit(assignee=u)89def update_status(commit_id, state, **kwargs):90 g = auth_git()91 repo = g.get_repo(properties.get('GITHUB_REPO'))92 commit = repo.get_commit(commit_id)93 commit.create_status(state, **kwargs)94 print "created status.."95def issues(*args, **kwargs):96 return [z for z in get_repo().get_issues(*args, **kwargs)]97def pulls(*args, **kwargs):98 return [z for z in get_repo().get_pulls(*args, **kwargs)]99def commits(*args, **kwargs):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful