machineshop 1.0.2 → 1.1.1
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 +4 -4
- data/.gitignore +45 -0
- data/{Gemfile → machineshop/Gemfile} +0 -0
- data/{LICENSE → machineshop/LICENSE} +0 -0
- data/{Rakefile → machineshop/Rakefile} +0 -0
- data/{doc.txt → machineshop/doc.txt} +0 -0
- data/{lib → machineshop/lib}/machineshop.rb +29 -18
- data/{lib → machineshop/lib}/machineshop/api_operations/create.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/api_operations/delete.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/api_operations/list.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/api_operations/update.rb +0 -0
- data/machineshop/lib/machineshop/api_proxies.rb +20 -0
- data/{lib → machineshop/lib}/machineshop/api_resource.rb +1 -1
- data/{lib → machineshop/lib}/machineshop/configuration.rb +2 -1
- data/machineshop/lib/machineshop/custom_api.rb +28 -0
- data/machineshop/lib/machineshop/custom_apis.rb +21 -0
- data/{lib → machineshop/lib}/machineshop/customer.rb +1 -1
- data/machineshop/lib/machineshop/customers.rb +20 -0
- data/{lib → machineshop/lib}/machineshop/data_source_types.rb +12 -2
- data/machineshop/lib/machineshop/data_sources.rb +57 -0
- data/{lib → machineshop/lib}/machineshop/database.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/device.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/device_instance.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/end_points.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/errors/api_connection_error.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/errors/api_error.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/errors/authentication_error.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/errors/database_error.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/errors/invalid_request_error.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/errors/machineshop_error.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/errors/schema_error.rb +0 -0
- data/machineshop/lib/machineshop/gateway_configs.rb +34 -0
- data/machineshop/lib/machineshop/gateway_data_source_types.rb +18 -0
- data/machineshop/lib/machineshop/gateway_data_sources.rb +60 -0
- data/{lib → machineshop/lib}/machineshop/json.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/machineshop_cache.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/machineshop_object.rb +7 -2
- data/{lib → machineshop/lib}/machineshop/mapping.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/meter.rb +1 -2
- data/{lib → machineshop/lib}/machineshop/models/api_endpoint.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/models/api_request.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/models/schema.rb +2 -1
- data/machineshop/lib/machineshop/monitor.rb +39 -0
- data/machineshop/lib/machineshop/report.rb +11 -0
- data/{lib/machineshop/report.rb → machineshop/lib/machineshop/reports.rb} +3 -1
- data/machineshop/lib/machineshop/routes.rb +29 -0
- data/{lib → machineshop/lib}/machineshop/rule.rb +0 -0
- data/machineshop/lib/machineshop/rules.rb +56 -0
- data/{lib → machineshop/lib}/machineshop/user.rb +22 -4
- data/machineshop/lib/machineshop/users.rb +81 -0
- data/{lib → machineshop/lib}/machineshop/util.rb +22 -11
- data/{lib → machineshop/lib}/machineshop/utility.rb +0 -0
- data/{lib → machineshop/lib}/machineshop/version.rb +1 -1
- data/{machineshop.gemspec → machineshop/machineshop.gemspec} +2 -1
- data/{spec → machineshop/spec}/lib/api_calls_spec.rb +0 -0
- data/machineshop/spec/lib/api_proxies_spec.rb +91 -0
- data/machineshop/spec/lib/custom_api_spec.rb +0 -0
- data/machineshop/spec/lib/custom_api_vo_spec.rb +77 -0
- data/{spec → machineshop/spec}/lib/custom_endpoint_test.rb +0 -0
- data/{spec → machineshop/spec}/lib/customer_spec.rb +21 -8
- data/{spec → machineshop/spec}/lib/data_source.rb +0 -0
- data/{spec → machineshop/spec}/lib/data_source_type_spec.rb +0 -0
- data/{spec → machineshop/spec}/lib/database_spec.rb +0 -0
- data/{spec → machineshop/spec}/lib/device_instances.rb +0 -0
- data/{spec → machineshop/spec}/lib/device_spec.rb +0 -0
- data/{spec → machineshop/spec}/lib/endpoint_spec.rb +0 -0
- data/{spec → machineshop/spec}/lib/geocode_spec +0 -0
- data/machineshop/spec/lib/logo_spec.rb +51 -0
- data/{spec → machineshop/spec}/lib/mapping_spec.rb +0 -0
- data/{spec → machineshop/spec}/lib/meter_spec.rb +3 -3
- data/machineshop/spec/lib/monitor_spec.rb +50 -0
- data/machineshop/spec/lib/new_api_key.rb +28 -0
- data/machineshop/spec/lib/report_spec.rb +91 -0
- data/machineshop/spec/lib/reports_v1_spec.rb +65 -0
- data/machineshop/spec/lib/routes_spec.rb +26 -0
- data/{spec → machineshop/spec}/lib/rule_spec.rb +30 -24
- data/machineshop/spec/lib/user_spec.rb +99 -0
- data/machineshop/spec/lib/v1_rules_spec.rb +106 -0
- data/{spec → machineshop/spec}/spec_helper.rb +0 -0
- metadata +115 -110
- data/.idea/.name +0 -1
- data/.idea/.rakeTasks +0 -7
- data/.idea/compiler.xml +0 -23
- data/.idea/copyright/profiles_settings.xml +0 -5
- data/.idea/encodings.xml +0 -5
- data/.idea/inspectionProfiles/Project_Default.xml +0 -7
- data/.idea/inspectionProfiles/profiles_settings.xml +0 -7
- data/.idea/machineshop.iml +0 -194
- data/.idea/misc.xml +0 -5
- data/.idea/modules.xml +0 -9
- data/.idea/scopes/scope_settings.xml +0 -5
- data/.idea/vcs.xml +0 -7
- data/.idea/workspace.xml +0 -722
- data/lib/machineshop/data_sources.rb +0 -35
- data/lib/machineshop/users.rb +0 -43
- data/spec/lib/report_spec.rb +0 -52
- data/spec/lib/user_spec.rb +0 -58
File without changes
|
@@ -27,7 +27,8 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.add_dependency 'rest-client'#, '~> 1.6.7'
|
28
28
|
gem.add_dependency('multi_json', '>= 1.0.4', '< 2')
|
29
29
|
# gem.add_dependency('activerecord', '>= 4.1.1')
|
30
|
-
gem.add_dependency('activerecord', '>=
|
30
|
+
gem.add_dependency('activerecord', '>= 3.2.12')
|
31
|
+
# gem.add_dependency('activerecord', '>= 4.0.0')
|
31
32
|
gem.required_ruby_version = '>= 1.9.3'
|
32
33
|
gem.post_install_message = "Thanks for installing Machineshop gem, Enjoy!!"
|
33
34
|
gem.requirements << 'mysql, activerecord'
|
File without changes
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
5
|
+
MachineShop.api_base_url= 'localhost:3000/api/v1'
|
6
|
+
|
7
|
+
#publisher_username = 'publisher@machineshop.com'
|
8
|
+
publisher_username = 'publisher@csr.com'
|
9
|
+
publisher_password = 'password'
|
10
|
+
|
11
|
+
|
12
|
+
auth_token, user = MachineShop::Users.authenticate(
|
13
|
+
:email => publisher_username,
|
14
|
+
:password => publisher_password
|
15
|
+
)
|
16
|
+
|
17
|
+
ApiProxies = nil
|
18
|
+
describe MachineShop::ApiProxies do
|
19
|
+
|
20
|
+
it "should get all the ApiProxies " do
|
21
|
+
ApiProxies = MachineShop::ApiProxies.all({}, auth_token)
|
22
|
+
|
23
|
+
ap "Listing custom apis"
|
24
|
+
|
25
|
+
ap ApiProxies
|
26
|
+
ApiProxies.should_not be_nil
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
it "should delete custom api " do
|
31
|
+
ap "deleting #{ApiProxies[0].id}"
|
32
|
+
delete = MachineShop::ApiProxies.delete(ApiProxies[0].id,auth_token)
|
33
|
+
ap delete
|
34
|
+
expect(delete[:http_code]).to equal(200)
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
specific_api_proxies = nil
|
41
|
+
|
42
|
+
it "should create api_proxies " do
|
43
|
+
|
44
|
+
create_hash = {
|
45
|
+
:name=> "abcde_daefault",
|
46
|
+
:method=> "get",
|
47
|
+
:endpoint=> "endpoint/end12",
|
48
|
+
:base_domain =>"localhost:3000",
|
49
|
+
:protocol=>"http",
|
50
|
+
:signature=>"singature1235"
|
51
|
+
|
52
|
+
}
|
53
|
+
|
54
|
+
specific_api_proxies = MachineShop::ApiProxies.create(create_hash,auth_token)
|
55
|
+
|
56
|
+
ap "created api_proxies is"
|
57
|
+
ap specific_api_proxies.as_json
|
58
|
+
specific_api_proxies.should_not be_nil
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
retrieved_api=nil
|
63
|
+
it "should get api_proxies by api_proxies id " do
|
64
|
+
# ap "looking up api_proxies before:"
|
65
|
+
# ap specific_api_proxies.as_json
|
66
|
+
|
67
|
+
retrieved_api = MachineShop::ApiProxies.retrieve(specific_api_proxies.name, auth_token)
|
68
|
+
|
69
|
+
ap "looking up api_proxies after:"
|
70
|
+
ap retrieved_api
|
71
|
+
|
72
|
+
retrieved_api.should_not be_nil
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
it "should update the api_proxies with id " do
|
77
|
+
|
78
|
+
update_hash = {
|
79
|
+
:name=> "dabcd_ault",
|
80
|
+
:method=> "delete",
|
81
|
+
:endpoint=> "endpoint/end12",
|
82
|
+
:base_domain =>"localhost:3000",
|
83
|
+
:protocol=>"http"
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
ap "updating api_proxies with id : #{specific_api_proxies.id}"
|
88
|
+
update = MachineShop::ApiProxies.update(specific_api_proxies.id,auth_token,update_hash)
|
89
|
+
ap update
|
90
|
+
end
|
91
|
+
end
|
File without changes
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
5
|
+
MachineShop.api_base_url= 'localhost:3000/api/v0'
|
6
|
+
|
7
|
+
#publisher_username = 'publisher@machineshop.com'
|
8
|
+
publisher_username = 'publisher@csr.com'
|
9
|
+
publisher_password = 'password'
|
10
|
+
|
11
|
+
|
12
|
+
auth_token, user = MachineShop::User.authenticate(
|
13
|
+
:email => publisher_username,
|
14
|
+
:password => publisher_password
|
15
|
+
)
|
16
|
+
describe MachineShop::CustomApi do
|
17
|
+
|
18
|
+
it "should get all the CustomApi " do
|
19
|
+
CustomApi = MachineShop::CustomApi.all({}, auth_token)
|
20
|
+
|
21
|
+
ap "Listing custom apis"
|
22
|
+
|
23
|
+
ap CustomApi
|
24
|
+
CustomApi.should_not be_nil
|
25
|
+
end
|
26
|
+
|
27
|
+
specificcustom_apis = nil
|
28
|
+
|
29
|
+
it "should create custom_apis " do
|
30
|
+
|
31
|
+
create_hash = {
|
32
|
+
:name=> "abcde_daefault",
|
33
|
+
:method=> "get",
|
34
|
+
:endpoint=> "endpoint/end12",
|
35
|
+
:base_domain =>"localhost:3000",
|
36
|
+
:protocol=>"http"
|
37
|
+
|
38
|
+
}
|
39
|
+
|
40
|
+
specificcustom_apis = MachineShop::CustomApi.create(create_hash,auth_token)
|
41
|
+
|
42
|
+
ap "created custom_apis is"
|
43
|
+
ap specificcustom_apis.as_json
|
44
|
+
specificcustom_apis.should_not be_nil
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
retrieved_api=nil
|
49
|
+
it "should get custom_apis by custom_apis id " do
|
50
|
+
# ap "looking up custom_apis before:"
|
51
|
+
# ap specificcustom_apis.as_json
|
52
|
+
|
53
|
+
retrieved_api = MachineShop::CustomApi.retrieve(specificcustom_apis.name, auth_token)
|
54
|
+
|
55
|
+
ap "looking up custom_apis after:"
|
56
|
+
ap retrieved_api
|
57
|
+
|
58
|
+
retrieved_api.should_not be_nil
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
it "should update the custom_apis with id " do
|
63
|
+
|
64
|
+
update_hash = {
|
65
|
+
:name=> "dabcd_ault",
|
66
|
+
:method=> "delete",
|
67
|
+
:endpoint=> "endpoint/end12",
|
68
|
+
:base_domain =>"localhost:3000",
|
69
|
+
:protocol=>"http"
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
ap "updating custom_apis with id : #{specificcustom_apis.id}"
|
74
|
+
update = MachineShop::CustomApi.update(specificcustom_apis.name,auth_token,update_hash)
|
75
|
+
ap update
|
76
|
+
end
|
77
|
+
end
|
File without changes
|
@@ -2,21 +2,21 @@ require_relative '../spec_helper'
|
|
2
2
|
|
3
3
|
|
4
4
|
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
5
|
-
MachineShop.api_base_url= '
|
5
|
+
MachineShop.api_base_url= 'localhost:3000/api/v1'
|
6
6
|
|
7
7
|
#publisher_username = 'publisher@machineshop.com'
|
8
|
-
publisher_username = '
|
8
|
+
publisher_username = 'publisher@csr.com'
|
9
9
|
publisher_password = 'password'
|
10
10
|
|
11
11
|
|
12
|
-
auth_token, user = MachineShop::
|
12
|
+
auth_token, user = MachineShop::Users.authenticate(
|
13
13
|
:email => publisher_username,
|
14
14
|
:password => publisher_password
|
15
15
|
)
|
16
|
-
describe MachineShop::
|
16
|
+
describe MachineShop::Customers do
|
17
17
|
|
18
18
|
it "should get all the customers " do
|
19
|
-
customers = MachineShop::
|
19
|
+
customers = MachineShop::Customers.all({}, auth_token)
|
20
20
|
|
21
21
|
puts "customers are #{customers}"
|
22
22
|
|
@@ -28,7 +28,7 @@ describe MachineShop::Customer do
|
|
28
28
|
specificCustomer = nil
|
29
29
|
it "should create customer " do
|
30
30
|
|
31
|
-
specificCustomer = MachineShop::
|
31
|
+
specificCustomer = MachineShop::Customers.create({:email=>"bajratests@bajratechnologies.com",
|
32
32
|
:password=>'password',
|
33
33
|
:notification_method=>'sms',
|
34
34
|
:first_name=>'niroj',:last_name=>'sapkota',
|
@@ -48,7 +48,7 @@ describe MachineShop::Customer do
|
|
48
48
|
ap "looking up customer before:"
|
49
49
|
ap specificCustomer.as_json
|
50
50
|
|
51
|
-
retrieved_cust = MachineShop::
|
51
|
+
retrieved_cust = MachineShop::Customers.retrieve(specificCustomer.id, auth_token)
|
52
52
|
|
53
53
|
ap "looking up customer after:"
|
54
54
|
ap retrieved_cust.as_json
|
@@ -60,7 +60,7 @@ describe MachineShop::Customer do
|
|
60
60
|
it "should update the customer with id " do
|
61
61
|
|
62
62
|
ap "updating customer with id : #{specificCustomer.id}"
|
63
|
-
update = MachineShop::
|
63
|
+
update = MachineShop::Customers.update(specificCustomer.id,auth_token,{:notification_method => 'email',:first_name=>'testJohn'})
|
64
64
|
ap update.as_json
|
65
65
|
end
|
66
66
|
|
@@ -74,6 +74,19 @@ describe MachineShop::Customer do
|
|
74
74
|
|
75
75
|
#success test
|
76
76
|
|
77
|
+
|
78
|
+
it "should delete customer without creating instance " do
|
79
|
+
|
80
|
+
#puts
|
81
|
+
puts "deleting customer with id : #{specificCustomer.id}"
|
82
|
+
|
83
|
+
delete = MachineShop::Customers.delete(specificCustomer.id, auth_token)
|
84
|
+
#delete = MachineShop::Customer.delete(customers[0].id,auth_token)
|
85
|
+
puts "delete #{delete}"
|
86
|
+
delete[:http_code].should eq 200
|
87
|
+
end
|
88
|
+
|
89
|
+
|
77
90
|
it "should delete customer with id " do
|
78
91
|
|
79
92
|
#puts
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
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
|
+
MachineShop.api_base_url= 'localhost:3000/api/v1'
|
7
|
+
|
8
|
+
#publisher_username = 'publisher@machineshop.com'
|
9
|
+
publisher_username = 'publisher@csr.com'
|
10
|
+
publisher_password = 'password'
|
11
|
+
|
12
|
+
describe MachineShop::Users do
|
13
|
+
auth_token = nil
|
14
|
+
user = nil
|
15
|
+
|
16
|
+
it "should allow a user to authenticate" do
|
17
|
+
auth_token.should be_nil
|
18
|
+
|
19
|
+
begin
|
20
|
+
|
21
|
+
auth_token, user = MachineShop::Users.authenticate(
|
22
|
+
:email => publisher_username,
|
23
|
+
:password => publisher_password
|
24
|
+
)
|
25
|
+
|
26
|
+
rescue Exception => e
|
27
|
+
ap e.message
|
28
|
+
end
|
29
|
+
|
30
|
+
auth_token.should_not be_nil
|
31
|
+
user.should_not be_nil
|
32
|
+
user.should be_kind_of MachineShop::Users
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
it "should create logo" do
|
38
|
+
tmpfile = "abc.png"
|
39
|
+
logo = File.open(tmpfile, "r")
|
40
|
+
logoHash = {logo: logo}
|
41
|
+
begin
|
42
|
+
logoupload = MachineShop::Users.create_user_logo(user.id,logoHash, auth_token)
|
43
|
+
|
44
|
+
rescue Exception => e
|
45
|
+
ap e
|
46
|
+
end
|
47
|
+
|
48
|
+
ap logoupload
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
File without changes
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require_relative '../spec_helper'
|
2
2
|
|
3
3
|
#MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
|
4
|
-
MachineShop.api_base_url= '
|
4
|
+
MachineShop.api_base_url= 'localhost:3000/api/v1'
|
5
5
|
|
6
6
|
#publisher_username = 'publisher@machineshop.com'
|
7
|
-
publisher_username = '
|
7
|
+
publisher_username = 'publisher@csr.com'
|
8
8
|
publisher_password = 'password'
|
9
9
|
|
10
10
|
|
11
|
-
auth_token, user = MachineShop::
|
11
|
+
auth_token, user = MachineShop::Users.authenticate(
|
12
12
|
:email => publisher_username,
|
13
13
|
:password => publisher_password
|
14
14
|
)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
MachineShop.api_base_url= 'localhost:3000/api/v1'
|
4
|
+
publisher_username = 'publisher@csr.com'
|
5
|
+
publisher_password = 'password'
|
6
|
+
|
7
|
+
auth_token, user = MachineShop::Users.authenticate(
|
8
|
+
:email => publisher_username,
|
9
|
+
:password => publisher_password
|
10
|
+
)
|
11
|
+
|
12
|
+
element_data=nil
|
13
|
+
describe MachineShop::Monitor do
|
14
|
+
|
15
|
+
it "should get all monitor data" do
|
16
|
+
element_data = MachineShop::Monitor.all({}, auth_token)
|
17
|
+
|
18
|
+
# puts "element_data from all: #{element_data}"
|
19
|
+
|
20
|
+
expect(element_data).not_to be_nil
|
21
|
+
expect(element_data).not_to be_empty
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should get monitor by id " do
|
25
|
+
|
26
|
+
monitor_id = element_data[0].id
|
27
|
+
ap "retrieving monitor for id #{monitor_id}"
|
28
|
+
|
29
|
+
# element_data = MachineShop::Monitor.retrieve(monitor_id, auth_token)
|
30
|
+
element_data = MachineShop::Monitor.retrieve(monitor_id, auth_token)
|
31
|
+
# puts "monitor by id : #{element_data}"
|
32
|
+
expect(element_data).not_to be_nil
|
33
|
+
# element_data.should_not be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it "rule_last_run_summary" do
|
37
|
+
summary = MachineShop::Monitor.rule_last_run_summary(auth_token)
|
38
|
+
ap "rule last run summary"
|
39
|
+
ap summary
|
40
|
+
expect(summary).not_to be_nil
|
41
|
+
end
|
42
|
+
|
43
|
+
it "total_reports_per_day" do
|
44
|
+
total_reports_per_day = MachineShop::Monitor.total_reports_per_day("2014-06-01", "2014-08-01",auth_token)
|
45
|
+
ap "rule total_reports_per_day"
|
46
|
+
ap total_reports_per_day
|
47
|
+
expect(total_reports_per_day).not_to be_nil
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
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
|
+
MachineShop.api_base_url= 'localhost:3000/api/v1'
|
7
|
+
|
8
|
+
#publisher_username = 'publisher@machineshop.com'
|
9
|
+
publisher_username = 'abcd@customer.com'
|
10
|
+
publisher_password = 'password'
|
11
|
+
|
12
|
+
describe MachineShop::Users do
|
13
|
+
auth_token = nil
|
14
|
+
user = nil
|
15
|
+
|
16
|
+
|
17
|
+
it "should get the versions where user exists" do
|
18
|
+
|
19
|
+
versions = MachineShop::Users.check_user_versions({:email=>"publisher@csr.com", :password=>"password"})
|
20
|
+
ap versions
|
21
|
+
end
|
22
|
+
|
23
|
+
# it "should reset the auth_token" do
|
24
|
+
# reset = MachineShop::Users.new_api_key("543fa688faf3d9e82300003a","UsfxTwV5zptYgCj8pheR")
|
25
|
+
# ap reset
|
26
|
+
# end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,91 @@
|
|
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
|
+
MachineShop.api_base_url= 'http://localhost:3000/api/v1'
|
6
|
+
|
7
|
+
#publisher_username = 'publisher@machineshop.com'
|
8
|
+
publisher_username = 'publisher@csr.com'
|
9
|
+
publisher_password = 'password'
|
10
|
+
|
11
|
+
|
12
|
+
auth_token, user = MachineShop::Users.authenticate(
|
13
|
+
:email => publisher_username,
|
14
|
+
:password => publisher_password
|
15
|
+
)
|
16
|
+
|
17
|
+
reports=nil
|
18
|
+
|
19
|
+
describe MachineShop::Reports do
|
20
|
+
|
21
|
+
|
22
|
+
it "should create report" do
|
23
|
+
|
24
|
+
report_json = {
|
25
|
+
:data_source_id=>"asdfds",
|
26
|
+
:device_datetime=> "2014-8-24 15:22:27",
|
27
|
+
:raw_data=> "video on",
|
28
|
+
:payload=> {
|
29
|
+
:video=> "1",
|
30
|
+
:test_new=> "Demo test 10"
|
31
|
+
}
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
ret = MachineShop::Reports.create(report_json, auth_token)
|
36
|
+
ap ret
|
37
|
+
|
38
|
+
|
39
|
+
# create_hash = {
|
40
|
+
# :devices=>["52585e1d981800bab2000479"],
|
41
|
+
# :device_instances=>[],
|
42
|
+
# :rule=>{
|
43
|
+
# :active=>true,
|
44
|
+
# :description=>"bajratest",
|
45
|
+
# :condition=>{
|
46
|
+
# :type=>"and_rule_condition",
|
47
|
+
# :rule_conditions=>[{
|
48
|
+
|
49
|
+
# :property=>"var",
|
50
|
+
# :value=>"30",
|
51
|
+
# :type=>"equal_rule_condition"
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should get all report data" do
|
59
|
+
element_data = MachineShop::Reports.all({}, auth_token)
|
60
|
+
reports=element_data
|
61
|
+
puts "element_data: #{element_data}"
|
62
|
+
|
63
|
+
element_data.should_not be_nil
|
64
|
+
element_data.should_not be_empty
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
it "should get report of specific device" do
|
70
|
+
element_data = MachineShop::Reports.all(
|
71
|
+
({:device_instance_id => '538461dc9818006e0900005e',
|
72
|
+
:per_page=>'1000',
|
73
|
+
#:created_at_between=>'2013-11-04T00:00:00_2014-03-19T17:02:00'
|
74
|
+
}), auth_token)
|
75
|
+
|
76
|
+
puts "element data of f00e5981800ad58000006 #{element_data} "
|
77
|
+
|
78
|
+
element_data.should_not be_nil
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should get specific report by id" do
|
82
|
+
specific_report_id=reports[0].id
|
83
|
+
element_data = MachineShop::Reports.retrieve("5384800dff7346390c000001",auth_token)
|
84
|
+
|
85
|
+
puts "report specific #{element_data} "
|
86
|
+
|
87
|
+
element_data.should_not be_nil
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|