Skip to content

Commit

Permalink
models: new queries for video and project
Browse files Browse the repository at this point in the history
Signed-off-by: Ludmila Marian <ludmila.marian@gmail.com>
  • Loading branch information
ludmilamarian committed Jul 5, 2017
1 parent 1635560 commit 53778e3
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 10 deletions.
19 changes: 19 additions & 0 deletions cds_dojson/marc21/models/videos/__init__.py
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
#
# This file is part of CERN Document Server.
# Copyright (C) 2017 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""CDS models for videos."""
35 changes: 35 additions & 0 deletions cds_dojson/marc21/models/videos/project.py
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
#
# This file is part of CERN Document Server.
# Copyright (C) 2017 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

"""Video Project model."""

from ....overdo import OverdoJSONSchema
from ..base import model as cds_base


class CDSVideoProject(OverdoJSONSchema):
"""Translation Index for CDS Video Projects."""

__query__ = '970__:project -980__:DELETED'

__schema__ = 'records/videos/project/project-v1.0.0.json'


model = CDSVideoProject(bases=(cds_base, ),
entry_point_group='cds_dojson.marc21.video')
Expand Up @@ -19,14 +19,15 @@

"""Video model."""

from ...overdo import OverdoJSONSchema
from .base import model as cds_base
from ....overdo import OverdoJSONSchema
from ..base import model as cds_base


class CDSVideo(OverdoJSONSchema):
"""Translation Index for CDS Videos."""

__query__ = '980__.a:PUBLVIDEOMOVIE'
__query__ = '980__:VIDEO -980__:VIDEOARC -980__:VIDEOSHOOT \
-970__:project -980__:DELETED'

__schema__ = 'records/videos/video/video-v1.0.0.json'

Expand Down
6 changes: 4 additions & 2 deletions setup.py
Expand Up @@ -87,13 +87,15 @@
tests_require=tests_require,
entry_points={
'cds_dojson.marc21.models': [
'video = cds_dojson.marc21.models.video:model',
'video = cds_dojson.marc21.models.videos.video:model',
'video_project = cds_dojson.marc21.models.videos.project:model'
],
'cds_dojson.marc21.base': [
'base = cds_dojson.marc21.fields.base'
],
'cds_dojson.marc21.video': [
'video = cds_dojson.marc21.fields.video'
'video = cds_dojson.marc21.fields.videos.video',
'project = cds_dojson.marc21.fields.videos.project'
],
# DoJSON entry points
'console_scripts': [
Expand Down
121 changes: 121 additions & 0 deletions tests/fixtures/video.xml
@@ -0,0 +1,121 @@
<collection xmlns="http://www.loc.gov/MARC21/slim">
<record>
<controlfield tag="001">2272973</controlfield>
<controlfield tag="005">20170704112045.0</controlfield>
<datafield tag="037" ind1=" " ind2=" ">
<subfield code="a">CERN-MOVIE-2017-023-001</subfield>
</datafield>
<datafield tag="041" ind1=" " ind2=" ">
<subfield code="a">eng</subfield>
</datafield>
<datafield tag="100" ind1=" " ind2=" ">
<subfield code="a">CERN video productions</subfield>
<subfield code="e">Produced by</subfield>
</datafield>
<datafield tag="245" ind1=" " ind2=" ">
<subfield code="a">Happy 5th anniversary, Higgs boson!</subfield>
</datafield>
<datafield tag="260" ind1=" " ind2=" ">
<subfield code="c">2017</subfield>
</datafield>
<datafield tag="269" ind1=" " ind2=" ">
<subfield code="c">2017-07-04</subfield>
</datafield>
<datafield tag="300" ind1=" " ind2=" ">
<subfield code="a">00:01:09.480</subfield>
<subfield code="b">1920x1080 16/9, 25.00</subfield>
<subfield code="c">25</subfield>
<subfield code="d">1920x1080</subfield>
<subfield code="e">16:9</subfield>
</datafield>
<datafield tag="506" ind1="1" ind2=" ">
<subfield code="a"/>
</datafield>
<datafield tag="520" ind1=" " ind2=" ">
<subfield code="a">Where were you on 4 July 2012, the day in which the Higgs boson discovery was announced? Many people will be able to answer without referring to their diary. Perhaps you were among the few who had managed to secure a seat in CERN’s main auditorium, or who joined colleagues in universities and laboratories around the world at odd times of the day to watch the webcast. “I think we have it, no?” was the question posed by the then CERN Director General Rolf Heuer on 4 July in the CERN auditorium. The answer was as obvious as the emotion on faces in the crowd. The then ATLAS and CMS spokespersons, Fabiola Gianotti and Joe Incandela, had just presented the latest Higgs search results based on roughly two years of LHC operations. Given the hints for the Higgs presented a few months earlier in December 2011, the frenzy of rumours on blogs and intense media interest during the preceding weeks, and a title for the CERN seminar that left little to the imagination, the outcome was anticipated. This did not temper excitement.</subfield>
</datafield>
<datafield tag="542" ind1=" " ind2=" ">
<subfield code="d">CERN</subfield>
<subfield code="g">2017</subfield>
</datafield>
<datafield tag="653" ind1="1" ind2=" ">
<subfield code="a">higgs</subfield>
<subfield code="9">CERN</subfield>
</datafield>
<datafield tag="653" ind1="1" ind2=" ">
<subfield code="a">anniversary</subfield>
<subfield code="9">CERN</subfield>
</datafield>
<datafield tag="690" ind1="C" ind2=" ">
<subfield code="a">publvideomovie</subfield>
</datafield>
<datafield tag="700" ind1=" " ind2=" ">
<subfield code="a">CERN video productions</subfield>
<subfield code="e">Director</subfield>
</datafield>
<datafield tag="773" ind1=" " ind2=" ">
<subfield code="o">AVW.project.2963</subfield>
<subfield code="r">CERN-MOVIE-2017-023</subfield>
</datafield>
<datafield tag="856" ind1="7" ind2=" ">
<subfield code="2">MediaArchive</subfield>
<subfield code="d">\\cern.ch\dfs\Services\MediaArchive\Video\Masters\Movies\CERN\2017\CERN-MOVIE-2017-023\Final_Output\CERN-MOVIE-2017-023-001.mov</subfield>
<subfield code="x">Absolute master path</subfield>
</datafield>
<datafield tag="856" ind1="7" ind2=" ">
<subfield code="2">MediaArchive</subfield>
<subfield code="u">https://mediaarchive.cern.ch/MediaArchive/Video/Public/Movies/CERN/2017/CERN-MOVIE-2017-023/CERN-MOVIE-2017-023-001/CERN-MOVIE-2017-023-001-5872-kbps-1920x1080-audio-128-kbps-stereo.mp4</subfield>
<subfield code="x">mp45872</subfield>
<subfield code="y">5872 kbps maxH 1080 25 fps audio 128 kbps 48 kHz stereo</subfield>
</datafield>
<datafield tag="856" ind1="7" ind2=" ">
<subfield code="2">MediaArchive</subfield>
<subfield code="u">https://mediaarchive.cern.ch/MediaArchive/Video/Public/Movies/CERN/2017/CERN-MOVIE-2017-023/CERN-MOVIE-2017-023-001/CERN-MOVIE-2017-023-001-2672-kbps-1280x720-audio-128-kbps-stereo.mp4</subfield>
<subfield code="x">mp42672</subfield>
<subfield code="y">2672 kbps maxH 720 25 fps audio 128 kbps 48 kHz stereo</subfield>
</datafield>
<datafield tag="856" ind1="7" ind2=" ">
<subfield code="2">MediaArchive</subfield>
<subfield code="u">https://mediaarchive.cern.ch/MediaArchive/Video/Public/Movies/CERN/2017/CERN-MOVIE-2017-023/CERN-MOVIE-2017-023-001/CERN-MOVIE-2017-023-001-1436-kbps-853x480-audio-64-kbps-stereo.mp4</subfield>
<subfield code="x">mp41436</subfield>
<subfield code="y">1436 kbps maxH 480 25 fps audio 64 kbps 48 kHz stereo</subfield>
</datafield>
<datafield tag="856" ind1="7" ind2=" ">
<subfield code="2">MediaArchive</subfield>
<subfield code="u">https://mediaarchive.cern.ch/MediaArchive/Video/Public/Movies/CERN/2017/CERN-MOVIE-2017-023/CERN-MOVIE-2017-023-001/CERN-MOVIE-2017-023-001-836-kbps-640x360-audio-64-kbps-stereo.mp4</subfield>
<subfield code="x">mp40836</subfield>
<subfield code="y">0836 kbps maxH 360 25 fps audio 64 kbps 48 kHz stereo</subfield>
</datafield>
<datafield tag="856" ind1="7" ind2=" ">
<subfield code="2">MediaArchive</subfield>
<subfield code="u">https://mediaarchive.cern.ch/MediaArchive/Video/Public/Movies/CERN/2017/CERN-MOVIE-2017-023/CERN-MOVIE-2017-023-001/CERN-MOVIE-2017-023-001-386-kbps-426x240-audio-64-kbps-stereo.mp4</subfield>
<subfield code="x">mp40386</subfield>
<subfield code="y">0386 kbps maxH 240 15 fps audio 64 kbps 48 kHz stereo</subfield>
</datafield>
<datafield tag="856" ind1="7" ind2=" ">
<subfield code="2">MediaArchive</subfield>
<subfield code="u">https://mediaarchive.cern.ch/MediaArchive/Video/Public/Movies/CERN/2017/CERN-MOVIE-2017-023/CERN-MOVIE-2017-023-001/CERN-MOVIE-2017-023-001-posterframe-640x360-at-5-percent.jpg</subfield>
<subfield code="x">jpgposterframe</subfield>
<subfield code="y">posterframe 640x360 at 5 percent</subfield>
</datafield>
<datafield tag="859" ind1=" " ind2=" ">
<subfield code="f">Jacques.Fichet@cern.ch</subfield>
</datafield>
<datafield tag="937" ind1=" " ind2=" ">
<subfield code="c">04 Jul 2017</subfield>
<subfield code="s"/>
</datafield>
<datafield tag="960" ind1=" " ind2=" ">
<subfield code="a">85</subfield>
</datafield>
<datafield tag="970" ind1=" " ind2=" ">
<subfield code="a">AVW.clip.3447</subfield>
</datafield>
<datafield tag="980" ind1=" " ind2=" ">
<subfield code="a">PUBLVIDEOMOVIE</subfield>
</datafield>
<datafield tag="980" ind1=" " ind2=" ">
<subfield code="b">VIDEOMEDIALAB</subfield>
</datafield>
</record>
</collection>
25 changes: 20 additions & 5 deletions tests/test_matcher.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2015 CERN.
# This file is part of CERN Document Server.
# Copyright (C) 2017 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
Expand All @@ -17,16 +17,31 @@
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02D111-1307, USA.

from cds_dojson.marc21.models import video
from cds_dojson.marc21.models.videos import video
from cds_dojson.marc21.models.videos import project
from cds_dojson.matcher import matcher

from dojson.contrib import marc21 as default


def test_marc21_matcher():
"""Test CDS DoJSON matcher."""
video_blob = {'980__': {'a': 'PUBLVIDEOMOVIE'}}
video_blob1 = {'980__': [{'a': 'PUBLVIDEOMOVIE'}, {'b': 'VIDEOMEDIALAB'}]}
video_blob2 = {'980__': [{'a': 'PUBLVIDEOMOVIE'}, {'c': 'DELETED'}]}
video_blob3 = {'980__': {'a': 'VIDEOARC'}}
video_blob4 = {'980__': {'a': 'CERNVIDEOSHOOT'}}
video_blob5 = {'980__': [{'a': 'PUBLVIDEOMOVIE'}, {'b': 'VIDEOMEDIALAB'}],
'970__': {'a': 'AVW.project.1234'}}
video_blob6 = {'980__': [{'a': 'PUBLVIDEOMOVIE'}, {'c': 'DELETED'}],
'970__': {'a': 'AVW.project.1234'}}
video_blob7 = {'970__': {'a': 'FCS.project.987'}}
not_match = {'foo': 'bar'}

assert video.model == matcher(video_blob, 'cds_dojson.marc21.models')
assert video.model == matcher(video_blob1, 'cds_dojson.marc21.models')
assert default.model == matcher(video_blob2, 'cds_dojson.marc21.models')
assert default.model == matcher(video_blob3, 'cds_dojson.marc21.models')
assert default.model == matcher(video_blob4, 'cds_dojson.marc21.models')
assert project.model == matcher(video_blob5, 'cds_dojson.marc21.models')
assert default.model == matcher(video_blob6, 'cds_dojson.marc21.models')
assert project.model == matcher(video_blob7, 'cds_dojson.marc21.models')
assert default.model == matcher(not_match, 'cds_dojson.marc21.models')

0 comments on commit 53778e3

Please sign in to comment.