Esempio n. 1
0
def repository(ghapi, *args, **kwargs):
    repository = kwargs['name']
    owner = kwargs['owner']
    verbose = kwargs['verbose']

    repository_info = analytics.get_repository_information(
        ghapi,
        owner,
        repository
    )
    repository_contributors = analytics.get_repository_contributors(
        ghapi,
        owner,
        repository
    )

    for human_readable_name, api_info in repository_info.items():
        leftpad_print(
            "{}: {}".format(human_readable_name, api_info),
            leftpad_length=0
        )

    leftpad_print("Contributors:", leftpad_length=0)

    contributor_count = len(repository_contributors) if verbose else CONCISE_COUNT

    for contributor in repository_contributors[:contributor_count]:
        for human_readable_name, api_info in contributor.items():
            leftpad_print(
                "{}: {}".format(human_readable_name, api_info),
                leftpad_length=2
            )
Esempio n. 2
0
    def test_get_repository_information(self):
        return_value = (
            {
                'name': 'name1',
                'description': 'desc1',
                'homepage': 'home1',
                'html_url': 'hu1',
                'clone_url': 'cu1',
                'created_at': 'ca1',
                'updated_at': 'ua1',
                'pushed_at': 'pa1',
                'language': 'lang1',
                'forks_count': 'fc1',
                'stargazers_count': 'sc1',
                'watchers_count': 'wc1',
            },
            requests.codes.OK,
        )

        ghapi = mock.MagicMock()
        ghapi.get_public_repository = mock.MagicMock(
            return_value=return_value
        )

        result = analytics.get_repository_information(ghapi, "unused", "unused")

        expected = collections.OrderedDict([
            ('Repository Name', 'name1'),
            ('Description', 'desc1'),
            ('Homepage', 'home1'),
            ('Github URL', 'hu1'),
            ('Clone URL', 'cu1'),
            ('Created', 'ca1'),
            ('Last Updated', 'ua1'),
            ('Last Pushed', 'pa1'),
            ('Language', 'lang1'),
            ('Forks', 'fc1'),
            ('Stars', 'sc1'),
            ('Watchers', 'wc1'),
        ])

        self.assertEqual(result, expected)