Project

General

Profile

Download (2.34 KB) Statistics
| Branch: | Tag: | Revision:

runcible / test / resources / content_test.rb @ master

1
require 'rubygems'
2
require 'minitest/autorun'
3

    
4
require './lib/runcible'
5
require './test/support/repository_support'
6

    
7
module Resources
8
  module TestContentBase
9
    def setup
10
      @resource = TestRuncible.server.resources.content
11
    end
12
  end
13

    
14
  class TestCreateUploadRequest < MiniTest::Unit::TestCase
15
    include TestContentBase
16

    
17
    def test_create_upload_request
18
      response = @resource.create_upload_request
19

    
20
      assert response.is_a? Hash
21
      assert_equal 201, response.code
22
    end
23
  end
24

    
25
  class TestUploadBits < MiniTest::Unit::TestCase
26
    include TestContentBase
27

    
28
    def test_upload_bits
29
      test_request = @resource.create_upload_request
30
      response = @resource.upload_bits(test_request['upload_id'], '0', 'abcde')
31
      assert_equal 200, response.code
32
    end
33
  end
34

    
35
  class TestImportIntoRepo < MiniTest::Unit::TestCase
36
    include TestContentBase
37

    
38
    def test_import_into_repo
39
      test_unit_key = {'checksumtype' => 'sha256',
40
                       'checksum' => '5e9fb809128d23a3e25d0c5fd38dd5d37d4ebceae7c6af8f15fed93e39d3145f',
41
                       'epoch' => '0',
42
                       'version' => '8.3.3',
43
                       'release' => '1.elfake',
44
                       'arch' => 'noarch',
45
                       'name' => 'recons'}
46

    
47
      self.class.support = RepositorySupport.new
48
      self.class.support.create_and_sync_repo(:importer_and_distributor => true)
49
      response = @resource.import_into_repo(RepositorySupport.repo_id, 'rpm', 'uvwx', test_unit_key)
50
      assert_async_response(response)
51
    ensure
52
      self.class.support.destroy_repo
53
    end
54
  end
55

    
56
  class TestDeleteUploadRequest < MiniTest::Unit::TestCase
57
    include TestContentBase
58

    
59
    def test_delete_upload_request
60
      test_request = @resource.create_upload_request
61
      response = @resource.delete_upload_request(test_request['upload_id'])
62
      assert_equal 200, response.code
63
    end
64
  end
65

    
66
  class TestListAllUploadRequests < MiniTest::Unit::TestCase
67
    include TestContentBase
68

    
69
    def test_list_all_requests
70
      response = @resource.list_all_requests
71

    
72
      assert_equal 200, response.code
73
    end
74
  end
75

    
76
  class TestOrphans < MiniTest::Unit::TestCase
77
    include TestContentBase
78

    
79
    def test_list_orphans
80
      assert @resource.list_orphans.is_a?(Hash)
81
    end
82

    
83
    def test_remove_orphans
84
      assert @resource.remove_orphans.is_a?(Hash)
85
    end
86
  end
87
end