Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b7c6a6c
Update bot.yaml
RohanBhattaraiNP Feb 7, 2025
241cd56
Update bot.yaml
RohanBhattaraiNP Feb 7, 2025
69f3a6e
Update cli.py
RohanBhattaraiNP Feb 7, 2025
17041d7
Update customize_schema.py
RohanBhattaraiNP Feb 7, 2025
d937dbd
Update bot_yaml.py
RohanBhattaraiNP Feb 7, 2025
7d6afcf
Update test_rdm.py
RohanBhattaraiNP Feb 7, 2025
9916a90
Update test_rdm.py
RohanBhattaraiNP Feb 7, 2025
a040571
Update cli.py
RohanBhattaraiNP Feb 7, 2025
db96fe9
Update customize_schema.py
RohanBhattaraiNP Feb 7, 2025
186e68c
Update bot.yaml
RohanBhattaraiNP Feb 7, 2025
aef0492
Update bot_yaml.py
RohanBhattaraiNP Feb 7, 2025
36a349b
Update customize_schema.py
RohanBhattaraiNP Feb 7, 2025
ff8d20a
Update bot.yaml
RohanBhattaraiNP Feb 7, 2025
d426208
Update customize_schema.py
RohanBhattaraiNP Feb 7, 2025
a80ea5a
Update bot.yaml
RohanBhattaraiNP Feb 7, 2025
ec5f1b3
Update customize_schema.py
RohanBhattaraiNP Feb 7, 2025
c521bfe
Update bot.yaml
RohanBhattaraiNP Feb 7, 2025
57435f3
Update test_rdm.py
RohanBhattaraiNP Feb 7, 2025
1613945
Update bot.yaml
RohanBhattaraiNP Feb 7, 2025
104f7cc
Update bot.yaml
RohanBhattaraiNP Feb 7, 2025
d6540c6
Delete tests/data/datacite43 directory
RohanBhattaraiNP Mar 5, 2025
1ec63c0
Create h
RohanBhattaraiNP Mar 5, 2025
b0a5573
Add files via upload
RohanBhattaraiNP Mar 5, 2025
43b7d37
Delete tests/data/datacite43/h
RohanBhattaraiNP Mar 5, 2025
9bb732d
Update customize_schema.py
RohanBhattaraiNP Mar 5, 2025
98c3443
Update customize_schema.py
RohanBhattaraiNP Mar 5, 2025
72405ac
Update customize_schema.py
RohanBhattaraiNP Mar 5, 2025
e5df301
Update customize_schema.py
RohanBhattaraiNP Mar 5, 2025
e56ccf1
Update conftest.py
RohanBhattaraiNP Mar 5, 2025
9f06fc0
Update cli.py
RohanBhattaraiNP Mar 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ jobs:
pip install pytest requests s3fs cryptography
pip install .

- name: Run CaltechDATA Metadata Validation
- name: Run against CaltechData Test system
env:
CALTECHDATA_TOKEN: ${{ secrets.CALTECHDATA_TOKEN }}
run: |
python tests/bot_yaml.py
- name: Run Unit Tests
RDMTOK: ${{ secrets.CALTECHDATA_TOKEN }}
run: |
cd tests
pytest test_unit.py
pytest test_rdm.py
- name: Run Medata Validation Test and RDM
env:
RDMTOK: ${{ secrets.CALTECHDATA_TOKEN }}
run: |
cd tests
python bot_yaml.py

5 changes: 3 additions & 2 deletions caltechdata_api/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def decrypt_token(encrypted_token, key):
return f.decrypt(encrypted_token).decode()


# Function to get or set token with support for test systems
# Function to get or set token with support for test system.
def get_or_set_token(production=True):
# First check for environment variable
env_token = os.environ.get("CALTECHDATA_TOKEN")
Expand All @@ -68,7 +68,7 @@ def get_or_set_token(production=True):

key = load_or_generate_key()

# Use different token files for production and test environment
# Use different token files for production and test environment.
token_filename = "token.txt" if production else "token_test.txt"
token_file = os.path.join(caltechdata_directory, token_filename)

Expand Down Expand Up @@ -609,6 +609,7 @@ def create_record(production):
print_upload_message(rec_id, production)
with open(response + ".json", "w") as file:
json.dump(metadata, file, indent=2)
exit()
break
else:
break
Expand Down
10 changes: 5 additions & 5 deletions caltechdata_api/customize_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,11 @@ def validate_metadata(json_record):
if creator["nameType"] == "Organizational":
if "name" not in creator:
errors.append("Each organizational 'creator' must have 'name'.")
else:
if "familyName" not in creator:
errors.append(
"Each 'creator' must have a 'familyName' or have type Organizational"
)
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this shouldn't be changed. Users should either provide a nameType or familyName (in which case we assume type Personal)

if "familyName" not in creator:
errors.append(
"Each 'creator' must have a 'familyName' or have type Organizational"
)
if "affiliation" in creator:
if not isinstance(creator["affiliation"], list):
errors.append("'affiliation' in 'creators' should be a list.")
Expand Down
3 changes: 2 additions & 1 deletion tests/bot_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ def import_cli_module(self):
def generate_test_responses(self):
"""Generate test responses for CLI prompts"""
return {
"Do you want to create or edit a CaltechDATA record? (create/edit): ": "create",
"What would you like to do? (create/edit/profile/exit): ": "create",
"Do you want to use metadata from an existing file or create new metadata? (existing/create): ": "create",
"Enter the title of the dataset: ": f"Test Dataset {self.timestamp}",
"Enter the abstract or description of the dataset: ": "This is an automated test dataset containing sample climate data for validation purposes.",
"Enter the number corresponding to the desired license: ": "1",
"Use saved profile? (y/n): ": "n",
"Enter your ORCID identifier: ": os.environ.get(
"TEST_ORCID", "0000-0002-1825-0097"
),
Expand Down
1 change: 0 additions & 1 deletion tests/data/datacite43/1171.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/data/datacite43/1235.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/data/datacite43/1250.json

This file was deleted.

1 change: 0 additions & 1 deletion tests/data/datacite43/1259.json

This file was deleted.

Loading
Loading