Skip to content

Instantly share code, notes, and snippets.

@pedrovanzella
Created April 3, 2013 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrovanzella/5301972 to your computer and use it in GitHub Desktop.
Save pedrovanzella/5301972 to your computer and use it in GitHub Desktop.
Fabricator(:default, from: :connection_profile) do
name_id "default"
name "Perfil Padrão"
conn_type "mobile"
end
Schedule precisa ter duas Probes, source e destination.
Cada uma dessas duas probes tem que ter um plano e um connection_profile, que devem ser os mesmos para ambas probes.
O plano também deve ter um connection_profile, que deve ser igual ao connection_profile das probes.
describe Median do
describe "cálculo de medianas" do
describe "scm4" do
before do
@reference_date = DateTime.parse('2012-04-08 12:00:00')
@from = '2012-04-08 03:00:00'
@to = '2012-04-09 03:00:00'
@schedule = Fabricate(:schedule)
@threshold = Fabricate(:threshold)
end
it "deve calcular corretamente" do
Median.calculate(@schedule, @threshold, @reference_date)
@medians = Median.
where(:schedule_id => @schedule.id).
where(:threshold_id => @threshold.id).
where('start_timestamp >= ?', @from).
where('end_timestamp <= ?', @to).order('start_timestamp ASC').all
@medians.length.must eq(1)
end
end
end
end
Fabricator(:default, from: :plan) do
name "default"
throughput_down 1000
throughput_up 1000
connection_profile(fabricator: :default, from: :connection_profile)
end
Fabricator(:source, from: :probe) do
name "origem"
ipaddress "origem"
status 1
type "linux"
city "pindamonhangaba"
state "sp"
plan(fabricator: :default, from: :plan)
connection_profile(fabricator: :default, from: :connection_profile)
end
Fabricator(:destination, from: :probe) do
name "destino"
ipaddress "192.168.1.2"
status 1
type "android"
city "conchinchina"
state "ac"
plan(fabricator: :default, from: :plan)
connection_profile(fabricator: :default, from: :connection_profile)
end
Fabricator(:schedule) do |s|
start '2012-01-01 00:00:00'
s.end '2012-31-12 23:59:59'
polling 10
status "active"
uuid "bf0f4c96-085e-4129-871b-fe8a1e85bb73"
source(fabricator: :source, from: :probe )
destination(fabricator: :destination, from: :probe )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment