Skip to content

Commit

Permalink
It's a number, not a string!
Browse files Browse the repository at this point in the history
  • Loading branch information
stsewd committed May 10, 2022
1 parent 8c7c362 commit eb8d042
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
6 changes: 3 additions & 3 deletions readthedocs/oauth/services/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def create_repository(self, fields, privacy=None, organization=None):
]):

repo, _ = RemoteRepository.objects.get_or_create(
remote_id=fields['id'],
vcs_provider=self.vcs_provider_slug
remote_id=str(fields["id"]),
vcs_provider=self.vcs_provider_slug,
)

owner_type = fields["owner"]["type"]
Expand All @@ -111,7 +111,7 @@ def create_repository(self, fields, privacy=None, organization=None):
if (
organization
and owner_type == "Organization"
and organization.remote_id == fields["owner"]["id"]
and organization.remote_id == str(fields["owner"]["id"])
):
repo.organization = organization

Expand Down
25 changes: 13 additions & 12 deletions readthedocs/rtd_tests/tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def setUp(self):
self.client.login(username='eric', password='test')
self.user = User.objects.get(pk=1)
self.project = Project.objects.get(slug="pip")
self.org = RemoteOrganization.objects.create(slug="rtfd", remote_id=1234)
self.org = RemoteOrganization.objects.create(slug="rtfd", remote_id="1234")
self.privacy = settings.DEFAULT_PRIVACY_LEVEL
self.service = GitHubService(
user=self.user,
Expand All @@ -52,15 +52,15 @@ def setUp(self):
}
]
self.repo_response_data = {
'name': 'testrepo',
'full_name': 'testuser/testrepo',
'id': '12345678',
'description': 'Test Repo',
'git_url': 'git://github.com/testuser/testrepo.git',
'private': False,
'ssh_url': 'ssh://git@github.com:testuser/testrepo.git',
'html_url': 'https://github.com/testuser/testrepo',
'clone_url': 'https://github.com/testuser/testrepo.git',
"name": "testrepo",
"full_name": "testuser/testrepo",
"id": 12345678,
"description": "Test Repo",
"git_url": "git://github.com/testuser/testrepo.git",
"private": False,
"ssh_url": "ssh://git@github.com:testuser/testrepo.git",
"html_url": "https://github.com/testuser/testrepo",
"clone_url": "https://github.com/testuser/testrepo.git",
"owner": {
"type": "User",
"id": 1234,
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_project_was_moved_from_an_organization_to_a_personal_account(self):

def test_project_was_moved_to_another_organization(self):
another_remote_organization = RemoteOrganization.objects.create(
slug="another", remote_id=4321
slug="another", remote_id="4321"
)

# Project belongs to an organization.
Expand Down Expand Up @@ -347,11 +347,12 @@ def test_send_build_status_value_error(self, session, mock_logger):
@override_settings(DEFAULT_PRIVACY_LEVEL='private')
def test_create_public_repo_when_private_projects_are_enabled(self):
"""Test ability to import ``public`` repositories under ``private`` level."""
self.repo_response_data["owner"]["type"] = "Organization"
repo = self.service.create_repository(
self.repo_response_data, organization=self.org
)
self.assertEqual(repo.organization, self.org)
self.assertEqual(repo.remote_id, self.repo_response_data["id"])
self.assertEqual(repo.remote_id, str(self.repo_response_data["id"]))

@mock.patch('readthedocs.oauth.services.github.log')
@mock.patch('readthedocs.oauth.services.github.GitHubService.get_session')
Expand Down

0 comments on commit eb8d042

Please sign in to comment.