cul-fedora-arm 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ require 'test_helper'
2
+ require 'net/http'
3
+ require 'net/https'
4
+
5
+ class CulFedoraArmTasksTest < Test::Unit::TestCase
6
+ context "Given the 'test_config' fedora instance " do
7
+ setup do
8
+ @connector = Cul::Fedora::Connector.parse(YAML::load_file("private/fedora-config.yml"))["test_config"]
9
+ end
10
+
11
+ should "build a connector properly" do
12
+ assert_kind_of Cul::Fedora::Connector, @connector
13
+ end
14
+
15
+
16
+ context "test next pid(s) reservation task on localhost" do
17
+ setup do
18
+ @numPids = 3
19
+ @ns = "test"
20
+ @task = Cul::Fedora::Arm::Tasks::ReservePidsTask.new(@numPids,@ns)
21
+ end
22
+ should "return expected output when executed" do
23
+ assert_nothing_raised [(response = @task.post(@connector))] do
24
+ end
25
+ assert_equal @numPids, response.pid.length
26
+ response.pid.each {|p| assert_equal 0, p.index(@ns)}
27
+ end
28
+ end
29
+ context "test metadata update SOAP message generation" do
30
+ setup do
31
+ @task = Cul::Fedora::Arm::Tasks::UpdateMODSTask.new("test:13","CONTENT",METADATA_MODS_TEST)
32
+ @expectedInput = MODIFY_MODS_SOAP_MESSAGE
33
+ @expectedOutput
34
+ end
35
+ end
36
+ context "test DC metadata update against local host" do
37
+ setup do
38
+ @pid = 'ldpd:1'
39
+ @src = DateTime.new().strftime("dublincore-%Y%m%dT%H%M%S.xml")
40
+ @expectedInput = sprintf(METADATA_DC_TEST, @src)
41
+ @task = Cul::Fedora::Arm::Tasks::UpdateDCTask.new(@pid,@expectedInput)
42
+ end
43
+ should "match expected SOAP output" do
44
+ assert_nothing_raised [(response = @task.post(@connector))] do
45
+ end
46
+ modifiedDate = DateTime.parse(response.modifiedDate)
47
+ now = DateTime.new()
48
+ diff = now - modifiedDate
49
+ assert diff < 2 # assert that the update time was within a couple of seconds
50
+ end
51
+ should "have updated the datastream correctly" do
52
+ @connector.rest_interface do |http|
53
+ response = http.get("/fedora/get/#{@pid}/DC")
54
+ assert response.body.rindex("<dc:source>#{@src}</dc:source>")
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,117 @@
1
+ require 'test_helper'
2
+ class CulFedoraImageTest < Test::Unit::TestCase
3
+ include Cul::Fedora::Image
4
+ TEST = 'test'
5
+ CASE1 = "#{TEST}/fixtures/case1"
6
+ CASE2 = "#{TEST}/fixtures/case2"
7
+ CASE3 = "#{TEST}/fixtures/case3"
8
+ def initialize(test_method_name)
9
+ super(test_method_name)
10
+ end
11
+ context "image library given a bitmap" do
12
+ setup do
13
+ @src = "#{CASE3}/test001.bmp"
14
+ @expected = {}
15
+ @expected[:width] = 373
16
+ @expected[:length] = 156
17
+ @expected[:size] = 174858
18
+ @expected[:mime] = 'image/bmp'
19
+ @expected[:sampling_unit] = :cm
20
+ @expected[:x_sampling] = 29
21
+ @expected[:y_sampling] = 29
22
+ @expected
23
+ # @expected[:bitdepth] = 24
24
+ end
25
+ should "correctly identify properties" do
26
+ actual = analyze_image(@src)
27
+ actual
28
+ assert_equal @expected, actual
29
+ end
30
+ teardown do
31
+
32
+ end
33
+ end
34
+ context "image library given a PNG" do
35
+ setup do
36
+ @src = "#{CASE3}/test001.png"
37
+ @expected = {}
38
+ @expected[:width] = 512
39
+ @expected[:length] = 512
40
+ @expected[:size] = 675412
41
+ @expected
42
+ # @expected[:bitdepth] = 32
43
+ end
44
+ should "correctly identify properties" do
45
+ actual = analyze_image(@src,true)
46
+ actual
47
+ assert_equal @expected, actual
48
+ end
49
+ teardown do
50
+
51
+ end
52
+ end
53
+ context "image library given a JPEG" do
54
+ setup do
55
+ @src = "#{CASE3}/test001.jpg"
56
+ @expected = {}
57
+ @expected[:width] = 313
58
+ @expected[:length] = 234
59
+ @expected[:x_sampling] = 72
60
+ @expected[:y_sampling] = 72
61
+ @expected[:size] = 15138
62
+ @expected[:mime] = 'image/jpeg'
63
+ @expected
64
+ end
65
+ should "correctly identify properties" do
66
+ actual = analyze_image(@src,false)
67
+ actual
68
+ assert_equal @expected, actual
69
+ end
70
+ teardown do
71
+
72
+ end
73
+ end
74
+ context "image library given a GIF" do
75
+ setup do
76
+ @src = "#{CASE3}/test001.gif"
77
+ @expected = {}
78
+ @expected[:width] = 492
79
+ @expected[:length] = 1392
80
+ @expected[:size] = 474706
81
+ @expected[:mime] = 'image/gif'
82
+ @expected
83
+ end
84
+ should "correctly identify properties" do
85
+ actual = analyze_image(@src)
86
+ actual
87
+ assert_equal @expected, actual
88
+ end
89
+ teardown do
90
+
91
+ end
92
+ end
93
+ context "image library given a TIFF" do
94
+ setup do
95
+ @src = "#{CASE3}/test001.tiff"
96
+ @expected = {}
97
+ @expected[:width] = 2085
98
+ @expected[:length] = 1470
99
+ @expected[:size] = 5658702
100
+ @expected[:x_sampling] = 600
101
+ @expected[:y_sampling] = 600
102
+ @expected[:mime] = 'image/tiff'
103
+ @expected[:sampling_unit] = :inch
104
+ @expected
105
+ # @expected['compression'] = LSW
106
+ # @expected[:bitdepth] = 24
107
+ end
108
+ should "correctly identify properties" do
109
+ actual = analyze_image(@src)
110
+ actual
111
+ assert_equal @expected, actual
112
+ end
113
+ teardown do
114
+
115
+ end
116
+ end
117
+ end
data/test/factories.rb ADDED
@@ -0,0 +1 @@
1
+ require "cul-fedora-arm"
@@ -0,0 +1,6 @@
1
+ 0 collection:1;ac:5 Aggregator Content InteractiveResource AC:P:5001 insert license:by-nc-nd
2
+ 1 0 Resource /01-Northover_IPD_SovDebt_Working_Paper.pdf Text insert license:by-nc-nd
3
+ 2 0 Metadata /test-0001.xml MODS Text insert license:by-nc-nd
4
+ 4 collection:1;ac:5 Aggregator Content InteractiveResource AC:P:5002 insert license:by-nc-nd
5
+ 6 4 Metadata /test-0002.xml MODS Text insert license:by-nc-nd
6
+ 7 4 Resource /02-851.pdf Text insert license:by-nc-nd
@@ -0,0 +1,7 @@
1
+ sequence target model_type source template_type dc_format id pid action license
2
+ 0 collection:1;ac:5 Aggregator Content InteractiveResource AC:P:5001 insert license:by-nc-nd
3
+ 1 0 Resource /01-Northover_IPD_SovDebt_Working_Paper.pdf Text insert license:by-nc-nd
4
+ 2 0 Metadata /test-0001.xml MODS Text insert license:by-nc-nd
5
+ 4 collection:1;ac:5 Aggregator Content InteractiveResource AC:P:5002 insert license:by-nc-nd
6
+ 6 4 Metadata /test-0002.xml MODS Text insert license:by-nc-nd
7
+ 7 4 Resource /02-851.pdf Text insert license:by-nc-nd
@@ -0,0 +1,3 @@
1
+ sequence target model_type source template_type dc_format id pid action license
2
+ 0 collection:1;ac:5 Aggregator Content InteractiveResource AC:P:5001 insert license:by-nc-nd
3
+ 1 collection:1;ac:5 Aggregator StaticImage Image jay.columbia.1 insert license:by-nc-nd
@@ -0,0 +1,2 @@
1
+ sequence target model_type source template_type dc_format id pid action license
2
+ 0 test:1 Resource #{CASE3}/test001.jpg Image Image insert license:by-nc-nd
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ sequence target model_type source template_type dc_format id pid action license
2
+ 0 test:1 Metadata #{CASE4}/test-mods.xml MODS Text insert license:by-nc-nd
@@ -0,0 +1,6 @@
1
+ <mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
2
+ <identifier type="local">test.identifier.1</identifier>
3
+ <titleInfo displayLabel="Supplied title">
4
+ <title>test record title</title>
5
+ </titleInfo>
6
+ </mods>
@@ -0,0 +1,38 @@
1
+ require 'base64'
2
+
3
+ METADATA_MODS_TEST = <<METADATA
4
+ <mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd">
5
+ <identifier type="local">test.identifier.1</identifier>
6
+ <titleInfo displayLabel="Supplied title">
7
+ <title>%s</title>
8
+ </titleInfo>
9
+ </mods>
10
+ METADATA
11
+ # >>
12
+
13
+ METADATA_DC_TEST = <<METADATA
14
+ <oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" >
15
+ <dc:title>Test Input Data</dc:title>
16
+ <dc:creator>BATCH</dc:creator>
17
+ <dc:type>Text</dc:type>
18
+ <dc:format>text/xml</dc:format>
19
+ <dc:publisher>Columbia University Libraries</dc:publisher>
20
+ <dc:identifier>test.identifier.1</dc:identifier>
21
+ <dc:source>%s</dc:source>
22
+ </oai_dc:dc>
23
+ METADATA
24
+ # >>
25
+
26
+ NEXT_PIDS_SOAP_MESSAGE = <<NEXT_PID
27
+ <?xml version="1.0" encoding="utf-8"?>
28
+ <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
29
+ <soap:Body>
30
+ <getNextPID xmlns="http://www.fedora.info/definitions/1/0/api/">
31
+ <numPIDs>13</numPIDs>
32
+ <pidNamespace>test</pidNamespace>
33
+ </getNextPID>
34
+ </soap:Body>
35
+ </soap:Envelope>
36
+ NEXT_PID
37
+ # >>
38
+
@@ -0,0 +1,4 @@
1
+
2
+ def template_builder(*lines_of_elements)
3
+ lines_of_elements.collect { |l| l.join("\t")}.join("\r\n")
4
+ end
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'factory_girl'
5
+ require 'activesupport'
6
+ require 'helpers/soap_inputs'
7
+ require 'helpers/template_builder'
8
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
9
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
10
+ $LOAD_PATH.unshift('./lib')
11
+ $LOAD_PATH.unshift('./test')
12
+
13
+ require 'cul-fedora-arm'
14
+ require 'cul/fedora/image/image'
15
+ class ActiveSupport::TestCase
16
+ end
17
+
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cul-fedora-arm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
+ platform: ruby
6
+ authors:
7
+ - James Stuart
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-21 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thoughtbot-shoulda
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: thoughtbot-factory_girl
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: activesupport
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: ruby-fedora
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ description: Tools for dealing with Cul ARM specification
56
+ email: tastyhat@jamesstuart.org
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - LICENSE
63
+ - README.rdoc
64
+ files:
65
+ - .buildpath
66
+ - .document
67
+ - .gitignore
68
+ - .loadpath
69
+ - .project
70
+ - LICENSE
71
+ - README.rdoc
72
+ - Rakefile
73
+ - VERSION
74
+ - cul-fedora-arm.gemspec
75
+ - lib/cul-fedora-arm.rb
76
+ - lib/cul/fedora/.rb
77
+ - lib/cul/fedora/arm/builder.rb
78
+ - lib/cul/fedora/arm/foxml_builder.rb
79
+ - lib/cul/fedora/arm/tasks.rb
80
+ - lib/cul/fedora/connector.rb
81
+ - lib/cul/fedora/image/image.rb
82
+ - test/cul_fedora_arm_builder_test.rb
83
+ - test/cul_fedora_arm_tasks_test.rb
84
+ - test/cul_fedora_image_test.rb
85
+ - test/factories.rb
86
+ - test/fixtures/case1/builder-template-noheader.txt
87
+ - test/fixtures/case1/builder-template.txt
88
+ - test/fixtures/case2/builder-template.txt
89
+ - test/fixtures/case3/builder-template.txt
90
+ - test/fixtures/case3/test001.bmp
91
+ - test/fixtures/case3/test001.gif
92
+ - test/fixtures/case3/test001.jpg
93
+ - test/fixtures/case3/test001.png
94
+ - test/fixtures/case3/test001.tiff
95
+ - test/fixtures/case4/builder-template.txt
96
+ - test/fixtures/case4/test-mods.xml
97
+ - test/helpers/soap_inputs.rb
98
+ - test/helpers/template_builder.rb
99
+ - test/test_helper.rb
100
+ has_rdoc: true
101
+ homepage: http://github.com/tastyhat/cul-fedora-arm
102
+ licenses: []
103
+
104
+ post_install_message:
105
+ rdoc_options:
106
+ - --charset=UTF-8
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ version:
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: "0"
120
+ version:
121
+ requirements: []
122
+
123
+ rubyforge_project:
124
+ rubygems_version: 1.3.5
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: Tools for dealing with Cul ARM specification
128
+ test_files:
129
+ - test/cul_fedora_arm_builder_test.rb
130
+ - test/cul_fedora_arm_tasks_test.rb
131
+ - test/cul_fedora_image_test.rb
132
+ - test/factories.rb
133
+ - test/helpers/soap_inputs.rb
134
+ - test/helpers/template_builder.rb
135
+ - test/test_helper.rb