puree 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +11 -0
  4. data/lib/puree/extractor/dataset.rb +7 -5
  5. data/lib/puree/extractor/event.rb +7 -5
  6. data/lib/puree/extractor/external_organisation.rb +7 -5
  7. data/lib/puree/extractor/journal.rb +7 -5
  8. data/lib/puree/extractor/journal_article.rb +3 -2
  9. data/lib/puree/extractor/organisational_unit.rb +7 -5
  10. data/lib/puree/extractor/person.rb +7 -5
  11. data/lib/puree/extractor/project.rb +7 -5
  12. data/lib/puree/extractor/publisher.rb +7 -5
  13. data/lib/puree/extractor/research_output.rb +10 -6
  14. data/lib/puree/extractor/resource.rb +8 -5
  15. data/lib/puree/model/file.rb +1 -1
  16. data/lib/puree/model/journal_article.rb +3 -3
  17. data/lib/puree/model/paper.rb +1 -1
  18. data/lib/puree/model/research_output.rb +1 -1
  19. data/lib/puree/model/research_output_scopus_metric.rb +4 -4
  20. data/lib/puree/model/thesis.rb +1 -1
  21. data/lib/puree/rest/base.rb +26 -2
  22. data/lib/puree/version.rb +1 -1
  23. data/lib/puree/xml_extractor/collection.rb +2 -0
  24. data/lib/puree/xml_extractor/journal_article.rb +2 -2
  25. data/lib/puree/xml_extractor/mixins/pages_mixin.rb +1 -1
  26. data/lib/puree/xml_extractor/research_output.rb +1 -1
  27. data/test/extractor/resource_count_test.rb +9 -9
  28. data/test/integration/research_output_types_test.rb +56 -0
  29. data/test/rest/base_test.rb +29 -2
  30. data/test/rest/common_test.rb +15 -0
  31. data/test/test_helper.rb +1 -1
  32. data/test/xml_extractor/xml_extractor_conference_paper_test.rb +1 -1
  33. data/test/xml_extractor/xml_extractor_journal_article_test.rb +3 -3
  34. data/test/xml_extractor/xml_extractor_research_output_test.rb +1 -1
  35. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: be040161fa2a4bfb0252b864310d90d56e88ac19
4
- data.tar.gz: 1b6437a55b0e4d08da2dd59af0bb5b68278d770e
2
+ SHA256:
3
+ metadata.gz: dd7631adf7f39b6d041f3ae46b0b6648b6220a37d74313c86293df1a6b2b938f
4
+ data.tar.gz: b19e093582fb9e14d2c0bad8898c6c63a9cc3afc501282566194e23b1d12e0a7
5
5
  SHA512:
6
- metadata.gz: 8ffe42bacb00c82a8fc81c2c70fec93a30d2cfd01e171d1999b18d878741f91a6ba02769ed079e11c3af0858e84fc9cedf135923e4df2d00af8fcc00c10bd11f
7
- data.tar.gz: bca33fed3f5467ed1c62153c2100eb26cb3252f427e66b140934fb38648b449d45dc03da742247048bc6beffc2ea85f1dafb2c3f9e943e0ae27aa26a53242b32
6
+ metadata.gz: '09784067f174ca5f1e310d35c6bbe7132148bc64b13623c12ed94920a5f8c934b7de19992ef117efbfbdea00803f3b19786675c7784ee1bb521d02a00ed9d50c'
7
+ data.tar.gz: 9a2a672ae92da3c02ccba9dd92010b7d865d8792f2e2bb2218dd85ebe3b2cfda7215e4207fc530921b4035bb169e828550d690d9a8a1f2270f7aa78360e4ad14
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ### 2.3.0 2018-10-09
6
+ ### Added
7
+ - POST for REST module.
8
+ - Count and random in extractor extended with GET and POST parameters.
9
+
10
+ ### Fixed
11
+ - Subcollection url building.
12
+
5
13
  ## 2.2.0 2018-04-20
6
14
  ### Added
7
15
  - Count, random for resource extractors.
data/README.md CHANGED
@@ -156,6 +156,17 @@ client.persons.all params: {size: 5}, accept: :json
156
156
  #=> #<HTTP::Response:0x00c0ffee>
157
157
  ```
158
158
 
159
+ ```ruby
160
+ # Find three active academics
161
+ params = {
162
+ size: 3,
163
+ employmentTypeUri: ['/dk/atira/pure/person/employmenttypes/academic'],
164
+ employmentStatus: 'ACTIVE'
165
+ }
166
+ client.persons.all_complex params: params
167
+ #=> #<HTTP::Response:0x00c0ffee>
168
+ ```
169
+
159
170
  ```ruby
160
171
  # Find research outputs for a person
161
172
  client.persons.research_outputs id: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
@@ -16,16 +16,18 @@ module Puree
16
16
 
17
17
  # Count of records available.
18
18
  #
19
- # @return [Fixnum]
20
- def count
21
- record_count :dataset
19
+ # @param params [Hash] Combined GET and POST parameters for all records
20
+ # @return [Integer]
21
+ def count(params = {})
22
+ record_count :dataset, params
22
23
  end
23
24
 
24
25
  # Random record.
25
26
  #
27
+ # @param params [Hash] Combined GET and POST parameters for all records
26
28
  # @return [Puree::Model::Dataset, nil]
27
- def random
28
- super :dataset
29
+ def random(params = {})
30
+ super :dataset, params
29
31
  end
30
32
 
31
33
  end
@@ -16,16 +16,18 @@ module Puree
16
16
 
17
17
  # Count of records available.
18
18
  #
19
- # @return [Fixnum]
20
- def count
21
- record_count :event
19
+ # @param params [Hash] Combined GET and POST parameters for all records
20
+ # @return [Integer]
21
+ def count(params = {})
22
+ record_count :event, params
22
23
  end
23
24
 
24
25
  # Random record.
25
26
  #
27
+ # @param params [Hash] Combined GET and POST parameters for all records
26
28
  # @return [Puree::Model::Event, nil]
27
- def random
28
- super :event
29
+ def random(params = {})
30
+ super :event, params
29
31
  end
30
32
 
31
33
  end
@@ -16,16 +16,18 @@ module Puree
16
16
 
17
17
  # Count of records available.
18
18
  #
19
- # @return [Fixnum]
20
- def count
21
- record_count :external_organisation
19
+ # @param params [Hash] Combined GET and POST parameters for all records
20
+ # @return [Integer]
21
+ def count(params = {})
22
+ record_count :external_organisation, params
22
23
  end
23
24
 
24
25
  # Random record.
25
26
  #
27
+ # @param params [Hash] Combined GET and POST parameters for all records
26
28
  # @return [Puree::Model::ExternalOrganisation, nil]
27
- def random
28
- super :external_organisation
29
+ def random(params = {})
30
+ super :external_organisation, params
29
31
  end
30
32
 
31
33
  end
@@ -16,16 +16,18 @@ module Puree
16
16
 
17
17
  # Count of records available.
18
18
  #
19
- # @return [Fixnum]
20
- def count
21
- record_count :journal
19
+ # @param params [Hash] Combined GET and POST parameters for all records
20
+ # @return [Integer]
21
+ def count(params = {})
22
+ record_count :journal, params
22
23
  end
23
24
 
24
25
  # Random record.
25
26
  #
27
+ # @param params [Hash] Combined GET and POST parameters for all records
26
28
  # @return [Puree::Model::Journal, nil]
27
- def random
28
- super :journal
29
+ def random(params = {})
30
+ super :journal, params
29
31
  end
30
32
 
31
33
  end
@@ -15,9 +15,10 @@ module Puree
15
15
 
16
16
  # Random record.
17
17
  #
18
+ # @param params [Hash] Combined GET and POST parameters for all records
18
19
  # @return [Puree::Model::JournalArticle, nil]
19
- def random
20
- record_count :journal_article
20
+ def random(params = {})
21
+ record_count :journal_article, params
21
22
  end
22
23
 
23
24
  end
@@ -16,16 +16,18 @@ module Puree
16
16
 
17
17
  # Count of records available.
18
18
  #
19
- # @return [Fixnum]
20
- def count
21
- record_count :organisational_unit
19
+ # @param params [Hash] Combined GET and POST parameters for all records
20
+ # @return [Integer]
21
+ def count(params = {})
22
+ record_count :organisational_unit, params
22
23
  end
23
24
 
24
25
  # Random record.
25
26
  #
27
+ # @param params [Hash] Combined GET and POST parameters for all records
26
28
  # @return [Puree::Model::OrganisationalUnit, nil]
27
- def random
28
- super :organisational_unit
29
+ def random(params = {})
30
+ super :organisational_unit, params
29
31
  end
30
32
 
31
33
  end
@@ -16,16 +16,18 @@ module Puree
16
16
 
17
17
  # Count of records available.
18
18
  #
19
- # @return [Fixnum]
20
- def count
21
- record_count :person
19
+ # @param params [Hash] Combined GET and POST parameters for all records
20
+ # @return [Integer]
21
+ def count(params = {})
22
+ record_count :person, params
22
23
  end
23
24
 
24
25
  # Random record.
25
26
  #
27
+ # @param params [Hash] Combined GET and POST parameters for all records
26
28
  # @return [Puree::Model::Person, nil]
27
- def random
28
- super :person
29
+ def random(params = {})
30
+ super :person, params
29
31
  end
30
32
 
31
33
  end
@@ -16,16 +16,18 @@ module Puree
16
16
 
17
17
  # Count of records available.
18
18
  #
19
- # @return [Fixnum]
20
- def count
21
- record_count :project
19
+ # @param params [Hash] Combined GET and POST parameters for all records
20
+ # @return [Integer]
21
+ def count(params = {})
22
+ record_count :project, params
22
23
  end
23
24
 
24
25
  # Random record.
25
26
  #
27
+ # @param params [Hash] Combined GET and POST parameters for all records
26
28
  # @return [Puree::Model::Project, nil]
27
- def random
28
- super :project
29
+ def random(params = {})
30
+ super :project, params
29
31
  end
30
32
 
31
33
  end
@@ -16,16 +16,18 @@ module Puree
16
16
 
17
17
  # Count of records available.
18
18
  #
19
- # @return [Fixnum]
20
- def count
21
- record_count :publisher
19
+ # @param params [Hash] Combined GET and POST parameters for all records
20
+ # @return [Integer]
21
+ def count(params = {})
22
+ record_count :publisher, params
22
23
  end
23
24
 
24
25
  # Random record.
25
26
  #
27
+ # @param params [Hash] Combined GET and POST parameters for all records
26
28
  # @return [Puree::Model::Publisher, nil]
27
- def random
28
- super :publisher
29
+ def random(params = {})
30
+ super :publisher, params
29
31
  end
30
32
 
31
33
  end
@@ -16,18 +16,22 @@ module Puree
16
16
 
17
17
  # Count of records available.
18
18
  #
19
- # @return [Fixnum]
20
- def count
21
- record_count :research_output
19
+ # @param params [Hash] Combined GET and POST parameters for all records
20
+ # @return [Integer]
21
+ def count(params = {})
22
+ record_count :research_output, params
22
23
  end
23
24
 
24
25
  # Random record. Includes the metadata from Puree::Model::ResearchOutput as a minimum.
25
26
  #
27
+ # @param params [Hash] Combined GET and POST parameters for all records
26
28
  # @return [Puree::Model::ResearchOutput or subclass, nil]
27
- def random
29
+ def random(params = {})
28
30
  client = Puree::REST::Client.new @config
29
- offset = rand(0..count-1)
30
- response = client.research_outputs.all params: {size: 1, offset: offset}
31
+ offset = rand(0..count(params)-1)
32
+ params[:size] = 1
33
+ params[:offset] = offset
34
+ response = client.research_outputs.all_complex params: params
31
35
  research_outputs_hash = Puree::XMLExtractor::Collection.research_outputs response.to_s
32
36
  research_outputs_array = []
33
37
  research_outputs_hash.each do |k, v|
@@ -38,17 +38,20 @@ module Puree
38
38
  Object.const_get(resource_class).new xml
39
39
  end
40
40
 
41
- def record_count(api_resource_type)
41
+ def record_count(api_resource_type, params = {})
42
42
  api_resource = make_api_resource api_resource_type
43
- response = api_resource.all params: {size: 0}
43
+ params[:size] = 0
44
+ response = api_resource.all_complex params: params
44
45
  return unless response.code === 200
45
46
  Puree::XMLExtractor::Collection.count response.to_s
46
47
  end
47
48
 
48
- def random(api_resource_type)
49
- offset = rand(0..record_count(api_resource_type)-1)
49
+ def random(api_resource_type, params = {})
50
+ offset = rand(0..record_count(api_resource_type, params)-1)
50
51
  api_resource = make_api_resource api_resource_type
51
- response = api_resource.all params: {size: 1, offset: offset}
52
+ params[:size] = 1
53
+ params[:offset] = offset
54
+ response = api_resource.all_complex params: params
52
55
  models = Puree::XMLExtractor::Collection.send "#{api_resource_type}s", response.to_s
53
56
  return nil if models.empty?
54
57
  models[0]
@@ -11,7 +11,7 @@ module Puree
11
11
  # @return [String, nil]
12
12
  attr_reader :mime
13
13
 
14
- # @return [Fixnum, nil]
14
+ # @return [Integer, nil]
15
15
  attr_accessor :size
16
16
 
17
17
  # @return [String, nil]
@@ -8,10 +8,10 @@ module Puree
8
8
  # @return [Puree::Model::JournalHeader, nil]
9
9
  attr_accessor :journal
10
10
 
11
- # @return [Fixnum, nil]
11
+ # @return [Integer, nil]
12
12
  attr_accessor :issue
13
13
 
14
- # @return [Fixnum, nil]
14
+ # @return [Integer, nil]
15
15
  attr_accessor :pages
16
16
 
17
17
  # @return [String, nil]
@@ -20,7 +20,7 @@ module Puree
20
20
  # @return [Boolean, nil]
21
21
  attr_accessor :peer_reviewed
22
22
 
23
- # @return [Fixnum, nil]
23
+ # @return [Integer, nil]
24
24
  attr_accessor :volume
25
25
 
26
26
  end
@@ -5,7 +5,7 @@ module Puree
5
5
  #
6
6
  class Paper < Puree::Model::ResearchOutput
7
7
 
8
- # @return [Fixnum, nil]
8
+ # @return [Integer, nil]
9
9
  attr_accessor :pages
10
10
 
11
11
  # @return [String, nil]
@@ -60,7 +60,7 @@ module Puree
60
60
  # @return [Array<Puree::Model::RelatedContentHeader>]
61
61
  attr_accessor :research_outputs
62
62
 
63
- # @return [Fixnum, nil]
63
+ # @return [Integer, nil]
64
64
  attr_accessor :scopus_citations_count
65
65
 
66
66
  # @return [String, nil]
@@ -5,18 +5,18 @@ module Puree
5
5
  #
6
6
  class ResearchOutputScopusMetric < Puree::Model::Structure
7
7
 
8
- # @return [Fixnum, nil]
8
+ # @return [Integer, nil]
9
9
  attr_reader :value
10
10
 
11
- # @return [Fixnum, nil]
11
+ # @return [Integer, nil]
12
12
  attr_reader :year
13
13
 
14
- # @param v [Fixnum]
14
+ # @param v [Integer]
15
15
  def value=(v)
16
16
  @value = v if v && !v.empty?
17
17
  end
18
18
 
19
- # @param v [Fixnum]
19
+ # @param v [Integer]
20
20
  def year=(v)
21
21
  @year = v if v && !v.empty?
22
22
  end
@@ -14,7 +14,7 @@ module Puree
14
14
  # @return [String, nil]
15
15
  attr_accessor :doi
16
16
 
17
- # @return [Fixnum, nil]
17
+ # @return [Integer, nil]
18
18
  attr_accessor :pages
19
19
 
20
20
  # @return [Puree::Model::PublisherHeader, nil]
@@ -25,7 +25,15 @@ module Puree
25
25
  @url = config[:url]
26
26
  end
27
27
 
28
- # @param params [Hash]
28
+ # @param params [Hash] Combined GET and POST parameters for all records
29
+ # @param accept [Symbol]
30
+ # @return [HTTP::Response]
31
+ def all_complex(params: {}, accept: :xml)
32
+ post_request_collection params: params,
33
+ accept: accept
34
+ end
35
+
36
+ # @param params [Hash] GET parameters for all records
29
37
  # @param accept [Symbol]
30
38
  # @return [HTTP::Response]
31
39
  def all(params: {}, accept: :xml)
@@ -68,6 +76,15 @@ module Puree
68
76
  end
69
77
  end
70
78
 
79
+ def content_type_header(content_type)
80
+ case content_type
81
+ when :json
82
+ return { 'Content-Type' => 'application/json' }
83
+ when :xml
84
+ return { 'Content-Type' => 'application/xml' }
85
+ end
86
+ end
87
+
71
88
  def api_key_header(key)
72
89
  msg = 'API key incomplete in configuration'
73
90
  raise msg if !key
@@ -94,6 +111,13 @@ module Puree
94
111
  File.join "#{url_collection}-meta", type
95
112
  end
96
113
 
114
+ # @return (see Puree::REST::Base#all_complex)
115
+ def post_request_collection(params: {}, accept: :xml)
116
+ @http_client = @http_client.headers(accept_header(accept))
117
+ @http_client = @http_client.headers(content_type_header(:json))
118
+ @http_client.post url_collection, json: params
119
+ end
120
+
97
121
  # @return (see Puree::REST::Base#all)
98
122
  def get_request_collection(params: {}, accept: :xml)
99
123
  @http_client = @http_client.headers(accept_header(accept))
@@ -103,7 +127,7 @@ module Puree
103
127
  # @return (see Puree::REST::Base#all)
104
128
  def get_request_collection_subcollection(subcollection:, params: {}, accept: :xml)
105
129
  @http_client = @http_client.headers(accept_header(accept))
106
- @http_client.get meta(url_collection_subcollection(subcollection)), params: params
130
+ @http_client.get url_collection_subcollection(subcollection), params: params
107
131
  end
108
132
 
109
133
  # @return (see Puree::REST::Base#all)
data/lib/puree/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Puree
2
2
  # Semantic version number
3
3
  #
4
- VERSION = "2.2.0"
4
+ VERSION = "2.3.0"
5
5
  end
@@ -110,6 +110,8 @@ module Puree
110
110
  data
111
111
  end
112
112
 
113
+ # Records available for a resource
114
+ #
113
115
  def self.count(xml)
114
116
  doc = Nokogiri::XML xml
115
117
  doc.remove_namespaces!
@@ -13,7 +13,7 @@ module Puree
13
13
  setup_model :journal_article
14
14
  end
15
15
 
16
- # @return [Fixnum, nil]
16
+ # @return [Integer, nil]
17
17
  def issue
18
18
  xpath_result = xpath_query_for_single_value('/journalNumber')
19
19
  xpath_result ? xpath_result.to_i : nil
@@ -32,7 +32,7 @@ module Puree
32
32
  end
33
33
  end
34
34
 
35
- # @return [Fixnum, nil]
35
+ # @return [Integer, nil]
36
36
  def volume
37
37
  xpath_result = xpath_query_for_single_value('/volume')
38
38
  xpath_result ? xpath_result.to_i : nil
@@ -6,7 +6,7 @@ module Puree
6
6
  #
7
7
  module PagesMixin
8
8
 
9
- # @return [Fixnum, nil]
9
+ # @return [Integer, nil]
10
10
  def pages
11
11
  xpath_result = xpath_query_for_single_value('/numberOfPages')
12
12
  xpath_result ? xpath_result.to_i : nil
@@ -114,7 +114,7 @@ module Puree
114
114
  data.uniq { |d| d.stage }
115
115
  end
116
116
 
117
- # @return [Fixnum, nil]
117
+ # @return [Integer, nil]
118
118
  def scopus_citations_count
119
119
  xpath_result = xpath_query_for_single_value '/totalScopusCitations'
120
120
  xpath_result ? xpath_result.to_i : nil
@@ -6,63 +6,63 @@ class TestResourceCount < Minitest::Test
6
6
  extractor = Puree::Extractor::Dataset.new config
7
7
  count = extractor.count
8
8
 
9
- assert_instance_of Fixnum, count
9
+ assert_instance_of Integer, count
10
10
  end
11
11
 
12
12
  def test_external_organisation_count
13
13
  extractor = Puree::Extractor::ExternalOrganisation.new config
14
14
  count = extractor.count
15
15
 
16
- assert_instance_of Fixnum, count
16
+ assert_instance_of Integer, count
17
17
  end
18
18
 
19
19
  def test_event_count
20
20
  extractor = Puree::Extractor::Event.new config
21
21
  count = extractor.count
22
22
 
23
- assert_instance_of Fixnum, count
23
+ assert_instance_of Integer, count
24
24
  end
25
25
 
26
26
  def test_journal_count
27
27
  extractor = Puree::Extractor::Journal.new config
28
28
  count = extractor.count
29
29
 
30
- assert_instance_of Fixnum, count
30
+ assert_instance_of Integer, count
31
31
  end
32
32
 
33
33
  def test_organisational_unit_count
34
34
  extractor = Puree::Extractor::OrganisationalUnit.new config
35
35
  count = extractor.count
36
36
 
37
- assert_instance_of Fixnum, count
37
+ assert_instance_of Integer, count
38
38
  end
39
39
 
40
40
  def test_person_count
41
41
  extractor = Puree::Extractor::Person.new config
42
42
  count = extractor.count
43
43
 
44
- assert_instance_of Fixnum, count
44
+ assert_instance_of Integer, count
45
45
  end
46
46
 
47
47
  def test_project_count
48
48
  extractor = Puree::Extractor::Project.new config
49
49
  count = extractor.count
50
50
 
51
- assert_instance_of Fixnum, count
51
+ assert_instance_of Integer, count
52
52
  end
53
53
 
54
54
  def test_publisher_count
55
55
  extractor = Puree::Extractor::Publisher.new config
56
56
  count = extractor.count
57
57
 
58
- assert_instance_of Fixnum, count
58
+ assert_instance_of Integer, count
59
59
  end
60
60
 
61
61
  def test_research_output_count
62
62
  extractor = Puree::Extractor::ResearchOutput.new config
63
63
  count = extractor.count
64
64
 
65
- assert_instance_of Fixnum, count
65
+ assert_instance_of Integer, count
66
66
  end
67
67
 
68
68
  end
@@ -0,0 +1,56 @@
1
+ require 'test_rest_helper'
2
+
3
+ class TestResearchOutputTypes < Minitest::Test
4
+
5
+ def types
6
+ [
7
+ {
8
+ uri: '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontojournal/article',
9
+ text: 'Journal article',
10
+ xml_extractor_key: :journal_articles
11
+ },
12
+ {
13
+ uri: '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontoconference/paper',
14
+ text: 'Conference paper',
15
+ xml_extractor_key: :conference_papers
16
+ }
17
+ ]
18
+ end
19
+
20
+ def test_types
21
+ size = 10
22
+
23
+ types.each do |type|
24
+ params = {
25
+ size: size,
26
+ typeUri: [type[:uri]]
27
+ }
28
+ response = client.research_outputs.all_complex params: params
29
+ # puts response
30
+
31
+ assert_equal response.code, 200
32
+ assert_instance_of HTTP::Response, response
33
+
34
+ typed_model_hash = Puree::XMLExtractor::Collection.research_outputs response.to_s
35
+ type_key = type[:xml_extractor_key]
36
+
37
+ # Number of models should not be more than expected for specific type
38
+ assert typed_model_hash[type_key].size <= size
39
+
40
+ # Number of models should not be more than expected across all types
41
+ model_total = 0
42
+ typed_model_hash.each do |k, v|
43
+ model_total += v.size
44
+ end
45
+ assert model_total <= size
46
+
47
+ # Model placed in correct hash key
48
+ typed_model_hash.each do |k, v|
49
+ v.each do |model|
50
+ assert_equal type[:text], model.type
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ end
@@ -7,12 +7,35 @@ class TestResourceBase < Minitest::Test
7
7
  assert_instance_of Puree::REST::Base, base
8
8
  end
9
9
 
10
- # Private get_request_X methods (used by all resources) tested via Client
10
+ # Private request methods (used by all resources) tested via Client
11
11
  # public interface. Exemplar resource is Person.
12
+ #
13
+ def test_post_request_collection
14
+ params = {
15
+ size: 3,
16
+ employmentTypeUri: ['/dk/atira/pure/person/employmenttypes/academic'],
17
+ employmentStatus: 'ACTIVE'
18
+ }
19
+ response = client.persons.all_complex params: params
20
+ # puts response
21
+ assert_equal response.code, 200
22
+ assert_instance_of HTTP::Response, response
23
+ end
24
+
25
+ def test_collection_count
26
+ params = {
27
+ employmentTypeUri: ['/dk/atira/pure/person/employmenttypes/academic'],
28
+ employmentStatus: 'ACTIVE'
29
+ }
30
+ extractor = Puree::Extractor::Person.new config
31
+ count = extractor.count(params)
32
+ assert_instance_of Integer, count
33
+ end
12
34
 
13
35
  def test_get_request_collection
14
- response = client.persons.all
36
+ response = client.persons.all params: {size: 5}, accept: :json
15
37
  # puts response
38
+ assert_equal response.code, 200
16
39
  assert_instance_of HTTP::Response, response
17
40
  end
18
41
 
@@ -20,18 +43,21 @@ class TestResourceBase < Minitest::Test
20
43
  uuid = random_singleton_uuid :person
21
44
  response = client.persons.find id: uuid
22
45
  # puts response
46
+ assert_equal response.code, 200
23
47
  assert_instance_of HTTP::Response, response
24
48
  end
25
49
 
26
50
  def test_get_request_meta
27
51
  response = client.persons.renderings
28
52
  # puts response
53
+ assert_equal response.code, 200
29
54
  assert_instance_of HTTP::Response, response
30
55
  end
31
56
 
32
57
  def test_get_request_collection_subcollection
33
58
  response = client.persons.active
34
59
  # puts response
60
+ assert_equal response.code, 200
35
61
  assert_instance_of HTTP::Response, response
36
62
  end
37
63
 
@@ -39,6 +65,7 @@ class TestResourceBase < Minitest::Test
39
65
  uuid = random_singleton_uuid :person
40
66
  response = client.persons.projects id: uuid
41
67
  # puts response
68
+ assert_equal response.code, 200
42
69
  assert_instance_of HTTP::Response, response
43
70
  end
44
71
 
@@ -9,6 +9,19 @@ class TestResourceCommon < Minitest::Test
9
9
  # puts test_name
10
10
  response = resource_instance(resource).all
11
11
  # puts response
12
+ assert_equal response.code, 200
13
+ assert_instance_of HTTP::Response, response
14
+ end
15
+ end
16
+
17
+ # all_complex
18
+ resources.each do |resource|
19
+ test_name = "test_#{resource}_all_complex"
20
+ define_method(test_name) do
21
+ # puts test_name
22
+ response = resource_instance(resource).all_complex
23
+ # puts response
24
+ assert_equal response.code, 200
12
25
  assert_instance_of HTTP::Response, response
13
26
  end
14
27
  end
@@ -23,6 +36,7 @@ class TestResourceCommon < Minitest::Test
23
36
  resource_instance = resource_instance(resource)
24
37
  response = resource_instance.find id: uuid
25
38
  # puts response
39
+ assert_equal response.code, 200
26
40
  assert_instance_of HTTP::Response, response
27
41
  end
28
42
  end
@@ -36,6 +50,7 @@ class TestResourceCommon < Minitest::Test
36
50
  resource_instance = resource_instance(resource)
37
51
  response = resource_instance.send meta_type
38
52
  # puts response
53
+ assert_equal response.code, 200
39
54
  assert_instance_of HTTP::Response, response
40
55
  end
41
56
  end
data/test/test_helper.rb CHANGED
@@ -9,7 +9,7 @@ require 'puree'
9
9
 
10
10
  def config
11
11
  {
12
- url: ENV['PURE_URL_59'],
12
+ url: ENV['PURE_URL'],
13
13
  username: ENV['PURE_USERNAME'],
14
14
  password: ENV['PURE_PASSWORD'],
15
15
  api_key: ENV['PURE_API_KEY']
@@ -25,7 +25,7 @@ class TestXMLExtractorPaper < Minitest::Test
25
25
  assert_instance_of Puree::Model::EventHeader, x.event
26
26
  assert_equal true, x.event.data?
27
27
 
28
- assert_instance_of Fixnum, x.pages
28
+ assert_instance_of Integer, x.pages
29
29
  end
30
30
 
31
31
  def test_page_range
@@ -22,7 +22,7 @@ class TestXMLExtractorJournalArticle < Minitest::Test
22
22
 
23
23
  asserts_resource x
24
24
 
25
- assert_instance_of Fixnum, x.issue
25
+ assert_instance_of Integer, x.issue
26
26
 
27
27
  assert_instance_of Puree::Model::JournalHeader, x.journal
28
28
  assert_equal true, x.journal.data?
@@ -30,11 +30,11 @@ class TestXMLExtractorJournalArticle < Minitest::Test
30
30
  assert_instance_of String, x.page_range
31
31
  refute_empty x.page_range
32
32
 
33
- assert_instance_of Fixnum, x.pages
33
+ assert_instance_of Integer, x.pages
34
34
 
35
35
  assert_includes [true, false], x.peer_reviewed
36
36
 
37
- assert_instance_of Fixnum, x.volume
37
+ assert_instance_of Integer, x.volume
38
38
  end
39
39
 
40
40
  def test_absence
@@ -113,7 +113,7 @@ class TestXMLExtractorResearchOutput < Minitest::Test
113
113
  id = 'ce76dbda-8b22-422b-9bb6-8143820171b8'
114
114
  x = xml_extractor_from_id id
115
115
 
116
- assert_instance_of Fixnum, x.scopus_citations_count
116
+ assert_instance_of Integer, x.scopus_citations_count
117
117
  end
118
118
 
119
119
  def test_scopus_id
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puree
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Albin-Clark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-20 00:00:00.000000000 Z
11
+ date: 2018-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -202,6 +202,7 @@ files:
202
202
  - test/extractor/resource_count_test.rb
203
203
  - test/extractor/resource_find_test.rb
204
204
  - test/extractor/resource_random_test.rb
205
+ - test/integration/research_output_types_test.rb
205
206
  - test/rest/base_test.rb
206
207
  - test/rest/common_test.rb
207
208
  - test/test_extractor_helper.rb
@@ -241,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
242
  version: '0'
242
243
  requirements: []
243
244
  rubyforge_project:
244
- rubygems_version: 2.2.2
245
+ rubygems_version: 2.7.3
245
246
  signing_key:
246
247
  specification_version: 4
247
248
  summary: Metadata extraction from the Pure Research Information System.
@@ -249,6 +250,7 @@ test_files:
249
250
  - test/extractor/resource_count_test.rb
250
251
  - test/extractor/resource_find_test.rb
251
252
  - test/extractor/resource_random_test.rb
253
+ - test/integration/research_output_types_test.rb
252
254
  - test/rest/base_test.rb
253
255
  - test/rest/common_test.rb
254
256
  - test/test_extractor_helper.rb