evostream-event 0.1.1 → 0.1.2.pre.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a07b8b3fd6b95c9a7938cbe4d4c944fd951ac34
4
- data.tar.gz: 0df1b38b37dfc986e518658e82812e0132a1734b
3
+ metadata.gz: f699343ba4037b558f4eb9f583c8764f173043d2
4
+ data.tar.gz: d864337e49da7ac7ebef86d42fee4c56a6d04d52
5
5
  SHA512:
6
- metadata.gz: 7b78eebfd272ec4161426f01951bcd664aa6cfd1ec6279b1ff82e427e1d82d00017be553ee1f5bb35693ea3d325069be28156b13f6a9fcbd03cfbfaa160c3013
7
- data.tar.gz: d7121e7a5b3cdf0a3609485ba52684c441cd01f34da3212f8b66be002bcf6e19462d77f54b778f8ffba25b39deecadc576bfc8ae97e927cee043f8a5aece863f
6
+ metadata.gz: 17c661d04c0e955db365c06923ce2e6d7dcd3daee14964eae40d3c6ba872d1dae25a9a2b83dad78e519ae9a68ae147c15ee3915ff1156e9fa8bd947f6a0d4cef
7
+ data.tar.gz: 19ae30891325cb412e720319702728b02a754ac35466fd4f2b4a57824892d64f9ecfb8807976608ec8b8ee75c9017f5fd9ba5ff4ce904e594308f008e93cd0bc
@@ -5,6 +5,7 @@ require 'evostream/event/info'
5
5
  require 'evostream/event/service'
6
6
  require 'evostream/event/commands'
7
7
  require 'evostream/event/events'
8
+ require 'net/http'
8
9
 
9
10
  # Primary command to gem
10
11
  module Evostream
@@ -10,15 +10,19 @@ module Evostream
10
10
  end
11
11
 
12
12
  def execute
13
- super
14
- stream = what_flux.constantize
15
- model.streams.push(stream.new(config_id: ex_config, flux: ex_flux))
13
+ stream_flux = what_flux.constantize
14
+ model.streams.push(stream_flux.new(config_id: ex_config, flux: ex_flux))
15
+ model.save
16
16
  end
17
17
 
18
18
  private
19
19
 
20
20
  def what_flux
21
- @request.key?('hlsSettings') ? 'Hls' : 'Dash'
21
+ hls? ? 'Hls' : 'Dash'
22
+ end
23
+
24
+ def hls?
25
+ @request.key?(:hlsSettings) || @request.key?('hlsSettings')
22
26
  end
23
27
 
24
28
  def name_flux
@@ -6,7 +6,7 @@
6
6
  # Define constant to gem.
7
7
  module Evostream
8
8
  # Define version to gem
9
- VERSION = '0.1.1'
9
+ VERSION = '0.1.2'
10
10
 
11
11
  # Name to gem
12
12
  GEM_NAME = 'evostream-event'
@@ -14,7 +14,7 @@ Evostream::Service.configuration do |config|
14
14
  config.name = 'srteamming_'
15
15
  config.web_root = '/var/www/html'
16
16
  config.model = ModelUsedInDatabase
17
- config.model_id = :idenitfier_used_in_model
17
+ config.model_id = :identifier_used_in_model
18
18
  end
19
19
  INIT
20
20
 
@@ -2,7 +2,11 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Evostream::Events::InStreamClosed do
5
+ describe Evostream::Events::InStreamClosed, type: :request do
6
+ let(:name_stream) do
7
+ "#{Evostream::Service.name}#{Faker::Number.between(1, 999)}"
8
+ end
9
+
6
10
  let(:body) do
7
11
  {
8
12
  id: Faker::Number.between(1, 999_999),
@@ -24,7 +28,7 @@ describe Evostream::Events::InStreamClosed do
24
28
  farIp: Faker::Internet.ip_v4_address,
25
29
  farPort: Faker::Number.between(1, 65_536),
26
30
  ip: Faker::Internet.ip_v4_address,
27
- name: "#{Faker::Zelda.character}_#{Faker::Number.between(1, 999)}",
31
+ name: name_stream,
28
32
  nearIp: Faker::Internet.ip_v4_address,
29
33
  nearPort: Faker::Number.between(1, 65_536),
30
34
  outStreamsUniqueIds: [
@@ -63,7 +67,7 @@ describe Evostream::Events::InStreamClosed do
63
67
 
64
68
  context 'payload is correct' do
65
69
  let(:type) { body[:type] }
66
- let(:payload) { body[:payload].to_json }
70
+ let(:payload) { body[:payload] }
67
71
 
68
72
  include_examples 'payload is correct'
69
73
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Evostream::Events::InStreamCreated do
5
+ describe Evostream::Events::InStreamCreated, type: :request do
6
6
  let(:body) do
7
7
  {
8
8
  id: Faker::Number.between(1, 999_999),
@@ -60,7 +60,7 @@ describe Evostream::Events::InStreamCreated do
60
60
 
61
61
  context 'payload is correct' do
62
62
  let(:type) { body[:type] }
63
- let(:payload) { body[:payload].to_json }
63
+ let(:payload) { body[:payload] }
64
64
 
65
65
  include_examples 'payload is correct'
66
66
  end
@@ -3,6 +3,8 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Evostream::Events::OutStreamCreated do
6
+ let(:type_default) { 'outStreamCreated' }
7
+
6
8
  context 'HLS Flux' do
7
9
  let(:body) do
8
10
  {
@@ -95,13 +97,105 @@ describe Evostream::Events::OutStreamCreated do
95
97
  }
96
98
  end
97
99
 
98
- let(:type_default) { 'outStreamCreated' }
100
+ context 'payload is correct' do
101
+ let(:type) { body[:type] }
102
+ let(:payload) { body[:payload] }
103
+ let(:type_stream) { 'Hls' }
104
+
105
+ include_examples 'payload is correct', false
106
+ end
107
+
108
+ context 'payload isn\'t correct' do
109
+ let(:body) { Faker::Lorem.paragraph }
110
+ let(:type) { Faker::Zelda.character }
111
+ let(:payload) { Faker::Zelda.game }
112
+
113
+ include_examples 'payload isn\'t correct'
114
+ end
115
+ end
116
+
117
+ context 'DASH Flux' do
118
+ let(:body) do
119
+ {
120
+ id: Faker::Number.between(1, 999_999),
121
+ payload: {
122
+ PID: Faker::Number.between(1, 999_999),
123
+ appName: 'evostreamms',
124
+ audio: {
125
+ bytesCount: Faker::Number.between(1, 999_999),
126
+ codec: 'AAAC',
127
+ codecNumeric: Faker::Number.between(1, 999_999),
128
+ droppedBytesCount: 0,
129
+ droppedPacketsCount: 0,
130
+ packetsCount: Faker::Number.between(1, 999_999)
131
+ },
132
+ bandwidth: Faker::Number.between(1, 999_999),
133
+ connectionType: 0,
134
+ creationTimestamp: Faker::Number.decimal(2),
135
+ customData: nil,
136
+ farIp: Faker::Internet.ip_v4_address,
137
+ farPort: Faker::Number.between(1, 65_536),
138
+ dashSettings: {
139
+ bandwidth: 0,
140
+ chunkBaseName: 'dummy',
141
+ chunkLength: 1,
142
+ chunkOnIDR: true,
143
+ cleanupDestination: false,
144
+ configId: 2,
145
+ dynamicProfile: true,
146
+ groupName: Faker::Lorem.word,
147
+ groupTargetFolder: Faker::File.file_name(Faker::Lorem.word),
148
+ keepAlive: true,
149
+ localStreamName: Faker::GameOfThrones.house,
150
+ manifestName: "#{Faker::Lorem.word}.#{Faker::Lorem.word}",
151
+ operationType: 6,
152
+ overwriteDestination: true,
153
+ playlistLength: 5,
154
+ playlistType: %w(rolling appending).sample,
155
+ staleRetentionCount: 5,
156
+ targetFolder: Faker::File.file_name(Faker::Lorem.word,
157
+ Faker::GameOfThrones.city,
158
+ Faker::Color.color_name)
159
+ },
160
+ ip: Faker::Internet.ip_v4_address,
161
+ name: "#{Faker::Zelda.character}_#{Faker::Number.between(1, 999)}",
162
+ nearIp: Faker::Internet.ip_v4_address,
163
+ nearPort: Faker::Number.between(1, 65_536),
164
+ outStreamsUniqueIds: nil,
165
+ port: Faker::Number.between(1, 65_536),
166
+ processId: Faker::Number.between(1, 999),
167
+ processType: 'origin',
168
+ queryTimestamp: Faker::Number.decimal(3),
169
+ type: 'INP',
170
+ typeNumeric: Faker::Number.between(1, 999_999_999),
171
+ uniqueId: 2,
172
+ upTime: Faker::Number.decimal(3),
173
+ userAgent: 'Lavf56.40.101',
174
+ video: {
175
+ bytesCount: Faker::Number.between(1, 999_999),
176
+ codec: 'VH264',
177
+ codecNumeric: Faker::Number.between(1, 999_999_999),
178
+ droppedBytesCount: 0,
179
+ droppedPacketsCount: 0,
180
+ height: Faker::Number.between(1, 999),
181
+ level: Faker::Number.between(1, 999),
182
+ packetsCount: Faker::Number.between(1, 999),
183
+ profile: Faker::Number.between(1, 999),
184
+ width: Faker::Number.between(1, 999)
185
+ }
186
+ },
187
+ processId: Faker::Number.between(1, 999_999),
188
+ timestamp: Faker::Number.between(1, 999_999),
189
+ type: 'outStreamCreated'
190
+ }
191
+ end
99
192
 
100
193
  context 'payload is correct' do
101
194
  let(:type) { body[:type] }
102
- let(:payload) { body[:payload].to_json }
195
+ let(:payload) { body[:payload] }
196
+ let(:type_stream) { 'Dash' }
103
197
 
104
- include_examples 'payload is correct'
198
+ include_examples 'payload is correct', false
105
199
  end
106
200
 
107
201
  context 'payload isn\'t correct' do
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'active_support'
4
4
  require 'evostream/event'
5
5
  require 'faker'
6
6
  require 'json'
7
+ require 'webmock/rspec'
7
8
 
8
9
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
9
10
 
@@ -18,4 +19,39 @@ RSpec.configure do |config|
18
19
 
19
20
  # Exclude spec broken
20
21
  config.filter_run_excluding broken: true
22
+
23
+ # Configure Service DSL
24
+ config.before do
25
+ Evostream::Service.configuration do |c|
26
+ c.uri_in = 'http://server_stream.local:80'
27
+ c.uri_out = 'http://server_stream.local:7777'
28
+ c.name = 'srteamming_'
29
+ c.web_root = '/var/www/html'
30
+ c.model = Test
31
+ c.model_id = :identifier_used_in_model
32
+ end
33
+ end
34
+
35
+ # Disable all remote connections
36
+ WebMock.disable_net_connect!(allow_localhost: true)
37
+
38
+ # Configure test Net::HTTP
39
+ config.before(:each, type: :request) do
40
+ stub_request(:get, /server_stream.local/)
41
+ .with(headers: { 'Accept': '*/*', 'User-Agent': 'Ruby' })
42
+ .to_return(status: 200, body: '', headers: {})
43
+ end
21
44
  end
45
+
46
+ # Class for testing
47
+ class Test
48
+ def self.find_by(id)
49
+ id
50
+ end
51
+ end
52
+
53
+ # Class for testing model stream
54
+ class Hls; end
55
+
56
+ # Class for testing model stream
57
+ class Dash; end
@@ -1,9 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.shared_examples 'payload is correct' do
3
+ RSpec.shared_examples 'payload is correct' do |request = true|
4
4
  include_examples 'body type'
5
5
  include_examples 'evostream::event new'
6
6
  include_examples 'instance variable model'
7
+ if request
8
+ include_examples 'request test'
9
+ else
10
+ include_examples 'type stream'
11
+ end
7
12
  it { expect(type).to eql(type_default) }
8
13
  end
9
14
 
@@ -19,12 +24,25 @@ RSpec.shared_examples 'body type' do
19
24
  end
20
25
 
21
26
  RSpec.shared_examples 'evostream::event new' do
22
- it { expect(Evostream::Event.new(type, payload)).not_to be nil }
27
+ it { expect(Evostream::Event.new(type, payload.to_json)).not_to be nil }
23
28
  end
24
29
 
25
30
  RSpec.shared_examples 'instance variable model' do
26
31
  let(:model) { type.sub(/^(\w)/, &:capitalize) }
27
- let(:evo) { Evostream::Event.new(type, payload) }
32
+ let(:evo) { Evostream::Event.new(type, payload.to_json) }
28
33
 
29
34
  it { expect(evo.instance_variable_get(:@model)).to eql(model) }
30
35
  end
36
+
37
+ RSpec.shared_examples 'request test' do
38
+ let(:response) { Evostream::Event.new(type, payload).execute_action }
39
+ it { expect(response).to be_an_instance_of(Array) }
40
+ end
41
+
42
+ RSpec.shared_examples 'type stream' do
43
+ let(:stream) do
44
+ Evostream::Events::OutStreamCreated.new(1234, payload).send(:what_flux)
45
+ end
46
+
47
+ it { expect(stream).to eql(type_stream) }
48
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evostream-event
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2.pre.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
@@ -208,6 +208,26 @@ dependencies:
208
208
  - - ">="
209
209
  - !ruby/object:Gem::Version
210
210
  version: 1.7.3
211
+ - !ruby/object:Gem::Dependency
212
+ name: webmock
213
+ requirement: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - "~>"
216
+ - !ruby/object:Gem::Version
217
+ version: '2.3'
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: 2.3.2
221
+ type: :development
222
+ prerelease: false
223
+ version_requirements: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - "~>"
226
+ - !ruby/object:Gem::Version
227
+ version: '2.3'
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: 2.3.2
211
231
  description: |
212
232
  Manage evostream.
213
233
  email:
@@ -277,9 +297,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
277
297
  version: '0'
278
298
  required_rubygems_version: !ruby/object:Gem::Requirement
279
299
  requirements:
280
- - - ">="
300
+ - - ">"
281
301
  - !ruby/object:Gem::Version
282
- version: '0'
302
+ version: 1.3.1
283
303
  requirements: []
284
304
  rubyforge_project:
285
305
  rubygems_version: 2.4.5