Skip to content

Commit

Permalink
test: add all supported file extensions to testdata and docs (DEV-1187)…
Browse files Browse the repository at this point in the history
… (#213)
  • Loading branch information
jnussbaum committed Aug 15, 2022
1 parent 6849737 commit 72000b3
Show file tree
Hide file tree
Showing 42 changed files with 392 additions and 23 deletions.
6 changes: 3 additions & 3 deletions docs/dsp-tools-create-ontologies.md
Expand Up @@ -797,13 +797,13 @@ The following base resources can be used as super-resource:

- `Resource`: A generic resource representing an item from the real world. This is the most general case, to be
used in all cases when your resource is none of the special cases below.
- `StillImageRepresentation`: A resource representing an image
- `TextRepresentation`: A resource representing a text
- `ArchiveRepresentation`: A resource representing an archive file (e.g. ZIP)
- `AudioRepresentation`: A resource representing an audio file
- `DDDRepresentation`: A resource representing a 3-D representation (not yet implemented)
- `DocumentRepresentation`: A resource representing an opaque document (e.g. a PDF)
- `MovingImageRepresentation`: A resource representing a video
- `ArchiveRepresentation`: A resource representing an archive file (e.g. ZIP)
- `StillImageRepresentation`: A resource representing an image
- `TextRepresentation`: A resource representing a text


### Cardinalities
Expand Down
13 changes: 13 additions & 0 deletions docs/dsp-tools-xmlupload.md
Expand Up @@ -265,6 +265,19 @@ Note:
- There is only _one_ `<bitstream>` element allowed per representation!
- The `<bitstream>` element must be the first element!

Supported file extensions:

| Representation | Supported formats |
| --------------------------- |----------------------------------------|
| `ArchiveRepresentation` | ZIP, TAR, GZ, Z, TAR.GZ, TGZ, GZIP, 7Z |
| `AudioRepresentation` | MP3, MP4, WAV |
| `DocumentRepresentation` | PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX |
| `MovingImageRepresentation` | MP4 |
| `StillImageRepresentation` | JPG, JPEG, PNG, TIF, TIFF, JP2 |
| `TextRepresentation` | TXT, CSV, XML, XSL, XSD |

For more details, please consult the [API docs](https://docs.dasch.swiss/latest/DSP-API/01-introduction/file-formats/).

Attributes:

- `permissions` : Permission ID (optional, but if omitted, users who are lower than a `ProjectAdmin` have no permissions at all, not even view rights)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/test_resource.py
Expand Up @@ -52,13 +52,13 @@ def test_Resource_create(self) -> None:

thing_picture = factory.get_resclass_type('anything:ThingPicture')
sipi = Sipi('http://0.0.0.0:1024', self.con.get_token())
img = sipi.upload_bitstream('testdata/bitstreams/TEMP11.TIF')
img = sipi.upload_bitstream('testdata/bitstreams/test.tif')
file_ref = img['uploadedFiles'][0]['internalFilename']
res_perm = Permissions({PermissionValue.M: ["knora-admin:UnknownUser", "knora-admin:KnownUser"],
PermissionValue.CR: ["knora-admin:Creator", "knora-admin:ProjectAdmin"]})

resource_bitstream = {
'value': 'testdata/bitstreams/TEMP11.TIF',
'value': 'testdata/bitstreams/test.tif',
'internal_file_name': file_ref,
'permissions': res_perm
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/test_tools.py
Expand Up @@ -22,7 +22,7 @@ class TestTools(unittest.TestCase):
sipi = 'http://0.0.0.0:1024'
test_project_file = 'testdata/test-project-systematic.json'
test_project_minimal_file = 'testdata/test-project-minimal.json'
test_data_file = 'testdata/test-data.xml'
test_data_file = 'testdata/test-data-systematic.xml'

def setUp(self) -> None:
"""Is executed before each test"""
Expand Down Expand Up @@ -197,7 +197,7 @@ def test_xml_upload(self) -> None:
self.assertTrue(result)

mapping_file = ''
for mapping in [x for x in os.scandir('.') if x.name.startswith('id2iri_test-data_mapping_')]:
for mapping in [x for x in os.scandir('.') if x.name.startswith('id2iri_test-data-systematic_mapping_')]:
delta = datetime.datetime.now() - datetime.datetime.fromtimestamp(mapping.stat().st_mtime_ns / 1000000000)
if delta.seconds < 15:
mapping_file = mapping.name
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/test_xmlupload.py
Expand Up @@ -34,7 +34,7 @@ def test_convert_ark_v0_to_resource_iri(self) -> None:

def test_remove_circular_references(self) -> None:
# create a list of XMLResources from the test data file
tree = _parse_xml_file('testdata/test-data.xml')
tree = _parse_xml_file('testdata/test-data-systematic.xml')
resources = [XMLResource(x, 'testonto') for x in tree.getroot() if x.tag == "resource"]

# get the purged resources and the stashes from the function to be tested
Expand Down
32 changes: 32 additions & 0 deletions testdata/bitstreams/README.txt
@@ -0,0 +1,32 @@
Rights/Licenses of the test data in this directory
**************************************************

test.7z DaSCH: Johannes Nussbaum
test.csv DaSCH: rosetta/Documents/RosettaCategoryList.csv
test.doc DaSCH: rosetta/Documents/RosettaTestProject.docx
test.docx DaSCH: rosetta/Documents/RosettaTestProject.docx
test.gz DaSCH: Johannes Nussbaum
test.gzip Python Package joblib: /test/data/joblib_0.11.0_pickle_py36_np111.pkl.gzip
test.jp2 Public Domain: www.loc.gov/item/00279382687-ms (Library of Congress Collection of Manuscripts in St. Catherine's Monastery, Mt. Sinai)
test.jpeg https://filesamples.com/samples/image/jpeg/sample_640%C3%97426.jpeg
test.jpg Public Domain: https://en.wikipedia.org/wiki/Haiku#/media/File:Basho_Horohoroto.jpg
test.mp3 DaSCH: Johannes Nussbaum
test.mp4 https://filesamples.com/samples/video/mp4/sample_960x540.mp4
test.pdf DaSCH: rosetta/Documents/RosettaTestProject.docx
test.png DaSCH: Johannes Nussbaum
test.ppt DaSCH: Johannes Nussbaum
test.pptx DaSCH: Johannes Nussbaum
test.tar DaSCH: Johannes Nussbaum
test.tar.gz DaSCH: Johannes Nussbaum
test.tgz DaSCH: Johannes Nussbaum
test.tif DaSCH: Lukas Rosenthaler
test.tiff DaSCH: Lukas Rosenthaler
test.txt DaSCH: Johannes Nussbaum
test.wav DaSCH: Johannes Nussbaum
test.xls DaSCH: Johannes Nussbaum
test.xlsx DaSCH: Johannes Nussbaum
test.xml DaSCH: Johannes Nussbaum
test.xsd DaSCH: Johannes Nussbaum
test.xsl DaSCH: Johannes Nussbaum
test.z DaSCH: Johannes Nussbaum
test.zip DaSCH: Johannes Nussbaum
Binary file removed testdata/bitstreams/TEMP11.TIF
Binary file not shown.
Binary file removed testdata/bitstreams/TEMP12.TIF
Binary file not shown.
Binary file removed testdata/bitstreams/TEMP13.TIF
Binary file not shown.
Binary file removed testdata/bitstreams/TEMP14.TIF
Binary file not shown.
Binary file removed testdata/bitstreams/TEMP15.TIF
Binary file not shown.
Binary file removed testdata/bitstreams/clara.wav
Binary file not shown.
Binary file added testdata/bitstreams/test.7z
Binary file not shown.
14 changes: 13 additions & 1 deletion testdata/bitstreams/test.csv
@@ -1 +1,13 @@
Performing arts;;;Performing arts;Music;;Performing arts;Music;Chamber music;Performing arts;Music;Church music;Performing arts;Music;Conducting;Performing arts;Music;Conducting;ChoirsPerforming arts;Music;Conducting;OrchestrasPerforming arts;Music;Music history;Performing arts;Music;Musictheory;Performing arts;Music;Musicology;Performing arts;Music;Jazz;Performing arts;Music;Pop/Rock/Blues;Dance;;;Dance;Choreography;;Theatre;;;Theatre;Acting;;Theatre;Directing;;Theatre;Playwriting;;Theatre;Scenography;;Movies/television;;;Movies/television;Animation;;Movies/television;Live action;;Visual arts;;;Visual arts;Fine Arts;;Visual arts;Fine Arts;Drawing;Visual arts;Fine Arts;Painting;Visual arts;Fine Arts;Photography;Visual arts;Applied arts;;Visual arts;Applied arts;Animation;Visual arts;Applied arts;Architecture;Visual arts;Applied arts;Decorative arts;History;;;History;Ancient history;;History;Modern history;;Languages and literature;;;Languages and literature;Linguistics;;Languages and literature;Linguistics;Grammer;Languages and literature;Linguistics;Etymology;Languages and literature;Linguistics;Phonetics;Languages and literature;Linguistics;Semantics;Languages and literature;Literature;;Languages and literature;Literature;Fiction;Languages and literature;Literature;Non-fiction;Languages and literature;Literature;Theory of literature;Philosophy;;;Philosophy;Aesthetics;;Philosophy;Applied philosophy;;Philosophy;Epistemology;;Philosophy;Epistemology;Justification;Philosophy;Epistemology;Reasoning;Philosophy;Metaphysics;;Philosophy;Metaphysics;Determinisn and free will;Philosophy;Metaphysics;Ontology;Philosophy;Metaphysics;Philosophy of mind;Philosophy;Metaphysics;Teleology;
artwork;;
vehicles;;
nature;;
nature;humans;
nature;animals;
nature;animals;mammals
nature;animals;insects
nature;animals;birds
nature;animals;amphibians
nature;animals;reptiles
nature;plants;
nature;weather;
nature;physics;
Binary file added testdata/bitstreams/test.doc
Binary file not shown.
Binary file added testdata/bitstreams/test.docx
Binary file not shown.
Binary file added testdata/bitstreams/test.gz
Binary file not shown.
Binary file added testdata/bitstreams/test.gzip
Binary file not shown.
Binary file added testdata/bitstreams/test.jp2
Binary file not shown.
Binary file added testdata/bitstreams/test.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/bitstreams/test.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/bitstreams/test.mp3
Binary file not shown.
File renamed without changes.
Binary file modified testdata/bitstreams/test.pdf
Binary file not shown.
Binary file added testdata/bitstreams/test.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added testdata/bitstreams/test.ppt
Binary file not shown.
Binary file added testdata/bitstreams/test.pptx
Binary file not shown.
Binary file added testdata/bitstreams/test.tar
Binary file not shown.
Binary file added testdata/bitstreams/test.tar.gz
Binary file not shown.
Binary file added testdata/bitstreams/test.tgz
Binary file not shown.
Binary file added testdata/bitstreams/test.tif
Binary file not shown.
Binary file added testdata/bitstreams/test.tiff
Binary file not shown.
5 changes: 5 additions & 0 deletions testdata/bitstreams/test.txt
@@ -0,0 +1,5 @@
Test text file
--------------

This is a sample text file without much content.
It contains the special characters àö¨`ô^.
Binary file added testdata/bitstreams/test.wav
Binary file not shown.
Binary file added testdata/bitstreams/test.xls
Binary file not shown.
Binary file added testdata/bitstreams/test.xlsx
Binary file not shown.
21 changes: 21 additions & 0 deletions testdata/bitstreams/test.xml
@@ -0,0 +1,21 @@
<?xml version='1.0' encoding='utf-8'?>

<knora xmlns="https://dasch.swiss/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://dasch.swiss/schema ../knora/dsplib/schemas/data.xsd">

<!-- this is a comment -->
<permissions id="res-default">
<allow group="UnknownUser">RV</allow>
<allow group="KnownUser">V</allow>
</permissions>

<resource label="test xml file"
restype=":TestFile"
id="test_xml_file">
<text-prop name=":hasText">
<text encoding="utf8">This is a test XML file</text>
</text-prop>
</resource>

</knora>
36 changes: 36 additions & 0 deletions testdata/bitstreams/test.xsd
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="https://dasch.swiss/schema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://dasch.swiss/schema"
elementFormDefault="qualified">

<!-- complete document -->
<xs:element name="knora">
<xs:complexType>
<xs:sequence>
<xs:element name="permissions" type="permissions_type" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice maxOccurs="unbounded">
<xs:element name="region" type="region_type" minOccurs="0" maxOccurs="unbounded">
<xs:unique name="UniqueNameAttr_Region">
<xs:selector xpath=".//*"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="link" type="link_type" minOccurs="0" maxOccurs="unbounded">
<xs:unique name="UniqueNameAttr_Link">
<xs:selector xpath=".//*"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="default-ontology" type="xs:string"/>
<xs:attribute name="shortcode" type="knorashortcode_type"/>
</xs:complexType>
<xs:key name="permissionsId">
<xs:selector xpath="./permissions"/>
<xs:field xpath="@id"/>
</xs:key>
</xs:element>
</xs:schema>

18 changes: 18 additions & 0 deletions testdata/bitstreams/test.xsl
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="https://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Title</h2>
<xsl:for-each select="Example">
<a>
<xsl:attribute name="href">
<xsl:value-of select="Something"/>
</xsl:attribute>
<xsl:value-of select="anotherthing"/>
</a><p/>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Binary file added testdata/bitstreams/test.z
Binary file not shown.
Binary file modified testdata/bitstreams/test.zip
Binary file not shown.

0 comments on commit 72000b3

Please sign in to comment.