artemis_api 0.2.0 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
2
+ require "artemis_api"
3
+
4
+ require "minitest/autorun"
5
+ require "webmock/minitest"
6
+ require "active_support"
7
+ require "active_support/core_ext/numeric"
8
+ require 'active_support/testing/assertions'
9
+ include ActiveSupport::Testing::Assertions
10
+
11
+ def get_client
12
+ options = {app_id: '12345',
13
+ app_secret: '67890',
14
+ base_uri: 'http://localhost:3000'}
15
+ @expires_at = 1.days.from_now
16
+ @client = ArtemisApi::Client.new(access_token: 'ya29',
17
+ refresh_token: 'eyJh',
18
+ expires_at: @expires_at,
19
+ options: options)
20
+ end
21
+
22
+ def get_facility
23
+ stub_request(:get, 'http://localhost:3000/api/v3/facilities/2')
24
+ .to_return(body: {data: {id: '2', type: 'facilities', attributes: {id: 2, name: 'Rare Dankness'}}}.to_json)
25
+ @facility = ArtemisApi::Facility.find(id: 2, client: @client)
26
+ end
@@ -0,0 +1,66 @@
1
+ require "test_helper"
2
+
3
+ class UserTest < Minitest::Test
4
+ def setup
5
+ get_client
6
+ get_facility
7
+
8
+ stub_request(:get, "http://localhost:3000/api/v3/user")
9
+ .to_return(body: {data: {id: '41', type: 'users', attributes: {id: 41, full_name: 'Jamey Hampton', email: 'jhampton@artemisag.com'}}}.to_json)
10
+
11
+ stub_request(:get, "http://localhost:3000/api/v3/facilities/#{@facility.id}/users")
12
+ .to_return(body: {data: [{id: '41', type: 'users', attributes: {id: 41, full_name: 'Jamey Hampton', email: 'jhampton@artemisag.com'}}, {id: '42', type: 'users', attributes: {id: 42, full_name: 'Developer', email: 'developer@artemisag.com'}}]}.to_json)
13
+
14
+ stub_request(:get, "http://localhost:3000/api/v3/facilities/#{@facility.id}/users/42")
15
+ .to_return(body: {data: {id: '42', type: 'users', attributes: {id: 42, full_name: 'Developer', email: 'developer@artemisag.com'}}}.to_json)
16
+ end
17
+
18
+ def test_getting_current_user
19
+ user = ArtemisApi::User.get_current(client: @client)
20
+ assert_equal user.id, 41
21
+ assert_equal user.full_name, 'Jamey Hampton'
22
+ assert_equal user.email, 'jhampton@artemisag.com'
23
+ end
24
+
25
+ def test_finding_all_users
26
+ users = ArtemisApi::User.find_all(facility_id: @facility.id, client: @client)
27
+ assert_equal 2, users.count
28
+ assert_equal 2, @client.objects['users'].count
29
+ end
30
+
31
+ def test_finding_all_users_through_facility
32
+ users = @facility.users
33
+ assert_equal 2, users.count
34
+ end
35
+
36
+ def test_finding_a_specific_user
37
+ user = ArtemisApi::User.find(id: 42, facility_id: @facility.id, client: @client)
38
+ assert_equal user.full_name, 'Developer'
39
+ assert_equal user.email, 'developer@artemisag.com'
40
+ end
41
+
42
+ def test_finding_a_specific_user_through_facility
43
+ user = @facility.user(42)
44
+ assert_equal user.full_name, 'Developer'
45
+ assert_equal user.email, 'developer@artemisag.com'
46
+ end
47
+
48
+ def test_finding_a_user_with_included_organizations
49
+ stub_request(:get, 'http://localhost:3000/api/v3/facilities/2/users/42?include=organizations')
50
+ .to_return(body: {data:
51
+ {id: '42',
52
+ type: 'users',
53
+ attributes: {id: 42, full_name: 'Developer', email: 'developer@artemisag.com'}},
54
+ included: [{id: '1', type: 'organizations', attributes: {id: 1, name: 'Vegetable Sky'}}]}.to_json)
55
+
56
+ user = ArtemisApi::User.find(id: 42, facility_id: @facility.id, client: @client, include: "organizations")
57
+ assert_equal user.full_name, 'Developer'
58
+ assert_equal user.email, 'developer@artemisag.com'
59
+ assert_equal @client.objects['organizations'].count, 1
60
+
61
+ # Since the organization has already been included and stored in the client objects array,
62
+ # this call doesn't actually hit the API and consdoesn't need to be stubbed.
63
+ organization = ArtemisApi::Organization.find(id: 1, client: @client)
64
+ assert_equal organization.name, 'Vegetable Sky'
65
+ end
66
+ end
@@ -0,0 +1,42 @@
1
+ require "test_helper"
2
+
3
+ class ZoneTest < Minitest::Test
4
+ def setup
5
+ get_client
6
+ get_facility
7
+
8
+ stub_request(:get, "http://localhost:3000/api/v3/facilities/#{@facility.id}/zones")
9
+ .to_return(body: {data: [{id: '1', type: 'zones', attributes: {id: 1, name: 'Germination'}}, {id: '2', type: 'zones', attributes: {id: 2, name: 'Propagation'}}]}.to_json)
10
+
11
+ stub_request(:get, "http://localhost:3000/api/v3/facilities/#{@facility.id}/zones/2")
12
+ .to_return(body: {data: {id: '2', type: 'zones', attributes: {id: 2, name: 'Propagation'}}}.to_json)
13
+
14
+ stub_request(:get, "http://localhost:3000/api/v3/facilities/#{@facility.id}/zones?filter[seeding_unit_id]=100")
15
+ .to_return(body: {data: [{id: '2', type: 'zones', attributes: {id: 2, name: 'Propagation'}}]}.to_json)
16
+ end
17
+
18
+ def test_finding_all_zones
19
+ zones = ArtemisApi::Zone.find_all(facility_id: @facility.id, client: @client)
20
+ assert_equal 2, zones.count
21
+ end
22
+
23
+ def test_finding_all_zones_through_facility
24
+ zones = @facility.zones
25
+ assert_equal 2, zones.count
26
+ end
27
+
28
+ def test_finding_a_specific_zone
29
+ zone = ArtemisApi::Zone.find(id: 2, facility_id: @facility.id, client: @client)
30
+ assert_equal 'Propagation', zone.name
31
+ end
32
+
33
+ def test_finding_a_specific_zone_through_facility
34
+ zone = @facility.zone(2)
35
+ assert_equal 'Propagation', zone.name
36
+ end
37
+
38
+ def test_filtering_zones_by_seeding_unit_id
39
+ zones = ArtemisApi::Zone.find_all(facility_id: @facility.id, client: @client, filters: {seeding_unit_id: 100})
40
+ assert_equal 1, zones.count
41
+ end
42
+ end
metadata CHANGED
@@ -1,43 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artemis_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamey Hampton
8
- autorequire:
8
+ - Carlos Betancourt Carrero
9
+ autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2019-10-24 00:00:00.000000000 Z
12
+ date: 2020-08-14 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: bundler
15
+ name: oauth2
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - "~>"
18
+ - - ">="
18
19
  - !ruby/object:Gem::Version
19
- version: '1.16'
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: activesupport
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
20
35
  type: :development
21
36
  prerelease: false
22
37
  version_requirements: !ruby/object:Gem::Requirement
23
38
  requirements:
24
- - - "~>"
39
+ - - ">="
25
40
  - !ruby/object:Gem::Version
26
- version: '1.16'
41
+ version: '0'
27
42
  - !ruby/object:Gem::Dependency
28
- name: rake
43
+ name: bundler
29
44
  requirement: !ruby/object:Gem::Requirement
30
45
  requirements:
31
46
  - - "~>"
32
47
  - !ruby/object:Gem::Version
33
- version: '10.0'
48
+ version: '1.16'
34
49
  type: :development
35
50
  prerelease: false
36
51
  version_requirements: !ruby/object:Gem::Requirement
37
52
  requirements:
38
53
  - - "~>"
39
54
  - !ruby/object:Gem::Version
40
- version: '10.0'
55
+ version: '1.16'
41
56
  - !ruby/object:Gem::Dependency
42
57
  name: minitest
43
58
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +68,7 @@ dependencies:
53
68
  - !ruby/object:Gem::Version
54
69
  version: '5.0'
55
70
  - !ruby/object:Gem::Dependency
56
- name: oauth2
71
+ name: pry
57
72
  requirement: !ruby/object:Gem::Requirement
58
73
  requirements:
59
74
  - - ">="
@@ -67,21 +82,21 @@ dependencies:
67
82
  - !ruby/object:Gem::Version
68
83
  version: '0'
69
84
  - !ruby/object:Gem::Dependency
70
- name: webmock
85
+ name: rake
71
86
  requirement: !ruby/object:Gem::Requirement
72
87
  requirements:
73
- - - ">="
88
+ - - "~>"
74
89
  - !ruby/object:Gem::Version
75
- version: '0'
90
+ version: '13.0'
76
91
  type: :development
77
92
  prerelease: false
78
93
  version_requirements: !ruby/object:Gem::Requirement
79
94
  requirements:
80
- - - ">="
95
+ - - "~>"
81
96
  - !ruby/object:Gem::Version
82
- version: '0'
97
+ version: '13.0'
83
98
  - !ruby/object:Gem::Dependency
84
- name: activesupport
99
+ name: webmock
85
100
  requirement: !ruby/object:Gem::Requirement
86
101
  requirements:
87
102
  - - ">="
@@ -94,14 +109,16 @@ dependencies:
94
109
  - - ">="
95
110
  - !ruby/object:Gem::Version
96
111
  version: '0'
97
- description:
112
+ description:
98
113
  email:
99
114
  - jhampton@artemisag.com
115
+ - cbetancourt@artemisag.com
100
116
  executables: []
101
117
  extensions: []
102
118
  extra_rdoc_files: []
103
119
  files:
104
120
  - ".gitignore"
121
+ - ".ruby-version"
105
122
  - ".travis.yml"
106
123
  - CODE_OF_CONDUCT.md
107
124
  - Gemfile
@@ -110,7 +127,6 @@ files:
110
127
  - LICENSE.txt
111
128
  - README.md
112
129
  - Rakefile
113
- - artemis_api-0.1.0.gem
114
130
  - artemis_api.gemspec
115
131
  - bin/console
116
132
  - bin/setup
@@ -118,6 +134,9 @@ files:
118
134
  - lib/artemis_api/batch.rb
119
135
  - lib/artemis_api/client.rb
120
136
  - lib/artemis_api/completion.rb
137
+ - lib/artemis_api/crop_variety.rb
138
+ - lib/artemis_api/custom_data.rb
139
+ - lib/artemis_api/custom_fields.rb
121
140
  - lib/artemis_api/discard.rb
122
141
  - lib/artemis_api/facility.rb
123
142
  - lib/artemis_api/harvest.rb
@@ -125,16 +144,36 @@ files:
125
144
  - lib/artemis_api/item.rb
126
145
  - lib/artemis_api/model.rb
127
146
  - lib/artemis_api/organization.rb
147
+ - lib/artemis_api/resource_unit.rb
128
148
  - lib/artemis_api/seeding_unit.rb
149
+ - lib/artemis_api/stage.rb
150
+ - lib/artemis_api/sub_stage.rb
129
151
  - lib/artemis_api/subscription.rb
130
152
  - lib/artemis_api/user.rb
131
153
  - lib/artemis_api/version.rb
132
154
  - lib/artemis_api/zone.rb
155
+ - test/artemis_api_test.rb
156
+ - test/batch_test.rb
157
+ - test/client_test.rb
158
+ - test/completion_test.rb
159
+ - test/discard_test.rb
160
+ - test/facility_test.rb
161
+ - test/harvest_test.rb
162
+ - test/harvest_unit_test.rb
163
+ - test/item_test.rb
164
+ - test/organization_test.rb
165
+ - test/resource_unit_test.rb
166
+ - test/seeding_unit_test.rb
167
+ - test/stage_test.rb
168
+ - test/subscription_test.rb
169
+ - test/test_helper.rb
170
+ - test/user_test.rb
171
+ - test/zone_test.rb
133
172
  homepage: https://github.com/artemis-ag/artemis_api/
134
173
  licenses:
135
174
  - MIT
136
175
  metadata: {}
137
- post_install_message:
176
+ post_install_message:
138
177
  rdoc_options: []
139
178
  require_paths:
140
179
  - lib
@@ -149,9 +188,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
188
  - !ruby/object:Gem::Version
150
189
  version: '0'
151
190
  requirements: []
152
- rubyforge_project:
153
- rubygems_version: 2.5.1
154
- signing_key:
191
+ rubygems_version: 3.0.8
192
+ signing_key:
155
193
  specification_version: 4
156
194
  summary: An API wrapper for the ArtemisAg API
157
195
  test_files: []
Binary file