-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to import public repositories on corporate site #3537
Conversation
When the DEFAULT_PRIVACY_LEVEL is ``private`` we allow to import public _and_ private repositories from Bitbucket service.
b3ac73d
to
f5e8987
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is certainly something that we should have caught. Tests here would be a good addition.
I just pushed a test for this, but I will add a comment on the commit since we need to find out how to make it valid :) |
@@ -270,6 +271,17 @@ def test_make_project_fail(self): | |||
data, organization=self.org, privacy=self.privacy) | |||
self.assertIsNone(repo) | |||
|
|||
@override_settings(DEFAULT_PRIVACY_LEVEL='private') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the most important part of the test.
The problem we have here is how are the method defined and how they use this setting:
- the setting is accessed at https://github.com/rtfd/readthedocs.org/blob/415120759b9abbf67092a1e4781341b0d58f205a/readthedocs/oauth/services/bitbucket.py#L22
- so, when it's accessed the first time, it's
public
(the default) and theBitbucketService.create_repository
is created withpublic
as default forprivacy
at https://github.com/rtfd/readthedocs.org/blob/415120759b9abbf67092a1e4781341b0d58f205a/readthedocs/oauth/services/bitbucket.py#L90-L92 - finally, my
@override_settings
patch has no effect
The test passes because it's a public
repo under a public
default privacy level.
What it should be the best way to handle this? Should we make privacy
as None
by default and access the settings
object inside the create_repository
method?
cc @agjohnson
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this probably makes the most sense. 👍
@agjohnson after the changes, this is ready to be merged. Please, take another look if you can. |
Looks great! 👍 on the tests for other providers as well. Make our tests more defensive is a smart idea. |
When the DEFAULT_PRIVACY_LEVEL is
private
we allow to importpublic and private repositories from Bitbucket service.
This handles an issue under
.com
, https://github.com/readthedocs/readthedocs-corporate/issues/225