Merge pull request !2759 from rhodecode-enterprise-ce feature/RCCE-251_Add-internal-api-field-that-indicates-if-repo-is-archived
feature: adds 'archived' field to internal api response
This commit is contained in:
commit
6fa7a269b8
2 changed files with 34 additions and 3 deletions
|
|
@ -15,11 +15,14 @@
|
|||
# This program is dual-licensed. If you wish to learn more about the
|
||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from rhodecode.api.utils import Optional, OAttr
|
||||
from rhodecode.api.tests.utils import build_data, api_call, assert_error, assert_ok
|
||||
from rhodecode.model.db import Repository
|
||||
from rhodecode.model.meta import Session
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("testuser_api", "app")
|
||||
|
|
@ -133,3 +136,30 @@ class TestApi(object):
|
|||
response = api_call(self.app, params)
|
||||
assert response.status == "200 OK"
|
||||
assert_ok(id_, expected, response.body)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"is_archived",
|
||||
[
|
||||
True,
|
||||
False,
|
||||
],
|
||||
)
|
||||
def test_api_repo_is_archived(self, backend, is_archived):
|
||||
repo_name = self._create_repo(backend, is_archived)
|
||||
|
||||
id_, params = build_data(apikey=self.apikey, method="get_repo", repoid=repo_name)
|
||||
response = api_call(self.app, params)
|
||||
|
||||
assert response.status == "200 OK"
|
||||
|
||||
json_body = json.loads(response.body)
|
||||
|
||||
assert json_body["result"]["archived"] == is_archived
|
||||
|
||||
def _create_repo(self, backend, is_archived):
|
||||
repo = backend.create_repo()
|
||||
repo_name = repo.repo_name
|
||||
repo = Repository.get_by_repo_name(repo_name)
|
||||
repo.archived = is_archived
|
||||
Session().commit()
|
||||
return repo_name
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ class BaseModel(object):
|
|||
return cls.query().all()
|
||||
|
||||
@classmethod
|
||||
def delete(cls, id_):
|
||||
def delete(cls, id_): # noqa: F811
|
||||
obj = cls.query().get(id_)
|
||||
Session().delete(obj)
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ class RhodeCodeSetting(Base, BaseModel):
|
|||
|
||||
@validates("_app_settings_value")
|
||||
def validate_settings_value(self, key, val):
|
||||
assert type(val) == str
|
||||
assert type(val) is str
|
||||
return val
|
||||
|
||||
@hybrid_property
|
||||
|
|
@ -535,7 +535,7 @@ class RepoRhodeCodeSetting(Base, BaseModel):
|
|||
|
||||
@validates("_app_settings_value")
|
||||
def validate_settings_value(self, key, val):
|
||||
assert type(val) == str
|
||||
assert type(val) is str
|
||||
return val
|
||||
|
||||
@hybrid_property
|
||||
|
|
@ -2398,6 +2398,7 @@ class Repository(Base, BaseModel):
|
|||
"locked_by": User.get(_user_id).get_api_data(include_secrets=include_secrets) if _user_id else None,
|
||||
"locked_date": time_to_datetime(_time) if _time else None,
|
||||
"lock_reason": _reason if _reason else None,
|
||||
"archived": repo.archived or False,
|
||||
}
|
||||
|
||||
# TODO: mikhail: should be per-repo settings here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue