Sha256: b6b4b70fed4216a8bd4dd87a150d8c1512bd8008a6d25340c48094fceb3e2c2a

Contents?: true

Size: 1.96 KB

Versions: 6

Compression:

Stored size: 1.96 KB

Contents

require 'test_rest_helper'

class TestResourceBase < Minitest::Test

  def test_instance
    base = Puree::REST::Base.new config
    assert_instance_of Puree::REST::Base, base
  end

  # Private request methods (used by all resources) tested via Client
  # public interface. Exemplar resource is Person.
  #
  def test_post_request_collection
    params = {
        size: 3,
        employmentTypeUris: ['/dk/atira/pure/person/employmenttypes/academic'],
        employmentStatus: 'ACTIVE'
    }
    response = client.persons.all_complex params: params
    assert_equal response.code, 200
    assert_instance_of HTTP::Response, response
  end

  def test_collection_count
    params = {
      employmentTypeUris: ['/dk/atira/pure/person/employmenttypes/academic'],
      employmentStatus: 'ACTIVE'
    }
    extractor = Puree::Extractor::Person.new config
    count = extractor.count(params)
    assert_instance_of Integer, count
  end

  def test_get_request_collection
    response = client.persons.all params: {size: 5}, accept: :json
    # puts response
    assert_equal response.code, 200
    assert_instance_of HTTP::Response, response
  end

  def test_get_request_singleton
    uuid = random_singleton_uuid :person
    response = client.persons.find id: uuid
    # puts response
    assert_equal response.code, 200
    assert_instance_of HTTP::Response, response
  end

  def test_get_request_meta
    response = client.persons.renderings
    # puts response
    assert_equal response.code, 200
    assert_instance_of HTTP::Response, response
  end

  def test_get_request_collection_subcollection
    response = client.persons.active
    # puts response
    assert_equal response.code, 200
    assert_instance_of HTTP::Response, response
  end

  def test_get_request_singleton_subcollection
    uuid = random_singleton_uuid :person
    response = client.persons.projects id: uuid
    # puts response
    assert_equal response.code, 200
    assert_instance_of HTTP::Response, response
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puree-2.9.2 test/rest/base_test.rb
puree-2.9.1 test/rest/base_test.rb
puree-2.9.0 test/rest/base_test.rb
puree-2.8.1 test/rest/base_test.rb
puree-2.8.0 test/rest/base_test.rb
puree-2.7.0 test/rest/base_test.rb