Skip to content

Commit

Permalink
Create READ_ME
Browse files Browse the repository at this point in the history
  • Loading branch information
rushirajnenuji committed Jul 29, 2023
1 parent d359fff commit 385bc52
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 0 deletions.
33 changes: 33 additions & 0 deletions ezidapp/migrations/0003_auto_20230713_1643.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.2.18 on 2023-07-13 16:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('ezidapp', '0002_auto_20221026_1139'),
]

operations = [
migrations.AlterField(
model_name='binderqueue',
name='status',
field=models.CharField(choices=[('U', 'Awaiting submission'), ('C', 'Submitted, unchecked'), ('S', 'Submitted'), ('W', 'Registered with warning'), ('F', 'Registration failed'), ('T', 'Registration attempt unsuccessful'), ('I', 'Ignored (operation not applicable)'), ('O', 'Completed successfully')], db_index=True, default='U', max_length=1),
),
migrations.AlterField(
model_name='crossrefqueue',
name='status',
field=models.CharField(choices=[('U', 'Awaiting submission'), ('C', 'Submitted, unchecked'), ('S', 'Submitted'), ('W', 'Registered with warning'), ('F', 'Registration failed'), ('T', 'Registration attempt unsuccessful'), ('I', 'Ignored (operation not applicable)'), ('O', 'Completed successfully')], db_index=True, default='U', max_length=1),
),
migrations.AlterField(
model_name='datacitequeue',
name='status',
field=models.CharField(choices=[('U', 'Awaiting submission'), ('C', 'Submitted, unchecked'), ('S', 'Submitted'), ('W', 'Registered with warning'), ('F', 'Registration failed'), ('T', 'Registration attempt unsuccessful'), ('I', 'Ignored (operation not applicable)'), ('O', 'Completed successfully')], db_index=True, default='U', max_length=1),
),
migrations.AlterField(
model_name='searchindexerqueue',
name='status',
field=models.CharField(choices=[('U', 'Awaiting submission'), ('C', 'Submitted, unchecked'), ('S', 'Submitted'), ('W', 'Registered with warning'), ('F', 'Registration failed'), ('T', 'Registration attempt unsuccessful'), ('I', 'Ignored (operation not applicable)'), ('O', 'Completed successfully')], db_index=True, default='U', max_length=1),
),
]
22 changes: 22 additions & 0 deletions ezidapp/migrations/0004_profilecopy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.2.18 on 2023-07-13 17:35

import django.core.validators
from django.db import migrations, models
import re


class Migration(migrations.Migration):

dependencies = [
('ezidapp', '0003_auto_20230713_1643'),
]

operations = [
migrations.CreateModel(
name='ProfileCopy',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('label', models.CharField(max_length=32, unique=True, validators=[django.core.validators.RegexValidator('^[a-z0-9]+([-_.][a-z0-9]+)*$', 'Invalid profile name.', flags=re.RegexFlag['IGNORECASE'])])),
],
),
]
19 changes: 19 additions & 0 deletions ezidapp/migrations/0005_profilecopy_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.18 on 2023-07-13 17:55

from django.db import migrations, models
import ezidapp.models.validation


class Migration(migrations.Migration):

dependencies = [
('ezidapp', '0004_profilecopy'),
]

operations = [
migrations.AddField(
model_name='profilecopy',
name='prefix',
field=models.CharField(default='ark:/99999/fk8', max_length=255, unique=True, validators=[ezidapp.models.validation.shoulder]),
),
]
45 changes: 45 additions & 0 deletions ezidapp/models/profile_copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright©2021, Regents of the University of California
# http://creativecommons.org/licenses/BSD

"""Abstract database model for metadata profiles.
"""

import re

import django.core.validators
import django.db.models
import impl.util

import impl
from ezidapp.models import validation


class ProfileCopy(django.db.models.Model):
label = django.db.models.CharField(
max_length=32,
unique=True,
validators=[
django.core.validators.RegexValidator(
"^[a-z0-9]+([-_.][a-z0-9]+)*$", "Invalid profile name.", flags=re.I
)
],
)

prefix = django.db.models.CharField(
max_length=impl.util.maxIdentifierLength,
unique=True,
validators=[validation.shoulder],
default='ark:/99999/fk8'
)
# The profile's label, e.g., "erc".

def clean(self):
self.label = self.label.strip()

def __str__(self):
return self.label


# if caches is None:
# labelCache = dict((p.label, p) for p in Profile.objects.all())
# idCache = dict((p.id, p) for p in list(labelCache.values()))
60 changes: 60 additions & 0 deletions tests/READ_ME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: EZID Py Test
tags: []
---

1. Set up virtual environment

```python
python3 -m venv .test-venv
```

2. Activate virtual environment
```python
source .test-venv/bin/activate
```


3. Install requirements.txt
```python
pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
```


4. Set up Django settings module
```bash
export DJANGO_SETTINGS_MODULE=settings.tests
```

5. Start mysql
```bash
brew services start mysql
```

6. Run mysql_test_setup.sh
```bash
shell tests/mysql_test_setup.sh
```

7. Set up file system
```bash
mkdir -p ../download/public ../logs
```

8. Setup DB and static files
```python
./manage.py migrate
./manage.py collectstatic --no-input
```

9. Load DB fixture
```python
./manage.py loaddata db
```

10. Run tests
```python
pytest --maxfail 10
```

0 comments on commit 385bc52

Please sign in to comment.