machineshop 0.0.4 → 1.0.0

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.
@@ -1,10 +1,20 @@
1
1
  require_relative '../spec_helper'
2
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
+
3
6
  #publisher_username = 'publisher@machineshop.com'
4
7
  publisher_username = 'admin@csr.com'
5
8
  publisher_password = 'password'
6
9
 
7
-
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
8
18
  auth_token, user = MachineShop::User.authenticate(
9
19
  :email => publisher_username,
10
20
  :password => publisher_password
@@ -20,8 +30,6 @@ describe MachineShop::Device do
20
30
  :per_page => 10},
21
31
  auth_token)
22
32
 
23
- ap "listing all devices"
24
- puts element_data
25
33
  device = element_data[0]
26
34
  device.should_not be_nil
27
35
  device.should be_kind_of MachineShop::Device
@@ -31,10 +39,8 @@ specificDevice = nil
31
39
 
32
40
 
33
41
  it "should get a device for the user by id" do
34
- specificDevice = MachineShop::Device.retrieve(device.id, auth_token)
42
+ specificDevice = MachineShop::Device.retrieve(device[:id], auth_token)
35
43
 
36
- ap "Device by id"
37
- ap specificDevice.as_json
38
44
  specificDevice.should_not be_nil
39
45
  specificDevice.should be_kind_of MachineShop::Device
40
46
  end
@@ -44,8 +50,6 @@ specificDevice = nil
44
50
  it "should delete device" do
45
51
  delete = specificDevice.delete
46
52
 
47
- ap "Delete Device by id"
48
- ap delete.as_json
49
53
  delete.http_code.should eq 200
50
54
  end
51
55
 
@@ -88,8 +92,6 @@ describe MachineShop::DeviceInstance do
88
92
  },
89
93
  auth_token)
90
94
 
91
- ap "device created:"
92
- ap device.as_json
93
95
 
94
96
  # Now create an instance
95
97
  device_instance = device.create_instance(
@@ -99,9 +101,6 @@ describe MachineShop::DeviceInstance do
99
101
  }
100
102
  )
101
103
 
102
- ap "creating device instance"
103
- ap device_instance.as_json
104
-
105
104
  device_instance.should_not be_nil
106
105
  device_instance.should be_kind_of MachineShop::DeviceInstance
107
106
  end
@@ -110,10 +109,6 @@ describe MachineShop::DeviceInstance do
110
109
  it "should get device instances" do
111
110
  element_data = MachineShop::DeviceInstance.all({}, auth_token)
112
111
 
113
- ap "getting all device instances"
114
-
115
- ap device_instance.as_json
116
-
117
112
  device_instance = element_data[0]
118
113
  element_data.should_not be_nil
119
114
  element_data.should_not be_empty
@@ -123,10 +118,7 @@ describe MachineShop::DeviceInstance do
123
118
 
124
119
 
125
120
  it "should get a device instance by id" do
126
- element_data = MachineShop::DeviceInstance.retrieve(device_instance.id, auth_token)
127
-
128
- ap "Device Instance by id: "
129
- ap element_data.as_json
121
+ element_data = MachineShop::DeviceInstance.retrieve("5395835f385f7f53ec000160", auth_token)
130
122
 
131
123
  element_data.should_not be_nil
132
124
  element_data.should be_kind_of MachineShop::DeviceInstance
@@ -135,9 +127,6 @@ describe MachineShop::DeviceInstance do
135
127
  it "should get a device instance by name" do
136
128
  element_data = MachineShop::DeviceInstance.all({:name => device_instance.name}, auth_token)
137
129
 
138
- ap "Device Instance by name: "
139
- ap element_data.as_json
140
-
141
130
  element_data.should_not be_nil
142
131
  element_data.should_not be_empty
143
132
  end
@@ -145,9 +134,6 @@ describe MachineShop::DeviceInstance do
145
134
  it "should get all devices via a user" do
146
135
  element_data = user.device_instances
147
136
 
148
- ap "Device Instance via user "
149
- ap element_data.as_json
150
-
151
137
  element_data.should_not be_nil
152
138
  element_data.should_not be_empty
153
139
  end
@@ -1,5 +1,8 @@
1
1
  require_relative '../spec_helper'
2
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
+
3
6
  #publisher_username = 'publisher@machineshop.com'
4
7
  publisher_username = 'admin@csr.com'
5
8
  publisher_password = 'password'
@@ -13,7 +16,6 @@ publisher_password = 'password'
13
16
  describe MachineShop::Mapping do
14
17
 
15
18
  it "should get a geocoded address" do
16
- ap "geocoding address"
17
19
  element_data = MachineShop::Mapping.geocode(
18
20
  {
19
21
  :address => "1600 Amphitheatre Parkway, Mountain View, CA",
@@ -21,15 +23,11 @@ describe MachineShop::Mapping do
21
23
  },
22
24
  auth_token)
23
25
 
24
- ap element_data.as_json
25
- #puts "GEO: #{element_data}"
26
-
27
26
  element_data.should_not be_nil
28
27
  element_data.should_not be_empty
29
28
  end
30
29
 
31
30
  it "should get directions" do
32
- ap "getting directions"
33
31
  element_data = MachineShop::Mapping.directions(
34
32
  {
35
33
  :origin => "Denver",
@@ -37,15 +35,12 @@ ap element_data.as_json
37
35
  :sensor => "false"
38
36
  },
39
37
  auth_token)
40
- # ap element_data.as_json
41
- #puts "GEO: #{element_data}"
42
38
 
43
39
  element_data.should_not be_nil
44
40
  element_data.should_not be_empty
45
41
  end
46
42
 
47
43
  it "should get distance" do
48
- ap "getting distance "
49
44
  element_data = MachineShop::Mapping.distance(
50
45
  {
51
46
  :origins => "Vancouver BC",
@@ -55,9 +50,6 @@ ap element_data.as_json
55
50
  :sensor => "false"
56
51
  },
57
52
  auth_token)
58
- ap element_data.as_json
59
- #puts "GEO: #{element_data}"
60
-
61
53
  element_data.should_not be_nil
62
54
  element_data.should_not be_empty
63
55
  end
@@ -1,5 +1,8 @@
1
1
  require_relative '../spec_helper'
2
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
+
3
6
  #publisher_username = 'publisher@machineshop.com'
4
7
  publisher_username = 'admin@csr.com'
5
8
  publisher_password = 'password'
@@ -16,8 +19,6 @@ describe MachineShop::Meter do
16
19
  it "should get all meter data" do
17
20
  element_data = MachineShop::Meter.all({}, auth_token)
18
21
 
19
- puts "element_data from all: #{element_data}"
20
-
21
22
  element_data.should_not be_nil
22
23
  element_data.should_not be_empty
23
24
  end
@@ -25,20 +26,14 @@ describe MachineShop::Meter do
25
26
  it "should get meter by id " do
26
27
 
27
28
  meter_id = element_data[0].id
28
- ap "retrieving meter for id #{meter_id}"
29
-
30
- # element_data = MachineShop::Meter.retrieve(meter_id, auth_token)
31
29
  element_data = MachineShop::Meter.retrieve(meter_id, auth_token)
32
- puts "meter by id : #{element_data}"
33
30
  element_data.should_not be_nil
34
31
  end
35
32
 
36
33
  it "should get meters via a user" do
37
34
 
38
- ap "meters by user "
39
35
  element_data = user.meters
40
36
 
41
- puts "meters via user: #{element_data}"
42
37
  element_data.should_not be_nil
43
38
  element_data.should_not be_empty
44
39
  end
@@ -1,5 +1,7 @@
1
1
  require_relative '../spec_helper'
2
2
 
3
+ #MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
4
+ MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
3
5
 
4
6
  #publisher_username = 'publisher@machineshop.com'
5
7
  publisher_username = 'publisher@csr.com'
@@ -17,10 +19,6 @@ describe MachineShop::Report do
17
19
  it "should get all report data" do
18
20
  element_data = MachineShop::Report.all({}, auth_token)
19
21
  reports=element_data
20
-
21
- puts "yaaaaaaaaaaaaaaaaaaaaa"
22
- puts "element_data: #{element_data}"
23
-
24
22
  element_data.should_not be_nil
25
23
  element_data.should_not be_empty
26
24
  end
@@ -34,8 +32,6 @@ puts "yaaaaaaaaaaaaaaaaaaaaa"
34
32
  #:created_at_between=>'2013-11-04T00:00:00_2014-03-19T17:02:00'
35
33
  }), auth_token)
36
34
 
37
- puts "element data of f00e5981800ad58000006 #{element_data} "
38
-
39
35
  element_data.should_not be_nil
40
36
  end
41
37
 
@@ -43,8 +39,6 @@ puts "yaaaaaaaaaaaaaaaaaaaaa"
43
39
  specific_report_id=reports[0].id
44
40
  element_data = MachineShop::Report.retrieve("5384800dff7346390c000001",auth_token)
45
41
 
46
- puts "report specific #{element_data} "
47
-
48
42
  element_data.should_not be_nil
49
43
  end
50
44
 
@@ -1,76 +1,71 @@
1
1
  require_relative '../spec_helper'
2
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'
3
7
  publisher_username = 'admin@csr.com'
4
8
  publisher_password = 'password'
5
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
6
18
 
7
- auth_token, user = MachineShop::User.authenticate(
8
- :email => publisher_username,
9
- :password => publisher_password
10
- )
19
+ auth_token, user = MachineShop::User.authenticate(
20
+ :email => publisher_username,
21
+ :password => publisher_password
22
+ )
11
23
 
12
24
 
13
25
  describe MachineShop::Rule do
14
26
 
15
27
  rules=nil
16
-
28
+
17
29
  it "should get all the rules " do
18
30
  rules = MachineShop::Rule.all({},auth_token)
19
- # puts "rules haru : #{rules}"
20
- ap "getting rules"
21
- puts rules
22
- ap rules.as_json
23
31
  rules.should_not be_nil
24
-
25
-
26
32
  end
27
33
 
28
-
29
-
30
-
31
34
  it "should create rule" do
32
35
 
33
-
34
- create_hash = {
36
+ create_hash = {
35
37
  :devices=>["52585e1d981800bab2000479"],
36
38
  :device_instances=>[],
37
39
  :rule=>{
38
- :active=>true,
39
- :description=>"bajratest",
40
- :condition=>{
41
- :type=>"and_rule_condition",
42
- :rule_conditions=>[{
43
-
44
- :property=>"var",
45
- :value=>"30",
46
- :type=>"equal_rule_condition"
47
-
48
- }]
49
- },
50
- :then_actions=>[{
51
- :priority=>"1",
52
- :send_to=>"abc@me.com",
53
- :type=>"email_rule_action"
40
+ :active=>true,
41
+ :description=>"bajratest",
42
+ :condition=>{
43
+ :type=>"and_rule_condition",
44
+ :rule_conditions=>[{
45
+
46
+ :property=>"var",
47
+ :value=>"30",
48
+ :type=>"equal_rule_condition"
49
+
54
50
  }]
51
+ },
52
+ :then_actions=>[{
53
+ :priority=>"1",
54
+ :send_to=>"abc@me.com",
55
+ :type=>"email_rule_action"
56
+ }]
55
57
  }
56
- }
58
+ }
57
59
 
58
- ap "creating rule "
59
60
  createdRule = MachineShop::Rule.create(create_hash,auth_token)
60
-
61
- ap createdRule.as_json
62
-
63
61
  createdRule.should_not be_nil
64
62
 
65
63
  end
66
64
 
67
65
  specificRule = nil
68
-
66
+
69
67
  it "should get rule by id" do
70
- # ruleById = MachineShop::Rule.retrieve(rules[0].id,auth_token)
71
68
  specificRule = MachineShop::Rule.retrieve("5395b4829818008e790000f9",auth_token)
72
- ap "retrieved rule"
73
- ap specificRule.as_json
74
69
  specificRule.should_not be_nil
75
70
 
76
71
  end
@@ -78,15 +73,12 @@ ap createdRule.as_json
78
73
  it "should delete rule by" do
79
74
  # ruleById = MachineShop::Rule.retrieve(rules[0].id,auth_token)
80
75
  delete = specificRule.delete
81
- ap "Deleted rule"
82
- ap delete.as_json
83
76
  delete.should_not be_nil
84
77
 
85
78
  end
86
79
 
87
80
  it "should get get join rule conditions" do
88
81
  test_data = MachineShop::Rule.get_join_rule_conditions(auth_token)
89
- puts "rule comparison : #{test_data.inspect}"
90
82
  test_data.should_not be_nil
91
83
 
92
84
  end
@@ -94,9 +86,6 @@ ap createdRule.as_json
94
86
 
95
87
  it "should get comparison rule_conditions" do
96
88
  test_data = MachineShop::Rule.get_comparison_rule_conditions(auth_token)
97
- ap "comparison rule condition :"
98
- ap test_data.as_json
99
- puts test_data
100
89
  test_data.should_not be_nil
101
90
 
102
91
  end
@@ -104,18 +93,14 @@ ap createdRule.as_json
104
93
 
105
94
  it "should get rule by device_id" do
106
95
  test_data = MachineShop::Rule.get_by_device_instance(auth_token,'52585e1d981800bab2000478')
107
- ap "rule by_device_instance :"
108
- puts test_data
109
- ap test_data.as_json
110
96
  test_data.should_not be_nil
111
97
 
112
98
  end
113
99
 
114
100
  it "should get deleted rule" do
115
101
  test_data = MachineShop::Rule.get_deleted(auth_token)
116
- puts "deleted rule : #{test_data.inspect}"
117
102
  test_data.should_not be_nil
118
103
 
119
104
  end
120
-
105
+
121
106
  end
@@ -0,0 +1,47 @@
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
+ describe MachineShop::Device do
24
+
25
+ device = nil
26
+
27
+ it "should get all devices for the user" do
28
+
29
+
30
+
31
+ element_data = MachineShop::Device.all(
32
+ {:page => 1,
33
+ :per_page => 10,
34
+ :name=>"my_device"
35
+ },
36
+ auth_token)
37
+
38
+ device = element_data[0]
39
+ device.should_not be_nil
40
+ device.should be_kind_of MachineShop::Device
41
+
42
+ end
43
+ end
44
+
45
+
46
+
47
+
@@ -1,6 +1,10 @@
1
1
  require_relative '../spec_helper'
2
2
 
3
3
 
4
+ #MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
5
+ MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
6
+
7
+ #publisher_username = 'publisher@machineshop.com'
4
8
  publisher_username = 'admin@csr.com'
5
9
  publisher_password = 'password'
6
10
 
@@ -15,8 +19,6 @@ describe MachineShop::User do
15
19
  :password => publisher_password
16
20
  )
17
21
 
18
- ap "User Data"
19
- ap user.as_json
20
22
  auth_token.should_not be_nil
21
23
  user.should_not be_nil
22
24
  user.should be_kind_of MachineShop::User
@@ -25,17 +27,11 @@ describe MachineShop::User do
25
27
  it "should get all roles from a static instance" do
26
28
  element_data = MachineShop::User.all_roles(auth_token)
27
29
 
28
- ap "all_roles: "
29
- ap element_data.as_json
30
- puts element_data
31
-
32
30
  element_data.should_not be_nil
33
31
  end
34
32
 
35
33
  it "should get all roles from a user instance" do
36
34
 
37
- ap " here user is : "
38
- ap user.as_json
39
35
  element_data = user.all_roles
40
36
  element_data.should_not be_nil
41
37
  end
@@ -43,9 +39,6 @@ describe MachineShop::User do
43
39
  it "should get a user for the user by id" do
44
40
  element_data = MachineShop::User.retrieve(user.id, auth_token)
45
41
 
46
- ap "user retrieve"
47
- ap element_data.as_json
48
-
49
42
  element_data.should_not be_nil
50
43
  element_data.should be_kind_of MachineShop::User
51
44
  end