Skip to content

Commit

Permalink
feat(service): date_published in datasets.list response
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammad-alisafaee committed Jan 7, 2024
1 parent 9377ac4 commit a0d54ad
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
1 change: 1 addition & 0 deletions renku/domain_model/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ class DatasetDetailsJson(marshmallow.Schema):
slug = marshmallow.fields.String(required=True)
version = marshmallow.fields.String(allow_none=True)
created_at = marshmallow.fields.String(allow_none=True, attribute="date_created")
date_published = marshmallow.fields.String(allow_none=True)

name = marshmallow.fields.String()
creators = marshmallow.fields.List(marshmallow.fields.Nested(DatasetCreatorsJson))
Expand Down
73 changes: 71 additions & 2 deletions tests/service/views/test_config_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# limitations under the License.
"""Renku service config view tests."""

import configparser
import json
import uuid

import pytest

Expand Down Expand Up @@ -43,6 +45,73 @@ def test_config_view_show(svc_client_with_repo):
assert 200 == response.status_code


@pytest.mark.service
@pytest.mark.integration
@retry_failed
def test_config_view_show_with_branch(svc_client_setup):
"""Check config show view in a different branch."""
svc_client, headers, project_id, url_components, repository = svc_client_setup

config_filepath = repository.path / ".renku" / "renku.ini"
current_branch = repository.active_branch.name
new_branch = uuid.uuid4().hex

# Write a default config value
config = configparser.ConfigParser()
config.add_section("interactive")
config["interactive"]["default_url"] = "/lab"
config.add_section("renku")
config["renku"]["test-config"] = "current-branch"
with open(config_filepath, "w") as f:
config.write(f)

repository.add(all=True)
repository.commit("master config")
repository.push(remote="origin", refspec=current_branch)
current_commit_sha = repository.active_branch.commit.hexsha

# Create a new branch and a modified config
repository.branches.add(new_branch)
repository.checkout(new_branch)
config["renku"]["test-config"] = "new-branch"
with open(config_filepath, "w") as f:
config.write(f)

repository.add(all=True)
repository.commit("new config")
repository.push(remote="origin", refspec=new_branch)

params = {
"git_url": url_components.href,
"branch": current_branch,
}

response = svc_client.get("/config.show", query_string=params, headers=headers)

assert 200 == response.status_code
assert "current-branch" == response.json["result"]["config"].get("renku.test-config")

params = {
"git_url": url_components.href,
"branch": new_branch,
}

response = svc_client.get("/config.show", query_string=params, headers=headers)

assert 200 == response.status_code
assert "new-branch" == response.json["result"]["config"].get("renku.test-config")

params = {
"git_url": url_components.href,
"branch": current_commit_sha,
}

response = svc_client.get("/config.show", query_string=params, headers=headers)

assert 200 == response.status_code
assert "current-branch" == response.json["result"]["config"].get("renku.test-config")


@pytest.mark.service
@pytest.mark.integration
@retry_failed
Expand Down Expand Up @@ -133,7 +202,7 @@ def test_config_view_set(svc_client_with_repo):
@pytest.mark.service
@pytest.mark.integration
@retry_failed
def test_config_view_set_nonexising_key_removal(svc_client_with_repo):
def test_config_view_set_non_existing_key_removal(svc_client_with_repo):
"""Check that removing a non-existing key (i.e. setting to None) is allowed."""
svc_client, headers, project_id, url_components = svc_client_with_repo

Expand All @@ -160,7 +229,7 @@ def test_config_view_set_and_show_failures(svc_client_with_repo):
"""Check errors triggered while invoking config set."""
svc_client, headers, project_id, url_components = svc_client_with_repo

# NOTE: use sections with wrong chars introduces a readin error. Should we handle it at write time?
# NOTE: use sections with wrong chars introduces a reading error. Should we handle it at write time?
payload = {
"git_url": url_components.href,
"config": {".NON_EXISTING": "test"},
Expand Down
1 change: 1 addition & 0 deletions tests/service/views/test_dataset_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ def test_list_datasets_view_remote(svc_client_with_repo, it_remote_repo_url):
"identifier",
"images",
"created_at",
"date_published",
"slug",
"name",
"creators",
Expand Down

0 comments on commit a0d54ad

Please sign in to comment.