bearcat 1.0.0 → 1.5.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bearcat.gemspec +15 -5
- data/lib/badgrcat/api_array.rb +25 -0
- data/lib/badgrcat/client/methods.rb +54 -0
- data/lib/badgrcat/client.rb +53 -0
- data/lib/badgrcat/version.rb +3 -0
- data/lib/bearcat/api_array.rb +132 -65
- data/lib/bearcat/client/account_reports.rb +6 -14
- data/lib/bearcat/client/accounts.rb +18 -6
- data/lib/bearcat/client/analytics.rb +12 -0
- data/lib/bearcat/client/assignment_groups.rb +15 -0
- data/lib/bearcat/client/assignments.rb +17 -9
- data/lib/bearcat/client/blueprint_courses.rb +25 -0
- data/lib/bearcat/client/calendar_events.rb +9 -17
- data/lib/bearcat/client/canvas_files.rb +0 -2
- data/lib/bearcat/client/conferences.rb +3 -8
- data/lib/bearcat/client/content_exports.rb +39 -0
- data/lib/bearcat/client/content_migrations.rb +54 -0
- data/lib/bearcat/client/conversations.rb +3 -8
- data/lib/bearcat/client/courses.rb +25 -14
- data/lib/bearcat/client/custom_gradebook_columns.rb +21 -0
- data/lib/bearcat/client/discussions.rb +10 -4
- data/lib/bearcat/client/enrollments.rb +9 -25
- data/lib/bearcat/client/external_tools.rb +18 -0
- data/lib/bearcat/client/file_helper.rb +36 -30
- data/lib/bearcat/client/files.rb +9 -0
- data/lib/bearcat/client/folders.rb +24 -0
- data/lib/bearcat/client/graph_ql.rb +17 -0
- data/lib/bearcat/client/group_categories.rb +18 -0
- data/lib/bearcat/client/group_memberships.rb +14 -0
- data/lib/bearcat/client/groups.rb +10 -2
- data/lib/bearcat/client/learning_outcomes.rb +17 -0
- data/lib/bearcat/client/logins.rb +20 -0
- data/lib/bearcat/client/module_items.rb +18 -0
- data/lib/bearcat/client/modules.rb +12 -7
- data/lib/bearcat/client/o_auth2.rb +18 -9
- data/lib/bearcat/client/outcome_groups.rb +2 -4
- data/lib/bearcat/client/outcome_imports.rb +48 -0
- data/lib/bearcat/client/outcomes.rb +4 -7
- data/lib/bearcat/client/pages.rb +15 -0
- data/lib/bearcat/client/progresses.rb +9 -0
- data/lib/bearcat/client/quizzes.rb +13 -9
- data/lib/bearcat/client/reports.rb +37 -17
- data/lib/bearcat/client/roles.rb +15 -0
- data/lib/bearcat/client/rubric.rb +17 -0
- data/lib/bearcat/client/rubric_assessment.rb +13 -0
- data/lib/bearcat/client/rubric_association.rb +13 -0
- data/lib/bearcat/client/search.rb +9 -0
- data/lib/bearcat/client/sections.rb +10 -17
- data/lib/bearcat/client/sis_imports.rb +6 -12
- data/lib/bearcat/client/submissions.rb +53 -21
- data/lib/bearcat/client/tabs.rb +12 -0
- data/lib/bearcat/client/users.rb +32 -13
- data/lib/bearcat/client.rb +111 -45
- data/lib/bearcat/client_module.rb +103 -0
- data/lib/bearcat/rate_limiting/increment_bucket.lua +33 -0
- data/lib/bearcat/rate_limiting/redis_script.rb +164 -0
- data/lib/bearcat/rate_limiting.rb +69 -0
- data/lib/bearcat/redis_connection.rb +106 -0
- data/lib/bearcat/spec_helpers.rb +125 -0
- data/lib/bearcat/version.rb +1 -1
- data/lib/bearcat.rb +49 -0
- data/lib/catalogcat/api_array.rb +22 -0
- data/lib/catalogcat/client/catalogs.rb +21 -0
- data/lib/catalogcat/client/certificates.rb +17 -0
- data/lib/catalogcat/client/courses.rb +25 -0
- data/lib/catalogcat/client/email_domain_sets.rb +17 -0
- data/lib/catalogcat/client/enrollments.rb +25 -0
- data/lib/catalogcat/client/orders.rb +13 -0
- data/lib/catalogcat/client/user_registrations.rb +9 -0
- data/lib/catalogcat/client.rb +26 -0
- data/lib/catalogcat/version.rb +3 -0
- data/lib/catalogcat.rb +14 -0
- data/spec/bearcat/api_array_spec.rb +112 -0
- data/spec/bearcat/client/accounts_spec.rb +71 -1
- data/spec/bearcat/client/analytics_spec.rb +22 -0
- data/spec/bearcat/client/assignment_groups_spec.rb +47 -0
- data/spec/bearcat/client/assignments_spec.rb +43 -0
- data/spec/bearcat/client/blueprint_courses_spec.rb +43 -0
- data/spec/bearcat/client/canvas_files_spec.rb +1 -2
- data/spec/bearcat/client/content_exports_spec.rb +68 -0
- data/spec/bearcat/client/content_migrations_spec.rb +94 -0
- data/spec/bearcat/client/courses_spec.rb +81 -2
- data/spec/bearcat/client/custom_gradebook_columns_spec.rb +66 -0
- data/spec/bearcat/client/discussions_spec.rb +73 -0
- data/spec/bearcat/client/enrollments_spec.rb +10 -0
- data/spec/bearcat/client/external_tools_spec.rb +106 -0
- data/spec/bearcat/client/files_spec.rb +15 -0
- data/spec/bearcat/client/folders_spec.rb +18 -0
- data/spec/bearcat/client/graph_ql_spec.rb +35 -0
- data/spec/bearcat/client/group_categories_spec.rb +45 -0
- data/spec/bearcat/client/group_membership_spec.rb +14 -0
- data/spec/bearcat/client/group_memberships_spec.rb +36 -0
- data/spec/bearcat/client/groups_spec.rb +46 -0
- data/spec/bearcat/client/learning_outcomes_spec.rb +25 -0
- data/spec/bearcat/client/module_items_spec.rb +60 -0
- data/spec/bearcat/client/modules_spec.rb +38 -1
- data/spec/bearcat/client/o_auth2_spec.rb +3 -3
- data/spec/bearcat/client/pages_spec.rb +17 -0
- data/spec/bearcat/client/quizzes_spec.rb +41 -4
- data/spec/bearcat/client/reports_spec.rb +40 -1
- data/spec/bearcat/client/roles_spec.rb +24 -0
- data/spec/bearcat/client/rubric_assessment_spec.rb +47 -0
- data/spec/bearcat/client/rubric_association_spec.rb +39 -0
- data/spec/bearcat/client/rubric_spec.rb +45 -0
- data/spec/bearcat/client/search_spec.rb +16 -0
- data/spec/bearcat/client/sections_spec.rb +12 -0
- data/spec/bearcat/client/submissions_spec.rb +47 -2
- data/spec/bearcat/client/users_spec.rb +43 -0
- data/spec/bearcat/client_spec.rb +1 -4
- data/spec/bearcat/rate_limiting_spec.rb +62 -0
- data/spec/bearcat/stub_bearcat_spec.rb +15 -0
- data/spec/fixtures/access_token.json +3 -0
- data/spec/fixtures/account_admin_create.json +14 -0
- data/spec/fixtures/account_admin_delete.json +15 -0
- data/spec/fixtures/account_admins.json +54 -0
- data/spec/fixtures/account_courses.json +48 -0
- data/spec/fixtures/account_grading_standards.json +20 -0
- data/spec/fixtures/account_groups.json +42 -0
- data/spec/fixtures/account_role.json +34 -0
- data/spec/fixtures/account_roles.json +35 -0
- data/spec/fixtures/account_sis_imports.json +39 -0
- data/spec/fixtures/account_sub_accounts.json +17 -0
- data/spec/fixtures/accounts.json +13 -0
- data/spec/fixtures/assignment.json +32 -0
- data/spec/fixtures/assignment_group.json +7 -0
- data/spec/fixtures/assignment_groups.json +16 -0
- data/spec/fixtures/blueprint_migration.json +12 -0
- data/spec/fixtures/blueprint_subscriptions.json +5 -0
- data/spec/fixtures/blueprint_template.json +7 -0
- data/spec/fixtures/blueprint_update_assocations_success.json +3 -0
- data/spec/fixtures/communication_channels.json +10 -0
- data/spec/fixtures/content_export.json +9 -0
- data/spec/fixtures/content_migration_files/content_migration.json +13 -0
- data/spec/fixtures/course_copy.json +18 -0
- data/spec/fixtures/course_files.json +38 -0
- data/spec/fixtures/course_folder.json +21 -0
- data/spec/fixtures/course_folders.json +44 -0
- data/spec/fixtures/course_grading_standards.json +20 -0
- data/spec/fixtures/course_settings.json +33 -0
- data/spec/fixtures/create_course_discussion.json +44 -0
- data/spec/fixtures/created_group.json +37 -0
- data/spec/fixtures/created_group_category.json +15 -0
- data/spec/fixtures/created_group_membership.json +8 -0
- data/spec/fixtures/created_module.json +13 -0
- data/spec/fixtures/custom_gradebook_columns/column_data.json +4 -0
- data/spec/fixtures/custom_gradebook_columns/custom_gradebook_column.json +7 -0
- data/spec/fixtures/custom_gradebook_columns/custom_gradebook_columns.json +16 -0
- data/spec/fixtures/custom_gradebook_columns/gradebook_column_progress.json +14 -0
- data/spec/fixtures/dashboard.json +6 -0
- data/spec/fixtures/delete_course.json +3 -0
- data/spec/fixtures/delete_group_category.json +3 -0
- data/spec/fixtures/deleted_group.json +37 -0
- data/spec/fixtures/department_level_participation.json +73 -0
- data/spec/fixtures/department_level_statistics.json +10 -0
- data/spec/fixtures/discussion_entries.json +21 -0
- data/spec/fixtures/discussion_entry_replies.json +21 -0
- data/spec/fixtures/discussion_topic.json +49 -0
- data/spec/fixtures/discussion_topics.json +51 -0
- data/spec/fixtures/edited_group.json +129 -0
- data/spec/fixtures/edited_group_category.json +15 -0
- data/spec/fixtures/enrollment_terms.json +1 -1
- data/spec/fixtures/external_tool.json +55 -0
- data/spec/fixtures/external_tools.json +57 -0
- data/spec/fixtures/file.csv +5 -0
- data/spec/fixtures/gradebook_history.json +52 -0
- data/spec/fixtures/graph_ql_scores.json +33 -0
- data/spec/fixtures/group.json +15 -0
- data/spec/fixtures/group_categories.json +28 -0
- data/spec/fixtures/group_category.json +13 -0
- data/spec/fixtures/group_category_groups.json +20 -0
- data/spec/fixtures/group_membership.json +7 -0
- data/spec/fixtures/learning_outcome.json +32 -0
- data/spec/fixtures/merge_user.json +8 -0
- data/spec/fixtures/module.json +15 -0
- data/spec/fixtures/module_item.json +15 -0
- data/spec/fixtures/module_items.json +47 -0
- data/spec/fixtures/ok.json +3 -0
- data/spec/fixtures/outcome_result.json +13 -0
- data/spec/fixtures/pages.json +40 -0
- data/spec/fixtures/progress.json +13 -0
- data/spec/fixtures/quizzes/course_quiz_questions.json +59 -0
- data/spec/fixtures/quizzes/quiz_assignment_override.json +31 -0
- data/spec/fixtures/reactivate_enrollment.json +20 -0
- data/spec/fixtures/rubric.json +13 -0
- data/spec/fixtures/rubric_assessment.json +32 -0
- data/spec/fixtures/rubric_association.json +13 -0
- data/spec/fixtures/search_find_recipients.json +10 -0
- data/spec/fixtures/update_section.json +1 -1
- data/spec/fixtures/user_details.json +16 -0
- data/spec/fixtures/user_logins.json +9 -0
- data/spec/helper.rb +2 -0
- metadata +336 -43
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::ContentMigrations do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'uploads a file' do
|
9
|
+
stub_post(@client, "/my/upload/path").
|
10
|
+
to_return(json_response('content_migration_files/response.json'))
|
11
|
+
|
12
|
+
stub_request(:post, "http://host/files_api").
|
13
|
+
to_return(status: 302, headers: {'Location' => 'https://confirm-upload.invalid/confirm?param=true'})
|
14
|
+
|
15
|
+
stub_get(@client, '/confirm').with(query: { param: true }).to_return(json_response('content_migration_files/upload_success.json'))
|
16
|
+
|
17
|
+
opts = {migration_type: 'canvas_cartridge_importer', pre_attachment: {name: 'cc.imscc', size: '2034'}}
|
18
|
+
response = @client.upload_content_package('my/upload/path', fixture('cc.imscc'), opts)
|
19
|
+
expect(response['id']).to eq 293
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'get_group_content_migration' do
|
23
|
+
it "gets a content_migration" do
|
24
|
+
stub_get(@client, "/api/v1/accounts/3/content_migrations/1").to_return(json_response("content_migration_files/content_migration.json"))
|
25
|
+
account = @client.get_account_content_migration(3, 1)
|
26
|
+
account['migration_type'].should == 'common_cartridge_importer'
|
27
|
+
account['migration_type_title'].should == "Canvas Cartridge Importer"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'get_course_content_migration' do
|
32
|
+
it "gets a content_migration" do
|
33
|
+
stub_get(@client, "/api/v1/courses/3/content_migrations/1").to_return(json_response("content_migration_files/content_migration.json"))
|
34
|
+
course = @client.get_course_content_migration(3, 1)
|
35
|
+
course['migration_type'].should == 'common_cartridge_importer'
|
36
|
+
course['migration_type_title'].should == "Canvas Cartridge Importer"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'get_group_content_migration' do
|
41
|
+
it "gets a content_migration" do
|
42
|
+
stub_get(@client, "/api/v1/groups/3/content_migrations/1").to_return(json_response("content_migration_files/content_migration.json"))
|
43
|
+
group = @client.get_group_content_migration(3, 1)
|
44
|
+
group['migration_type'].should == 'common_cartridge_importer'
|
45
|
+
group['migration_type_title'].should == "Canvas Cartridge Importer"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'get_user_content_migration' do
|
50
|
+
it "gets a content_migration" do
|
51
|
+
stub_get(@client, "/api/v1/users/3/content_migrations/1").to_return(json_response("content_migration_files/content_migration.json"))
|
52
|
+
user = @client.get_user_content_migration(3, 1)
|
53
|
+
user['migration_type'].should == 'common_cartridge_importer'
|
54
|
+
user['migration_type_title'].should == "Canvas Cartridge Importer"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'create_account_content_migration' do
|
59
|
+
it "creates a account migration" do
|
60
|
+
stub_post(@client, "/api/v1/accounts/3/content_migrations").to_return(json_response('content_migration_files/content_migration.json'))
|
61
|
+
account = @client.create_account_content_migration(3)
|
62
|
+
account['migration_type'].should == 'common_cartridge_importer'
|
63
|
+
account['migration_type_title'].should == "Canvas Cartridge Importer"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'create_course_content_migration' do
|
68
|
+
it "creates a course migration" do
|
69
|
+
stub_post(@client, "/api/v1/courses/3/content_migrations").to_return(json_response('content_migration_files/content_migration.json'))
|
70
|
+
course = @client.create_course_content_migration(3)
|
71
|
+
course['migration_type'].should == 'common_cartridge_importer'
|
72
|
+
course['migration_type_title'].should == "Canvas Cartridge Importer"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'create_group_content_migration' do
|
77
|
+
it "creates a group migration" do
|
78
|
+
stub_post(@client, "/api/v1/groups/3/content_migrations").to_return(json_response('content_migration_files/content_migration.json'))
|
79
|
+
group = @client.create_group_content_migration(3)
|
80
|
+
group['migration_type'].should == 'common_cartridge_importer'
|
81
|
+
group['migration_type_title'].should == "Canvas Cartridge Importer"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe 'create_user_content_migration' do
|
86
|
+
it "creates a user migration" do
|
87
|
+
stub_post(@client, "/api/v1/users/3/content_migrations").to_return(json_response('content_migration_files/content_migration.json'))
|
88
|
+
user = @client.create_user_content_migration(3)
|
89
|
+
user['migration_type'].should == 'common_cartridge_importer'
|
90
|
+
user['migration_type_title'].should == "Canvas Cartridge Importer"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -21,6 +21,12 @@ describe Bearcat::Client::Sections do
|
|
21
21
|
course['id'].should == 1
|
22
22
|
end
|
23
23
|
|
24
|
+
it "deletes a course" do
|
25
|
+
stub_request(:delete, "http://canvas.instructure.com/api/v1/courses/3?event=delete").to_return(json_response("delete_course.json"))
|
26
|
+
response = @client.delete_course(3)
|
27
|
+
response['delete'].should == true
|
28
|
+
end
|
29
|
+
|
24
30
|
it "updates a course" do
|
25
31
|
name = "updated course"
|
26
32
|
stub_put(@client, "/api/v1/courses/1").with(body: {"course" => {"name" => name}}).to_return(json_response("updated_course.json"))
|
@@ -43,14 +49,39 @@ describe Bearcat::Client::Sections do
|
|
43
49
|
stub_request(:post, "http://host/files_api").
|
44
50
|
to_return(status: 302, headers: {'Location' => 'https://confirm-upload.invalid/confirm?param=true'})
|
45
51
|
|
46
|
-
|
47
|
-
with(:body => {"param" => ["true"]}).to_return(json_response('content_migration_files', 'upload_success.json'))
|
52
|
+
stub_get(@client, '/confirm').with(query: { param: true }).to_return(json_response('content_migration_files', 'upload_success.json'))
|
48
53
|
|
49
54
|
opts = {'migration_type' => 'canvas_cartridge_importer', 'pre_attachment[name]' => 'cc.imscc', 'pre_attachment[size]' => '2034'}
|
50
55
|
response = @client.create_content_migration('659', fixture('cc.imscc'), opts)
|
51
56
|
expect(response['id']).to eq 293
|
52
57
|
end
|
53
58
|
|
59
|
+
describe '#create_content_migration_with_both_responses' do
|
60
|
+
it 'creates a content migration and returns the content migration response and the file creation response' do
|
61
|
+
stub_post(@client, "/api/v1/courses/659/content_migrations").
|
62
|
+
with(:body => {"migration_type"=>"canvas_cartridge_importer", "pre_attachment"=>{"name"=>"cc.imscc", "size"=>"2034"}}).
|
63
|
+
to_return(json_response('content_migration_files', 'response.json'))
|
64
|
+
|
65
|
+
stub_request(:post, "http://host/files_api").
|
66
|
+
to_return(status: 302, headers: {'Location' => 'https://confirm-upload.invalid/confirm?param=true'})
|
67
|
+
|
68
|
+
stub_get(@client, '/confirm').with(query: { param: true }).to_return(json_response('content_migration_files', 'upload_success.json'))
|
69
|
+
|
70
|
+
opts = {'migration_type' => 'canvas_cartridge_importer', 'pre_attachment[name]' => 'cc.imscc', 'pre_attachment[size]' => '2034'}
|
71
|
+
content_migration_response, file_upload_response = @client.create_content_migration_with_both_responses('659', fixture('cc.imscc'), opts)
|
72
|
+
expect(content_migration_response['id']).to eq 21
|
73
|
+
expect(file_upload_response['id']).to eq 293
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'returns a course\'s settings' do
|
78
|
+
stub_get(@client, '/api/v1/courses/1/settings').to_return(json_response('course_settings.json'))
|
79
|
+
settings = @client.course_settings(1)
|
80
|
+
settings['allow_student_discussion_topics'].should == false
|
81
|
+
settings['allow_student_discussion_editing'].should == true
|
82
|
+
settings['allow_student_discussion_reporting'].should == false
|
83
|
+
end
|
84
|
+
|
54
85
|
it 'throws an error on a failed file upload' do
|
55
86
|
stub_post(@client, "/api/v1/courses/659/content_migrations").
|
56
87
|
with(:body => {"migration_type"=>"canvas_cartridge_importer", "pre_attachment"=>{"name"=>"cc.imscc", "size"=>"2034"}}).
|
@@ -63,4 +94,52 @@ describe Bearcat::Client::Sections do
|
|
63
94
|
expect { @client.create_content_migration('659', fixture('cc.imscc'), opts) }.to raise_exception
|
64
95
|
end
|
65
96
|
|
97
|
+
it 'sets extensions on a quiz' do
|
98
|
+
stub_post(@client, "/api/v1/courses/1/quiz_extensions").to_return(json_response("quizzes/quiz_extension.json"))
|
99
|
+
quiz_extension = @client.course_quiz_extensions('1', {quiz_extensions: [{user_id: 1}, {extra_time: 30}]})
|
100
|
+
quiz_extension.should be_a Hash
|
101
|
+
quiz_extension['quiz_extensions'].first['extra_time'].should eq(30)
|
102
|
+
quiz_extension[:quiz_extensions].first[:extra_time].should eq(30)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'gets learning outcome results' do
|
106
|
+
stub_get(@client, "/api/v1/courses/1/outcome_results").to_return(json_response("outcome_result.json"))
|
107
|
+
outcome_result = @client.course_outcome_results('1')
|
108
|
+
outcome = outcome_result['outcome_results'].first
|
109
|
+
links = outcome['links']
|
110
|
+
expect(outcome['id']).to eq('1')
|
111
|
+
expect(outcome['score']).to eq(3)
|
112
|
+
expect(links['user']).to eq('101')
|
113
|
+
expect(links['learning_outcome']).to eq('1')
|
114
|
+
expect(links['alignment']).to eq('assignment_1')
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'performs a course copy' do
|
118
|
+
stub_post(@client, '/api/v1/courses/1/content_migrations').to_return(json_response("course_copy.json"))
|
119
|
+
response = @client.copy_course('1')
|
120
|
+
expect(response['id']).to eql 199
|
121
|
+
expect(response['migration_type']).to eql 'course_copy_importer'
|
122
|
+
expect(response['workflow_state']).to eql 'running'
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'gets course belonging to user' do
|
126
|
+
stub_get(@client, '/api/v1/courses?enrollment_type=teacher').to_return(json_response("course.json"))
|
127
|
+
response = @client.list_users_courses({'enrollment_type' => 'teacher'})
|
128
|
+
expect(response['id']).to eql 3
|
129
|
+
expect(response['workflow_state']).to eql 'available'
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'gets course grading_standards' do
|
133
|
+
stub_get(@client, "/api/v1/courses/1/grading_standards").to_return(json_response("course_grading_standards.json"))
|
134
|
+
grading_standards = @client.course_grading_standards(1)
|
135
|
+
expect(grading_standards['id']).to eq 2
|
136
|
+
expect(grading_standards['title']).to eq 'custom grading scheme'
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'gets course gradebook history' do
|
140
|
+
stub_get(@client, "/api/v1/courses/1/gradebook_history/feed").to_return(json_response("gradebook_history.json"))
|
141
|
+
gradebook_history = @client.course_gradebook_history(1).all_pages![0]
|
142
|
+
expect(gradebook_history['id']).to eq 1
|
143
|
+
expect(gradebook_history['workflow_state']).to eq 'graded'
|
144
|
+
end
|
66
145
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::CustomGradebookColumns do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix:"http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'custom_gradebook_columns' do
|
9
|
+
it "lists custom gradebook columns" do
|
10
|
+
stub_get(@client, '/api/v1/courses/1/custom_gradebook_columns').to_return(json_response('custom_gradebook_columns', 'custom_gradebook_columns.json'))
|
11
|
+
response = @client.custom_gradebook_columns(1)
|
12
|
+
response.first['id'].should == 1
|
13
|
+
response.last['id'].should == 2
|
14
|
+
end
|
15
|
+
|
16
|
+
it "creates custom gradebook column" do
|
17
|
+
params = {"title": "Third", "position": 3, "hidden": false}
|
18
|
+
stub_post(@client, '/api/v1/courses/1/custom_gradebook_columns').to_return(json_response('custom_gradebook_columns', 'custom_gradebook_column.json'))
|
19
|
+
response = @client.create_gradebook_columns(1, params)
|
20
|
+
expect(response['id']).to eq 3
|
21
|
+
expect(response['title']).to eq 'Third'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "deletes custom gradebook column" do
|
25
|
+
stub_delete(@client, '/api/v1/courses/1/custom_gradebook_columns/3').to_return(json_response('custom_gradebook_columns', 'custom_gradebook_column.json'))
|
26
|
+
response = @client.delete_gradebook_columns(1, 3)
|
27
|
+
expect(response['id']).to eq 3
|
28
|
+
expect(response['title']).to eq 'Third'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
context 'custom_gradebook_column_data' do
|
32
|
+
it "lists data for custom gradebook column" do
|
33
|
+
stub_get(@client, '/api/v1/courses/1/custom_gradebook_columns/1/data').to_return(json_response('custom_gradebook_columns', 'column_data.json'))
|
34
|
+
response = @client.gradebook_columns_data(1, 1)
|
35
|
+
response['content'].should == 'Nut allergy'
|
36
|
+
response['user_id'].should == 1
|
37
|
+
end
|
38
|
+
|
39
|
+
it "lists data for custom gradebook column" do
|
40
|
+
params = {"content": "Nut allergy", "user_id": 1}
|
41
|
+
stub_put(@client, '/api/v1/courses/1/custom_gradebook_columns/1/data/1').to_return(json_response('custom_gradebook_columns', 'column_data.json'))
|
42
|
+
response = @client.update_gradebook_columns_data(1, 1, 1, params)
|
43
|
+
response['content'].should == 'Nut allergy'
|
44
|
+
response['user_id'].should == 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
context 'update_gradebook_columns_data' do
|
48
|
+
it 'bulk updates gradebook columns data' do
|
49
|
+
params = {'column_data': [
|
50
|
+
{
|
51
|
+
'column_id': 1,
|
52
|
+
'user_id': 2,
|
53
|
+
'content': 'user2 content'
|
54
|
+
},
|
55
|
+
{
|
56
|
+
'column_id': 1,
|
57
|
+
'user_id': 3,
|
58
|
+
'content': 'user3 content'
|
59
|
+
}
|
60
|
+
]}
|
61
|
+
stub_put(@client, '/api/v1/courses/1/custom_gradebook_column_data').to_return(json_response('custom_gradebook_columns', 'gradebook_column_progress.json'))
|
62
|
+
response = @client.bulk_update_gradebook_columns_data(1, params)
|
63
|
+
expect(response['context_id']).to eq 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -12,4 +12,77 @@ describe Bearcat::Client::Discussions do
|
|
12
12
|
discussion['title'].should == 'This is a group discussion'
|
13
13
|
end
|
14
14
|
|
15
|
+
it 'creates a new course discussion' do
|
16
|
+
title = "This is a course discussion"
|
17
|
+
stub_post(@client, "/api/v1/courses/2/discussion_topics").with(body: {"title" => title}).to_return(json_response("create_course_discussion.json"))
|
18
|
+
discussion = @client.create_course_discussion(2, {'title' => title})
|
19
|
+
discussion['title'].should == 'This is a course discussion'
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
it 'returns course discussion topics' do
|
24
|
+
stub_get(@client, "/api/v1/courses/1/discussion_topics").to_return(json_response("discussion_topics.json"))
|
25
|
+
discussions = @client.course_discussions('1')
|
26
|
+
discussions.class.should eq(Bearcat::ApiArray)
|
27
|
+
discussions.count.should == 1
|
28
|
+
discussions[0].should be_a Hash
|
29
|
+
discussions[0]['id'].should == 1
|
30
|
+
discussions[0][:id].should == 1
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'returns group discussion topics' do
|
34
|
+
stub_get(@client, "/api/v1/groups/1/discussion_topics").to_return(json_response("discussion_topics.json"))
|
35
|
+
discussions = @client.group_discussions('1')
|
36
|
+
discussions.class.should eq(Bearcat::ApiArray)
|
37
|
+
discussions.count.should == 1
|
38
|
+
discussions[0].should be_a Hash
|
39
|
+
discussions[0]['id'].should == 1
|
40
|
+
discussions[0][:id].should == 1
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns course discussion entries' do
|
44
|
+
stub_get(@client, "/api/v1/courses/1/discussion_topics/1/entries").to_return(json_response("discussion_entries.json"))
|
45
|
+
discussions = @client.course_discussion_entries('1', '1')
|
46
|
+
discussions.class.should eq(Bearcat::ApiArray)
|
47
|
+
discussions.count.should == 1
|
48
|
+
discussions[0].should be_a Hash
|
49
|
+
discussions[0]['id'].should == 1
|
50
|
+
discussions[0][:id].should == 1
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'returns group discussion entries' do
|
54
|
+
stub_get(@client, "/api/v1/groups/1/discussion_topics/1/entries").to_return(json_response("discussion_entries.json"))
|
55
|
+
discussions = @client.group_discussion_entries('1', '1')
|
56
|
+
discussions.class.should eq(Bearcat::ApiArray)
|
57
|
+
discussions.count.should == 1
|
58
|
+
discussions[0].should be_a Hash
|
59
|
+
discussions[0]['id'].should == 1
|
60
|
+
discussions[0][:id].should == 1
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns course discussion entry replies' do
|
64
|
+
stub_get(@client, "/api/v1/courses/1/discussion_topics/1/entries/1/replies").to_return(json_response("discussion_entry_replies.json"))
|
65
|
+
discussions = @client.course_discussion_entry_replies('1', '1', '1')
|
66
|
+
discussions.class.should eq(Bearcat::ApiArray)
|
67
|
+
discussions.count.should == 1
|
68
|
+
discussions[0].should be_a Hash
|
69
|
+
discussions[0]['id'].should == 3
|
70
|
+
discussions[0][:id].should == 3
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'returns group discussion entry replies' do
|
74
|
+
stub_get(@client, "/api/v1/groups/1/discussion_topics/1/entries/1/replies").to_return(json_response("discussion_entry_replies.json"))
|
75
|
+
discussions = @client.group_discussion_entry_replies('1', '1', '1')
|
76
|
+
discussions.class.should eq(Bearcat::ApiArray)
|
77
|
+
discussions.count.should == 1
|
78
|
+
discussions[0].should be_a Hash
|
79
|
+
discussions[0]['id'].should == 3
|
80
|
+
discussions[0][:id].should == 3
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'returns a single group discussion' do
|
84
|
+
stub_get(@client, "/api/v1/courses/1/discussion_topics/1").to_return(json_response("discussion_topic.json"))
|
85
|
+
discussion = @client.course_discussion('1', '1')
|
86
|
+
expect(discussion['id']).to eq(1)
|
87
|
+
end
|
15
88
|
end
|
@@ -71,4 +71,14 @@ describe Bearcat::Client::Enrollments do
|
|
71
71
|
enrollment["enrollment_state"].should == "completed"
|
72
72
|
end
|
73
73
|
|
74
|
+
it "reactivates a students enrollment" do
|
75
|
+
stub_request(:put, "http://canvas.instructure.com/api/v1/courses/3/enrollments/1386/reactivate").to_return(json_response("reactivate_enrollment.json"))
|
76
|
+
enrollment = @client.reactivate_enrollment(3, 1386)
|
77
|
+
enrollment["course_id"].should == 3
|
78
|
+
enrollment["course_section_id"].should == 70
|
79
|
+
enrollment["id"].should == 1386
|
80
|
+
enrollment["role"].should == "StudentEnrollment"
|
81
|
+
enrollment["enrollment_state"].should == "active"
|
82
|
+
end
|
83
|
+
|
74
84
|
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::ExternalTools do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix: 'http://canvas.instructure.com', token: 'test_token')
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '.course_external_tools' do
|
9
|
+
it 'returns all external tools on a course' do
|
10
|
+
stub_get(@client, '/api/v1/courses/1/external_tools').to_return(json_response('external_tools.json'))
|
11
|
+
tools = @client.course_external_tools(1)
|
12
|
+
expect(tools.first['id']).to eq(1)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.account_external_tools' do
|
17
|
+
it 'returns all external tools on an accounts' do
|
18
|
+
stub_get(@client, '/api/v1/accounts/1/external_tools').to_return(json_response('external_tools.json'))
|
19
|
+
tools = @client.account_external_tools(1)
|
20
|
+
expect(tools.first['id']).to eq(1)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'course_external_tool' do
|
25
|
+
it 'returns a course external tool' do
|
26
|
+
stub_get(@client, '/api/v1/courses/1/external_tools/1').to_return(json_response('external_tool.json'))
|
27
|
+
tool = @client.course_external_tool(1, 1)
|
28
|
+
expect(tool['id']).to eq(1)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'account_external_tool' do
|
33
|
+
it 'returns an account external tool' do
|
34
|
+
stub_get(@client, '/api/v1/accounts/1/external_tools/1').to_return(json_response('external_tool.json'))
|
35
|
+
tool = @client.account_external_tool(1, 1)
|
36
|
+
expect(tool['id']).to eq(1)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'create_course_external_tool' do
|
41
|
+
it 'creates an external tool for the course' do
|
42
|
+
stub_post(@client, '/api/v1/courses/1/external_tools')
|
43
|
+
.with(body: {})
|
44
|
+
.to_return(json_response('external_tool.json'))
|
45
|
+
|
46
|
+
tool = @client.create_course_external_tool(1, {})
|
47
|
+
expect(tool['id']).to eq(1)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'create_account_external_tool' do
|
52
|
+
it 'creates an external tool for the account' do
|
53
|
+
stub_post(@client, '/api/v1/accounts/1/external_tools')
|
54
|
+
.with(body: {})
|
55
|
+
.to_return(json_response('external_tool.json'))
|
56
|
+
|
57
|
+
tool = @client.create_account_external_tool(1, {})
|
58
|
+
expect(tool['id']).to eq(1)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'edit_course_external_tool' do
|
63
|
+
it 'edits the external tool' do
|
64
|
+
stub_put(@client, '/api/v1/courses/1/external_tools/1')
|
65
|
+
.with(body: {})
|
66
|
+
.to_return(json_response('external_tool.json'))
|
67
|
+
|
68
|
+
tool = @client.edit_course_external_tool(1, 1, {})
|
69
|
+
expect(tool['id']).to eq(1)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'edit_account_external_tool' do
|
74
|
+
it 'edits the external tool' do
|
75
|
+
stub_put(@client, '/api/v1/accounts/1/external_tools/1')
|
76
|
+
.with(body: {})
|
77
|
+
.to_return(json_response('external_tool.json'))
|
78
|
+
|
79
|
+
tool = @client.edit_account_external_tool(1, 1, {})
|
80
|
+
expect(tool['id']).to eq(1)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'delete_course_external_tool' do
|
85
|
+
it 'deletes the external tool' do
|
86
|
+
stub_delete(@client, '/api/v1/courses/1/external_tools/1')
|
87
|
+
.with(body: {})
|
88
|
+
.to_return(json_response('external_tool.json'))
|
89
|
+
|
90
|
+
tool = @client.delete_course_external_tool(1, 1, {})
|
91
|
+
expect(tool['id']).to eq(1)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
describe 'delete_account_external_tool' do
|
97
|
+
it 'deletes the external tool' do
|
98
|
+
stub_delete(@client, '/api/v1/accounts/1/external_tools/1')
|
99
|
+
.with(body: {})
|
100
|
+
.to_return(json_response('external_tool.json'))
|
101
|
+
|
102
|
+
tool = @client.delete_account_external_tool(1, 1, {})
|
103
|
+
expect(tool['id']).to eq(1)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::Files do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'returns a list of all the files in the course' do
|
9
|
+
stub_get(@client, "/api/v1/courses/7/files").to_return(json_response("course_files.json"))
|
10
|
+
course_files = @client.list_course_files('7')
|
11
|
+
expect(course_files.count).to eq(2)
|
12
|
+
expect(course_files.first['url']).to eq('http://localhost:3000/files/109/download?download_frd=1&verifier=FBoa2CGPYKxLYgKu49oSl3b6qnfvsmLgGeBxaUrW')
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::Folders do
|
4
|
+
let(:client) { Bearcat::Client.new(token: 'test_token', prefix: 'https://canvas.instructure.com') }
|
5
|
+
|
6
|
+
it 'returns a list of folders in a course' do
|
7
|
+
stub_get(client, '/api/v1/courses/7/folders').to_return(json_response('course_folders.json'))
|
8
|
+
folders = client.list_course_folders 7
|
9
|
+
expect(folders.map { |f| f['id'] }).to eql [1, 593]
|
10
|
+
expect(folders.map { |f| f['full_name'] }).to eql ['course files', 'course files/folder1']
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'creates a new folder in a course' do
|
14
|
+
resp = stub_post(client, '/api/v1/courses/7/folders').to_return(json_response('course_folder.json'))
|
15
|
+
folder = client.create_course_folder(7, {name: 'new folder'})
|
16
|
+
expect(folder['name']).to eql('new folder')
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::GraphQL do
|
4
|
+
|
5
|
+
let(:url) { '/api/graphql' }
|
6
|
+
before do
|
7
|
+
@client = Bearcat::Client.new(prefix: 'http://canvas.instructure.com', token: 'test_token')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns scores for an assignment group' do
|
11
|
+
query = {
|
12
|
+
query: "{
|
13
|
+
assignmentGroup(id: \"29\") {
|
14
|
+
id
|
15
|
+
name
|
16
|
+
gradesConnection {
|
17
|
+
nodes {
|
18
|
+
finalGrade
|
19
|
+
finalScore
|
20
|
+
enrollment{
|
21
|
+
_id
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}"
|
27
|
+
}
|
28
|
+
stub_post(@client, url).with(body: query).to_return(json_response('graph_ql_scores.json'))
|
29
|
+
res = @client.graphql_query(query)
|
30
|
+
res['data']['assignmentGroup']['gradesConnection']['nodes'].count.should eq 3
|
31
|
+
res['data']['assignmentGroup']['name'].should eq 'Assignments'
|
32
|
+
res['data']['assignmentGroup']['gradesConnection']['nodes'][0]['currentScore'].should eq 100
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::GroupCategories do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns group categories" do
|
9
|
+
stub_get(@client, "/api/v1/courses/1809/group_categories").to_return(json_response("group_categories.json"))
|
10
|
+
categories = @client.list_group_categories('courses', 1809)
|
11
|
+
categories.count.should == 2
|
12
|
+
categories.first['name'].should == 'mark red'
|
13
|
+
categories.last['name'].should == 'test group'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns a single group category' do
|
17
|
+
stub_get(@client, "/api/v1/group_categories/2").to_return(json_response("group_category.json"))
|
18
|
+
category = @client.group_category(2)
|
19
|
+
category['name'].should == 'mark red'
|
20
|
+
category['id'].should == 5
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'creates a new group category' do
|
24
|
+
name = "new group category"
|
25
|
+
stub_post(@client, "/api/v1/courses/1/group_categories").with(body: {"name" => name}).to_return(json_response("created_group_category.json"))
|
26
|
+
group_category = @client.create_group_category('courses', 1, { name: name })
|
27
|
+
group_category["name"].should == name
|
28
|
+
group_category["id"].should == 1
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'edits an existing group category' do
|
32
|
+
name = "edited group category"
|
33
|
+
stub_put(@client, "/api/v1/group_categories/1").with(body: {"name" => name}).to_return(json_response("edited_group_category.json"))
|
34
|
+
group_category = @client.edit_group_category(1, { name: name })
|
35
|
+
group_category["name"].should == name
|
36
|
+
group_category["id"].should == 1
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'deletes a group category' do
|
40
|
+
stub_delete(@client, "/api/v1/group_categories/1").to_return(json_response('delete_group_category.json'))
|
41
|
+
response = @client.delete_group_category(1)
|
42
|
+
response["delete"].should == true
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::GroupMemberships do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'gets a single group membership' do
|
9
|
+
stub_get(@client, "/api/v1/groups/1/memberships/1").to_return(json_response('group_membership.json'))
|
10
|
+
group_membership = @client.group_membership(1, 1)
|
11
|
+
group_membership['user_id'].should == 26906
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Bearcat::Client::GroupMemberships do
|
4
|
+
before do
|
5
|
+
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "creates a group membership" do
|
9
|
+
stub_post(@client, "/api/v1/groups/3/memberships").with(:body => {"user_id"=>"6"}).to_return(json_response("created_group_membership.json"))
|
10
|
+
created_group_membership = @client.create_group_membership(3, { user_id: 6 })
|
11
|
+
created_group_membership['id'] == 14
|
12
|
+
created_group_membership['group_id'] == 3
|
13
|
+
created_group_membership['workflow_state'] == 'accepted'
|
14
|
+
created_group_membership['user_id'] == 6
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'GroupMemberships#delete_group_membership' do
|
18
|
+
|
19
|
+
context 'deleting the group membership by id' do
|
20
|
+
it 'deletes a group membership' do
|
21
|
+
stub_delete(@client, "/api/v1/groups/3/memberships/3").to_return(json_response("ok.json"))
|
22
|
+
deleted_response = @client.delete_group_membership(3, 'memberships', 3)
|
23
|
+
deleted_response['ok'] == true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'deleting the group membership by user and group id' do
|
28
|
+
it 'deletes a group membership' do
|
29
|
+
stub_delete(@client, "/api/v1/groups/3/users/3").to_return(json_response("ok.json"))
|
30
|
+
deleted_response = @client.delete_group_membership(3, 'users', 3)
|
31
|
+
deleted_response['ok'] == true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|