Project

General

Profile

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

runcible / test / resources / repository_schedule_test.rb @ master

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

    
4
require './test/support/repository_support'
5

    
6
module Resources
7
  module TestScheduleBase
8
    def setup
9
      @resource = TestRuncible.server.resources.repository_schedule
10
      @support = RepositorySupport.new
11
    end
12
  end
13

    
14
  class TestRepositoryCreateSchedule < MiniTest::Unit::TestCase
15
    include TestScheduleBase
16

    
17
    def setup
18
      super
19
      @support.create_repo :importer => true
20
      @support.create_schedule
21
    end
22

    
23
    def teardown
24
      @support.destroy_repo
25
      super
26
    end
27

    
28
    def test_repository_schedules_path
29
      path = @resource.class.path('foo', 'some_importer')
30

    
31
      assert_match 'repositories/foo/importers/some_importer/schedules/sync/', path
32
    end
33

    
34
    def test_schedule_create
35
      response = @resource.create(RepositorySupport.repo_id, 'yum_importer', '2012-09-25T20:44:00Z/P7D')
36

    
37
      assert_equal 201, response.code
38
    end
39

    
40
    def test_list_schedules
41
      list = @resource.list(RepositorySupport.repo_id, 'yum_importer')
42

    
43
      assert_match list.first[:schedule], @support.schedule_time
44
    end
45
  end
46

    
47
  class TestScheduleUpdate < MiniTest::Unit::TestCase
48
    include TestScheduleBase
49

    
50
    def setup
51
      super
52
      @support.create_repo :importer => true
53
      @support.create_schedule
54
    end
55

    
56
    def teardown
57
      @support.destroy_repo
58
      super
59
    end
60

    
61
    def test_update_schedule
62
      id = @resource.list(RepositorySupport.repo_id, 'yum_importer').first['_id']
63
      response = @resource.update(RepositorySupport.repo_id, 'yum_importer', id, :schedule => 'P1DT')
64

    
65
      assert_equal 200, response.code
66
    end
67
  end
68

    
69
  class TestScheduleDelete < MiniTest::Unit::TestCase
70
    include TestScheduleBase
71

    
72
    def setup
73
      super
74
      @support.create_repo :importer => true
75
      @support.create_schedule
76
    end
77

    
78
    def teardown
79
      @support.destroy_repo
80
      super
81
    end
82

    
83
    def test_delete_schedules
84
      id = @resource.list(RepositorySupport.repo_id, 'yum_importer').first['_id']
85
      response = @resource.delete(RepositorySupport.repo_id, 'yum_importer', id)
86

    
87
      assert_equal 200, response.code
88
    end
89
  end
90
end