Skip to content

Commit

Permalink
Rebuild demo output
Browse files Browse the repository at this point in the history
  • Loading branch information
zimeon committed Oct 21, 2024
1 parent 5b42ba0 commit 5fe9673
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 17 deletions.
6 changes: 3 additions & 3 deletions docs/demo_build_v1_0_spec_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"type": "https://ocfl.io/1.0/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-21T14:04:00.192769Z",
"created": "2024-10-21T17:25:40.589858Z",
"state": {
"7dcc352f96c56dc...c31": [
"foo/bar.xml"
Expand All @@ -114,7 +114,7 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
}
},
"v2": {
"created": "2024-10-21T14:04:00.193378Z",
"created": "2024-10-21T17:25:40.590400Z",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand All @@ -126,7 +126,7 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
}
},
"v3": {
"created": "2024-10-21T14:04:00.193732Z",
"created": "2024-10-21T17:25:40.590672Z",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand Down
6 changes: 3 additions & 3 deletions docs/demo_build_v1_1_spec_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-21T14:04:00.709527Z",
"created": "2024-10-21T17:25:41.115854Z",
"state": {
"7dcc352f96c56dc...c31": [
"foo/bar.xml"
Expand All @@ -114,7 +114,7 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
}
},
"v2": {
"created": "2024-10-21T14:04:00.710212Z",
"created": "2024-10-21T17:25:41.116411Z",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand All @@ -126,7 +126,7 @@ This is inventory should match the example with 3 versions in <https://ocfl.io/1
}
},
"v3": {
"created": "2024-10-21T14:04:00.710604Z",
"created": "2024-10-21T17:25:41.117149Z",
"state": {
"4d27c86b026ff70...b53": [
"foo/bar.xml"
Expand Down
65 changes: 59 additions & 6 deletions docs/demo_ocfl_object_script.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Without an `--objdir` argument the script just writes out the inventory for the
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-21T14:03:55.460006Z",
"created": "2024-10-21T17:25:35.531888Z",
"state": {
"43a43fe8a8a082d3b5343dfaf2fd0c8b8e370675b1f376e92e9994612c33ea255b11298269d72f797399ebb94edeefe53df243643676548f584fb8603ca53a0f": [
"a_file.txt"
Expand Down Expand Up @@ -69,23 +69,23 @@ Without an `--objdir` argument the script just writes out the inventory for each
"type": "https://ocfl.io/1.1/spec/#inventory",
"versions": {
"v1": {
"created": "2024-10-21T14:03:55.607383Z",
"created": "2024-10-21T17:25:35.679587Z",
"state": {
"43a43fe8a8a082d3b5343dfaf2fd0c8b8e370675b1f376e92e9994612c33ea255b11298269d72f797399ebb94edeefe53df243643676548f584fb8603ca53a0f": [
"a_file.txt"
]
}
},
"v2": {
"created": "2024-10-21T14:03:55.607784Z",
"created": "2024-10-21T17:25:35.679921Z",
"state": {
"296e72b8fd5f7f0ac1473993600ae34953d5dab646f17e7b182b8648aff830d7bf01b56490777cb3e72b33fcc1ae520506badea1032252d1a55fd7362e269975": [
"a_file.txt"
]
}
},
"v3": {
"created": "2024-10-21T14:03:55.607960Z",
"created": "2024-10-21T17:25:35.680048Z",
"state": {
"43a43fe8a8a082d3b5343dfaf2fd0c8b8e370675b1f376e92e9994612c33ea255b11298269d72f797399ebb94edeefe53df243643676548f584fb8603ca53a0f": [
"a_file.txt"
Expand Down Expand Up @@ -119,7 +119,7 @@ INFO:root:Built object http://example.org/obj2 at tmp/obj2 with 3 versions

## 5. Test extract of version.

### 5.1 Extract v1 of an OCFL v1.0 object
### 5.1 Extract v1 of content in an OCFL v1.0 object

Version 1 object with location specified in `--objdir` and the first version specified in `--objver`, extract into tmp/v1:

Expand All @@ -141,14 +141,25 @@ tmp/v1/foo/bar.xml
```


### 5.2 Extract v2 of content in the same OCFL v1.1 object
### 5.2 Extract v2 of content in an OCFL v1.1 object

```
> python ocfl-object.py extract --objver v2 --objdir fixtures/1.1/good-objects/spec-ex-full --dstdir tmp/v2 -v
INFO:root:Extracted v2 into tmp/v2
Extracted content for v2 in tmp/v2
```

and the extracted files are:

```
> find tmp/v2 -print
tmp/v2
tmp/v2/empty.txt
tmp/v2/empty2.txt
tmp/v2/foo
tmp/v2/foo/bar.xml
```


### 5.3 Extract head version (v3) of content in the same OCFL v1.1 object

Expand All @@ -158,6 +169,48 @@ INFO:root:Extracted v3 into tmp/head
Extracted content for v3 in tmp/head
```

and the extracted files are:

```
> find tmp/v3 -print
find: tmp/v3: No such file or directory
```

(last command exited with return code 1)


### 5.4 Extract foo/bar.xml of v3 into a new directory

```
> python ocfl-object.py extract --objver v3 --objdir fixtures/1.1/good-objects/spec-ex-full --logical-path foo/bar.xml --dstdir tmp/files -v
Extracted foo/bar.xml in v3 to tmp/files
```

and the extracted file is:

```
> find tmp/files -print
tmp/files
tmp/files/bar.xml
```


### 5.5 Extract image.tiff of v3 (default) into the same directory

```
> python ocfl-object.py extract --objdir fixtures/1.1/good-objects/spec-ex-full --logical-path image.tiff --dstdir tmp/files -v
Extracted image.tiff in v3 to tmp/files
```

and the directory now contains two extracted files:

```
> find tmp/files -print
tmp/files
tmp/files/image.tiff
tmp/files/bar.xml
```


## 6. Test error conditions.

Expand Down
4 changes: 2 additions & 2 deletions docs/demo_using_bagit_bags.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ Taking the newly created OCFL object `/tmp/obj` we can `--extract` the `v4` cont
INFO:root:Extracted v4 into tmp/extracted_v4
INFO:bagit:Creating bag for directory tmp/extracted_v4
INFO:bagit:Creating data directory
INFO:bagit:Moving my_content to /privatetmp/extracted_v4/tmp7apb1l_h/my_content
INFO:bagit:Moving /privatetmp/extracted_v4/tmp7apb1l_h to data
INFO:bagit:Moving my_content to /privatetmp/extracted_v4/tmp1ilh36tg/my_content
INFO:bagit:Moving /privatetmp/extracted_v4/tmp1ilh36tg to data
INFO:bagit:Using 1 processes to generate manifests: sha512
INFO:bagit:Generating manifest lines for file data/my_content/dracula.txt
INFO:bagit:Generating manifest lines for file data/my_content/dunwich.txt
Expand Down
5 changes: 2 additions & 3 deletions tests/test_demo_ocfl_object_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,16 @@ def test04_extract(self):
text="and the extracted file is:")
self.assertEqual(os.path.getsize(os.path.join(self.tmpdir, "files/bar.xml")), 272)
# Extract individual file into dir that exists
out = self.run_script("Extract image.tiff of v3 into the same directory",
out = self.run_script("Extract image.tiff of v3 (default) into the same directory",
["python", "ocfl-object.py", "extract",
"--objver", "v3",
"--objdir", "fixtures/1.1/good-objects/spec-ex-full",
"--logical-path", "image.tiff",
"--dstdir", "TMPDIR/files",
"-v"])
self.assertIn('Extracted image.tiff in v3', out)
out = self.run_script(None,
["find", "TMPDIR/files", "-print"],
text="and the directort now contains two extracted files:")
text="and the directory now contains two extracted files:")
self.assertEqual(os.path.getsize(os.path.join(self.tmpdir, "files/image.tiff")), 2021)

def test20_errors(self):
Expand Down

0 comments on commit 5fe9673

Please sign in to comment.