test_machine_shop 0.0.4
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/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/compiler.xml +23 -0
- data/.idea/copyright/profiles_settings.xml +5 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/inspectionProfiles/Project_Default.xml +7 -0
- data/.idea/inspectionProfiles/profiles_settings.xml +7 -0
- data/.idea/machineshop.iml +194 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +722 -0
- data/Gemfile +9 -0
- data/LICENSE +22 -0
- data/README.md +977 -0
- data/Rakefile +8 -0
- data/doc.txt +50 -0
- data/lib/machineshop.rb +475 -0
- data/lib/machineshop/api_operations/create.rb +17 -0
- data/lib/machineshop/api_operations/delete.rb +11 -0
- data/lib/machineshop/api_operations/list.rb +16 -0
- data/lib/machineshop/api_operations/update.rb +11 -0
- data/lib/machineshop/api_resource.rb +35 -0
- data/lib/machineshop/configuration.rb +14 -0
- data/lib/machineshop/customer.rb +15 -0
- data/lib/machineshop/data_source_types.rb +28 -0
- data/lib/machineshop/data_sources.rb +35 -0
- data/lib/machineshop/database.rb +59 -0
- data/lib/machineshop/device.rb +30 -0
- data/lib/machineshop/device_instance.rb +30 -0
- data/lib/machineshop/end_points.rb +30 -0
- data/lib/machineshop/errors/api_connection_error.rb +4 -0
- data/lib/machineshop/errors/api_error.rb +4 -0
- data/lib/machineshop/errors/authentication_error.rb +4 -0
- data/lib/machineshop/errors/database_error.rb +5 -0
- data/lib/machineshop/errors/invalid_request_error.rb +10 -0
- data/lib/machineshop/errors/machineshop_error.rb +20 -0
- data/lib/machineshop/errors/schema_error.rb +5 -0
- data/lib/machineshop/json.rb +21 -0
- data/lib/machineshop/machineshop_cache.rb +49 -0
- data/lib/machineshop/machineshop_object.rb +165 -0
- data/lib/machineshop/mapping.rb +34 -0
- data/lib/machineshop/meter.rb +12 -0
- data/lib/machineshop/models/api_endpoint.rb +8 -0
- data/lib/machineshop/models/api_request.rb +28 -0
- data/lib/machineshop/models/schema.rb +184 -0
- data/lib/machineshop/report.rb +11 -0
- data/lib/machineshop/rule.rb +42 -0
- data/lib/machineshop/user.rb +43 -0
- data/lib/machineshop/users.rb +43 -0
- data/lib/machineshop/util.rb +193 -0
- data/lib/machineshop/utility.rb +30 -0
- data/lib/machineshop/version.rb +3 -0
- data/machineshop.gemspec +35 -0
- data/spec/lib/api_calls_spec.rb +628 -0
- data/spec/lib/custom_endpoint_test.rb +78 -0
- data/spec/lib/customer_spec.rb +87 -0
- data/spec/lib/data_source.rb +138 -0
- data/spec/lib/data_source_type_spec.rb +77 -0
- data/spec/lib/database_spec.rb +45 -0
- data/spec/lib/device_instances.rb +73 -0
- data/spec/lib/device_spec.rb +172 -0
- data/spec/lib/endpoint_spec.rb +37 -0
- data/spec/lib/geocode_spec +45 -0
- data/spec/lib/mapping_spec.rb +68 -0
- data/spec/lib/meter_spec.rb +49 -0
- data/spec/lib/report_spec.rb +52 -0
- data/spec/lib/rule_spec.rb +130 -0
- data/spec/lib/user_spec.rb +58 -0
- data/spec/spec_helper.rb +12 -0
- metadata +235 -0
@@ -0,0 +1,172 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
4
|
+
MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
|
5
|
+
|
6
|
+
#publisher_username = 'publisher@machineshop.com'
|
7
|
+
publisher_username = 'admin@csr.com'
|
8
|
+
publisher_password = 'password'
|
9
|
+
|
10
|
+
MachineShop.configure do |config|
|
11
|
+
config.db_name = "machineshop"
|
12
|
+
config.db_username="root"
|
13
|
+
config.db_password="root"
|
14
|
+
config.db_host= "localhost"
|
15
|
+
config.expiry_time= lambda{120.seconds.ago}
|
16
|
+
#second
|
17
|
+
end
|
18
|
+
auth_token, user = MachineShop::User.authenticate(
|
19
|
+
:email => publisher_username,
|
20
|
+
:password => publisher_password
|
21
|
+
)
|
22
|
+
|
23
|
+
describe MachineShop::Device do
|
24
|
+
|
25
|
+
device = nil
|
26
|
+
|
27
|
+
it "should get all devices for the user" do
|
28
|
+
element_data = MachineShop::Device.all(
|
29
|
+
{:page => 1,
|
30
|
+
:per_page => 10},
|
31
|
+
auth_token)
|
32
|
+
|
33
|
+
ap "listing all devices"
|
34
|
+
puts element_data
|
35
|
+
device = element_data[0]
|
36
|
+
device.should_not be_nil
|
37
|
+
device.should be_kind_of MachineShop::Device
|
38
|
+
end
|
39
|
+
|
40
|
+
specificDevice = nil
|
41
|
+
|
42
|
+
|
43
|
+
it "should get a device for the user by id" do
|
44
|
+
specificDevice = MachineShop::Device.retrieve(device[:id], auth_token)
|
45
|
+
|
46
|
+
ap "Device by id"
|
47
|
+
ap specificDevice.as_json
|
48
|
+
specificDevice.should_not be_nil
|
49
|
+
specificDevice.should be_kind_of MachineShop::Device
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
it "should delete device" do
|
55
|
+
delete = specificDevice.delete
|
56
|
+
|
57
|
+
ap "Delete Device by id"
|
58
|
+
ap delete.as_json
|
59
|
+
delete.http_code.should eq 200
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
it "should get a device for the user by name" do
|
64
|
+
element_data = MachineShop::Device.all(
|
65
|
+
{
|
66
|
+
:name => device.name
|
67
|
+
},
|
68
|
+
auth_token)
|
69
|
+
|
70
|
+
element_data.should_not be_nil
|
71
|
+
element_data.should_not be_empty
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
describe MachineShop::DeviceInstance do
|
77
|
+
|
78
|
+
device = nil
|
79
|
+
device_instance = nil
|
80
|
+
|
81
|
+
it "should create a device for the user" do
|
82
|
+
# First create a device to use
|
83
|
+
device = MachineShop::Device.create(
|
84
|
+
{
|
85
|
+
:name => "my_device",
|
86
|
+
:type => "Test",
|
87
|
+
:manufacturer => "a company",
|
88
|
+
:model => "D-vice 1000",
|
89
|
+
:active => "yes",
|
90
|
+
:init_cmd => "my_init_cmd",
|
91
|
+
:init_params => "{'init':'go'}",
|
92
|
+
:exe_path => "/etc/foo",
|
93
|
+
:unit_price => "$199.99",
|
94
|
+
:sample_data => "some arbitrary sample data",
|
95
|
+
:long_description => "This device tracks position and NCAA football conference.",
|
96
|
+
:image_url => "http://someurl.com/your_image.png",
|
97
|
+
:manual_url => "http://someurl.com/manual.pdf"
|
98
|
+
},
|
99
|
+
auth_token)
|
100
|
+
|
101
|
+
ap "device created:"
|
102
|
+
ap device.as_json
|
103
|
+
|
104
|
+
# Now create an instance
|
105
|
+
device_instance = device.create_instance(
|
106
|
+
{
|
107
|
+
:name => "My little instance",
|
108
|
+
:active => "yes"
|
109
|
+
}
|
110
|
+
)
|
111
|
+
|
112
|
+
ap "creating device instance"
|
113
|
+
ap device_instance.as_json
|
114
|
+
|
115
|
+
device_instance.should_not be_nil
|
116
|
+
device_instance.should be_kind_of MachineShop::DeviceInstance
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
it "should get device instances" do
|
121
|
+
element_data = MachineShop::DeviceInstance.all({}, auth_token)
|
122
|
+
|
123
|
+
ap "getting all device instances"
|
124
|
+
|
125
|
+
ap device_instance.as_json
|
126
|
+
|
127
|
+
device_instance = element_data[0]
|
128
|
+
element_data.should_not be_nil
|
129
|
+
element_data.should_not be_empty
|
130
|
+
|
131
|
+
device_instance.should be_kind_of MachineShop::DeviceInstance
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
it "should get a device instance by id" do
|
136
|
+
element_data = MachineShop::DeviceInstance.retrieve("5395835f385f7f53ec000160", auth_token)
|
137
|
+
|
138
|
+
ap "Device Instance by id: "
|
139
|
+
ap element_data.as_json
|
140
|
+
|
141
|
+
element_data.should_not be_nil
|
142
|
+
element_data.should be_kind_of MachineShop::DeviceInstance
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should get a device instance by name" do
|
146
|
+
element_data = MachineShop::DeviceInstance.all({:name => device_instance.name}, auth_token)
|
147
|
+
|
148
|
+
ap "Device Instance by name: "
|
149
|
+
ap element_data.as_json
|
150
|
+
|
151
|
+
element_data.should_not be_nil
|
152
|
+
element_data.should_not be_empty
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should get all devices via a user" do
|
156
|
+
element_data = user.device_instances
|
157
|
+
|
158
|
+
ap "Device Instance via user "
|
159
|
+
ap element_data.as_json
|
160
|
+
|
161
|
+
element_data.should_not be_nil
|
162
|
+
element_data.should_not be_empty
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should get all devices via a user with a filter" do
|
166
|
+
element_data = user.device_instances({:name => device_instance.name})
|
167
|
+
|
168
|
+
element_data.should_not be_nil
|
169
|
+
element_data.should_not be_empty
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
4
|
+
MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
|
5
|
+
|
6
|
+
publisher_username = 'admin@csr.com'
|
7
|
+
publisher_password = 'password'
|
8
|
+
|
9
|
+
MachineShop.configure do |config|
|
10
|
+
config.db_name = "machineshop"
|
11
|
+
config.db_username="root"
|
12
|
+
config.db_password="root"
|
13
|
+
config.db_host= "localhost"
|
14
|
+
config.expiry_time= lambda{120.seconds.ago}
|
15
|
+
#second
|
16
|
+
end
|
17
|
+
|
18
|
+
# auth_token, user = MachineShop::User.authenticate(
|
19
|
+
# :email => publisher_username,
|
20
|
+
# :password => publisher_password
|
21
|
+
# )
|
22
|
+
|
23
|
+
# ap "auth_token #{auth_token}"
|
24
|
+
|
25
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
26
|
+
|
27
|
+
auth_token="2jzZmcHWLZyghsxcB16E"
|
28
|
+
# => admin
|
29
|
+
|
30
|
+
# auth_token="WPyus6qzPxaPbNN1V5qb" # => publisher
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
describe MachineShop::EndPoints do
|
35
|
+
element_data = MachineShop::EndPoints.all("v0",auth_token)
|
36
|
+
# # element_data = MachineShop::EndPoints.all({:namespace=>"secm"},auth_token)
|
37
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
4
|
+
MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
|
5
|
+
|
6
|
+
publisher_username = 'admin@csr.com'
|
7
|
+
publisher_password = 'password'
|
8
|
+
|
9
|
+
MachineShop.configure do |config|
|
10
|
+
config.db_name = "machineshop"
|
11
|
+
config.db_username="root"
|
12
|
+
config.db_password="root"
|
13
|
+
config.db_host= "localhost"
|
14
|
+
config.expiry_time= lambda{120.seconds.ago}
|
15
|
+
#second
|
16
|
+
end
|
17
|
+
|
18
|
+
auth_token, user = MachineShop::User.authenticate(
|
19
|
+
:email => publisher_username,
|
20
|
+
:password => publisher_password
|
21
|
+
)
|
22
|
+
# ap user
|
23
|
+
|
24
|
+
describe MachineShop::Mapping do
|
25
|
+
|
26
|
+
device = nil
|
27
|
+
|
28
|
+
it "should get a geocoded address" do
|
29
|
+
element_data = MachineShop::Mapping.geocode(
|
30
|
+
{
|
31
|
+
:latlng => "40.714224,-73.961452",
|
32
|
+
# :sensor => "false"
|
33
|
+
},
|
34
|
+
auth_token)
|
35
|
+
ap element_data.as_json
|
36
|
+
element_data.should_not be_nil
|
37
|
+
element_data.should_not be_empty
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
4
|
+
MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
|
5
|
+
|
6
|
+
#publisher_username = 'publisher@machineshop.com'
|
7
|
+
publisher_username = 'admin@csr.com'
|
8
|
+
publisher_password = 'password'
|
9
|
+
|
10
|
+
|
11
|
+
auth_token, user = MachineShop::User.authenticate(
|
12
|
+
:email => publisher_username,
|
13
|
+
:password => publisher_password
|
14
|
+
)
|
15
|
+
|
16
|
+
describe MachineShop::Mapping do
|
17
|
+
|
18
|
+
it "should get a geocoded address" do
|
19
|
+
ap "geocoding address"
|
20
|
+
element_data = MachineShop::Mapping.geocode(
|
21
|
+
{
|
22
|
+
:address => "1600 Amphitheatre Parkway, Mountain View, CA",
|
23
|
+
:sensor => "false"
|
24
|
+
},
|
25
|
+
auth_token)
|
26
|
+
|
27
|
+
ap element_data.as_json
|
28
|
+
#puts "GEO: #{element_data}"
|
29
|
+
|
30
|
+
element_data.should_not be_nil
|
31
|
+
element_data.should_not be_empty
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should get directions" do
|
35
|
+
ap "getting directions"
|
36
|
+
element_data = MachineShop::Mapping.directions(
|
37
|
+
{
|
38
|
+
:origin => "Denver",
|
39
|
+
:destination => "Boston",
|
40
|
+
:sensor => "false"
|
41
|
+
},
|
42
|
+
auth_token)
|
43
|
+
# ap element_data.as_json
|
44
|
+
#puts "GEO: #{element_data}"
|
45
|
+
|
46
|
+
element_data.should_not be_nil
|
47
|
+
element_data.should_not be_empty
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should get distance" do
|
51
|
+
ap "getting distance "
|
52
|
+
element_data = MachineShop::Mapping.distance(
|
53
|
+
{
|
54
|
+
:origins => "Vancouver BC",
|
55
|
+
:destinations => "San Francisco",
|
56
|
+
:mode => "bicycling",
|
57
|
+
:language => "fr-FR",
|
58
|
+
:sensor => "false"
|
59
|
+
},
|
60
|
+
auth_token)
|
61
|
+
ap element_data.as_json
|
62
|
+
#puts "GEO: #{element_data}"
|
63
|
+
|
64
|
+
element_data.should_not be_nil
|
65
|
+
element_data.should_not be_empty
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
4
|
+
MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
|
5
|
+
|
6
|
+
#publisher_username = 'publisher@machineshop.com'
|
7
|
+
publisher_username = 'admin@csr.com'
|
8
|
+
publisher_password = 'password'
|
9
|
+
|
10
|
+
|
11
|
+
auth_token, user = MachineShop::User.authenticate(
|
12
|
+
:email => publisher_username,
|
13
|
+
:password => publisher_password
|
14
|
+
)
|
15
|
+
|
16
|
+
element_data=nil
|
17
|
+
describe MachineShop::Meter do
|
18
|
+
|
19
|
+
it "should get all meter data" do
|
20
|
+
element_data = MachineShop::Meter.all({}, auth_token)
|
21
|
+
|
22
|
+
puts "element_data from all: #{element_data}"
|
23
|
+
|
24
|
+
element_data.should_not be_nil
|
25
|
+
element_data.should_not be_empty
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should get meter by id " do
|
29
|
+
|
30
|
+
meter_id = element_data[0].id
|
31
|
+
ap "retrieving meter for id #{meter_id}"
|
32
|
+
|
33
|
+
# element_data = MachineShop::Meter.retrieve(meter_id, auth_token)
|
34
|
+
element_data = MachineShop::Meter.retrieve(meter_id, auth_token)
|
35
|
+
puts "meter by id : #{element_data}"
|
36
|
+
element_data.should_not be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should get meters via a user" do
|
40
|
+
|
41
|
+
ap "meters by user "
|
42
|
+
element_data = user.meters
|
43
|
+
|
44
|
+
puts "meters via user: #{element_data}"
|
45
|
+
element_data.should_not be_nil
|
46
|
+
element_data.should_not be_empty
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
4
|
+
MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
|
5
|
+
|
6
|
+
#publisher_username = 'publisher@machineshop.com'
|
7
|
+
publisher_username = 'publisher@csr.com'
|
8
|
+
publisher_password = 'password'
|
9
|
+
|
10
|
+
|
11
|
+
auth_token, user = MachineShop::User.authenticate(
|
12
|
+
:email => publisher_username,
|
13
|
+
:password => publisher_password
|
14
|
+
)
|
15
|
+
|
16
|
+
reports=nil
|
17
|
+
describe MachineShop::Report do
|
18
|
+
|
19
|
+
it "should get all report data" do
|
20
|
+
element_data = MachineShop::Report.all({}, auth_token)
|
21
|
+
reports=element_data
|
22
|
+
puts "element_data: #{element_data}"
|
23
|
+
|
24
|
+
element_data.should_not be_nil
|
25
|
+
element_data.should_not be_empty
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
it "should get report of specific device" do
|
31
|
+
element_data = MachineShop::Report.all(
|
32
|
+
({:device_instance_id => '538461dc9818006e0900005e',
|
33
|
+
:per_page=>'1000',
|
34
|
+
#:created_at_between=>'2013-11-04T00:00:00_2014-03-19T17:02:00'
|
35
|
+
}), auth_token)
|
36
|
+
|
37
|
+
puts "element data of f00e5981800ad58000006 #{element_data} "
|
38
|
+
|
39
|
+
element_data.should_not be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should get specific report by id" do
|
43
|
+
specific_report_id=reports[0].id
|
44
|
+
element_data = MachineShop::Report.retrieve("5384800dff7346390c000001",auth_token)
|
45
|
+
|
46
|
+
puts "report specific #{element_data} "
|
47
|
+
|
48
|
+
element_data.should_not be_nil
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
4
|
+
MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
|
5
|
+
|
6
|
+
#publisher_username = 'publisher@machineshop.com'
|
7
|
+
publisher_username = 'admin@csr.com'
|
8
|
+
publisher_password = 'password'
|
9
|
+
|
10
|
+
MachineShop.configure do |config|
|
11
|
+
config.db_name = "machineshop"
|
12
|
+
config.db_username="root"
|
13
|
+
config.db_password="root"
|
14
|
+
config.db_host= "localhost"
|
15
|
+
config.expiry_time= lambda{10.seconds.ago}
|
16
|
+
#second
|
17
|
+
end
|
18
|
+
|
19
|
+
auth_token, user = MachineShop::User.authenticate(
|
20
|
+
:email => publisher_username,
|
21
|
+
:password => publisher_password
|
22
|
+
)
|
23
|
+
|
24
|
+
|
25
|
+
describe MachineShop::Rule do
|
26
|
+
|
27
|
+
rules=nil
|
28
|
+
|
29
|
+
it "should get all the rules " do
|
30
|
+
rules = MachineShop::Rule.all({},auth_token)
|
31
|
+
# puts "rules haru : #{rules}"
|
32
|
+
# ap "getting rules"
|
33
|
+
# ap rules.as_json
|
34
|
+
rules.should_not be_nil
|
35
|
+
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
it "should create rule" do
|
43
|
+
|
44
|
+
|
45
|
+
create_hash = {
|
46
|
+
:devices=>["52585e1d981800bab2000479"],
|
47
|
+
:device_instances=>[],
|
48
|
+
:rule=>{
|
49
|
+
:active=>true,
|
50
|
+
:description=>"bajratest",
|
51
|
+
:condition=>{
|
52
|
+
:type=>"and_rule_condition",
|
53
|
+
:rule_conditions=>[{
|
54
|
+
|
55
|
+
:property=>"var",
|
56
|
+
:value=>"30",
|
57
|
+
:type=>"equal_rule_condition"
|
58
|
+
|
59
|
+
}]
|
60
|
+
},
|
61
|
+
:then_actions=>[{
|
62
|
+
:priority=>"1",
|
63
|
+
:send_to=>"abc@me.com",
|
64
|
+
:type=>"email_rule_action"
|
65
|
+
}]
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
# ap "creating rule "
|
70
|
+
createdRule = MachineShop::Rule.create(create_hash,auth_token)
|
71
|
+
|
72
|
+
# ap createdRule.as_json
|
73
|
+
|
74
|
+
createdRule.should_not be_nil
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
specificRule = nil
|
79
|
+
|
80
|
+
it "should get rule by id" do
|
81
|
+
# ruleById = MachineShop::Rule.retrieve(rules[0].id,auth_token)
|
82
|
+
specificRule = MachineShop::Rule.retrieve("5395b4829818008e790000f9",auth_token)
|
83
|
+
# ap "retrieved rule"
|
84
|
+
# ap specificRule.as_json
|
85
|
+
specificRule.should_not be_nil
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should delete rule by" do
|
90
|
+
# ruleById = MachineShop::Rule.retrieve(rules[0].id,auth_token)
|
91
|
+
delete = specificRule.delete
|
92
|
+
# ap "Deleted rule"
|
93
|
+
# ap delete.as_json
|
94
|
+
delete.should_not be_nil
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should get get join rule conditions" do
|
99
|
+
test_data = MachineShop::Rule.get_join_rule_conditions(auth_token)
|
100
|
+
# puts "rule comparison : #{test_data.inspect}"
|
101
|
+
test_data.should_not be_nil
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
it "should get comparison rule_conditions" do
|
107
|
+
test_data = MachineShop::Rule.get_comparison_rule_conditions(auth_token)
|
108
|
+
# ap "comparison rule condition :"
|
109
|
+
# ap test_data.as_json
|
110
|
+
test_data.should_not be_nil
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
it "should get rule by device_id" do
|
116
|
+
test_data = MachineShop::Rule.get_by_device_instance(auth_token,'52585e1d981800bab2000478')
|
117
|
+
# ap "rule by_device_instance :"
|
118
|
+
# ap test_data.as_json
|
119
|
+
test_data.should_not be_nil
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should get deleted rule" do
|
124
|
+
test_data = MachineShop::Rule.get_deleted(auth_token)
|
125
|
+
# puts "deleted rule : #{test_data.inspect}"
|
126
|
+
test_data.should_not be_nil
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|