Permalink
Browse files

Some tests for Marvin

  • Loading branch information...
samstarling committed May 2, 2012
1 parent e97156c commit f0393700e95d22de9e127fa13eda2e78b7e08d45
@@ -0,0 +1,6 @@
+require 'capybara/cucumber'
+
+Capybara.configure do |config|
+ config.default_driver = :selenium
+ config.app_host = "http://127.0.0.1:8080/marvin-console"
+end
@@ -0,0 +1,6 @@
+Feature: Check the encoders
+
+ Scenario: Check than an encoder is free
+ Given encoder "1A" is in a default state
+ When I visit the server status page
+ Then encoder "1A" should be free
@@ -0,0 +1,32 @@
+Given /^encoder "([^"]*)" is in a default state$/ do |encoder_id|
+
+ context = {
+ encoder_id: encoder_id,
+ profile_name: "Test",
+ device_number: 1,
+ device_id: 2,
+ status: "running",
+ live_id: 103,
+ user_data: "blah",
+ error_code: nil,
+ switch_timestamp: nil,
+ start_time: nil,
+ complete_time: nil
+ }
+
+ path = "/#{encoder_id}/live_events?per_page=10000"
+ template = 'encoder.xml'
+ create_double path, template, context
+
+ path = "/#{encoder_id}/live_events/#{context[:live_id]}"
+ template = 'live_event.xml'
+ create_double path, template, context
+end
+
+When /^I visit the server status page$/ do
+ visit '/index.html'
+end
+
+Then /^encoder "([^"]*)" should be free$/ do |arg1|
+ page.should have_selector '#encoder_1A .encoder_list_row_img_free'
+end
@@ -0,0 +1,27 @@
+require 'rest-assured'
+require 'rest-client'
+require 'erubis'
+
+RestAssured::Server.address = 'http://localhost:4578'
+
+module FixtureSupport
+ def fixture(filename)
+ fixtures_dir = File.dirname(__FILE__) + '/fixtures'
+ File.read(File.join(fixtures_dir, filename))
+ end
+end
+
+module DoubleSupport
+ def create_double(path, template, context)
+ file = fixture(template)
+ xml = Erubis::Eruby.new(file).result(context)
+ RestAssured::Double.create(fullpath: path, content: xml)
+ end
+end
+
+Before do
+ RestClient.delete "#{RestAssured::Server.address}/doubles/all"
+end
+
+World(FixtureSupport)
+World(DoubleSupport)
@@ -0,0 +1,7 @@
+class FakeMQ
+
+ def initialize
+
+ end
+
+end
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<live_event_list>
+ <live_event href="/live_events/<%= live_id %>">
+ <name><%= profile_name %></name>
+
+ <input>
+ <order>2</order>
+ <loop>true</loop>
+ <file_input>
+ <uri>/data/marvin/sport_coming_up.mp4</uri>
+ </file_input>
+ </input>
+
+ <input>
+ <order>1</order>
+ <device_input>
+ <channel>1</channel>
+ <input_format>Auto</input_format>
+ <device_type>AJA</device_type>
+ <device_number><%= device_number %></device_number>
+ <device_id><%= device_id %></device_id>
+ </device_input>
+ </input>
+
+ <input>
+ <order>3</order>
+ <loop>true</loop>
+ <file_input>
+ <uri>/data/marvin/sport_ended.mp4</uri>
+ </file_input>
+ </input>
+
+ <input>
+ <order>4</order>
+ <loop>true</loop>
+ <file_input>
+ <uri>/data/marvin/sport_interrupted.mp4</uri>
+ </file_input>
+ </input>
+
+ <user_data><%= user_data %></user_data>
+ <status><%= status %></status>
+ <% if error_code -%>
+ <error_messages>
+ <error>
+ <code><%= error_code %></code>
+ <message><%= error_msg %></message>
+ </error>
+ </error_messages>
+ <% end -%>
+
+ <audit_messages>
+ <audit>
+ <code>10</code>
+ <created_at>2003-03-03T03:03:03Z</created_at>
+ <message>Initial timecode: 03:03:03:03</message><!-- initial startup: live video -->
+ </audit>
+ <% if switch_timestamp %>
+ <audit>
+ <code>10</code>
+ <created_at><%= (switch_timestamp + 1.second).strftime('%Y-%m-%dT%H:%M:%SZ') %></created_at>
+ <message>Switch to input <%= active_order %>: <%= switch_timestamp.strftime("%H:%M:%S") %>:00</message>
+ </audit>
+ <% end %>
+ </audit_messages>
+
+ <% if start_time -%>
+ <start_time><%= start_time %></start_time>
+ <% end -%>
+ <% if complete_time -%>
+ <complete_time><%= complete_time %></complete_time>
+ <% end -%>
+ <image_inserter>
+ <enable_rest>true</enable_rest>
+ </image_inserter>
+ </live_event>
+ <live_event href="/live_events/1000">
+ <name>Broken profile</name>
+ <input>
+ <device_input>
+ <device_number>7</device_number>
+ <device_id>6</device_id>
+ </device_input>
+ </input>
+ <user_data></user_data>
+ <status>pending</status>
+ </live_event>
+</live_event_list>
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<live_event href="/live_events/<%= live_id %>">
+ <name><%= profile_name %></name>
+
+ <input>
+ <order>2</order>
+ <loop>true</loop>
+ <file_input>
+ <uri>/data/marvin/sport_coming_up.mp4</uri>
+ </file_input>
+ </input>
+
+ <input>
+ <order>1</order>
+ <device_input>
+ <channel>1</channel>
+ <input_format>Auto</input_format>
+ <device_type>AJA</device_type>
+ <device_number><%= device_number %></device_number>
+ <device_id><%= device_id %></device_id>
+ </device_input>
+ </input>
+
+ <input>
+ <order>3</order>
+ <loop>true</loop>
+ <file_input>
+ <uri>/data/marvin/sport_ended.mp4</uri>
+ </file_input>
+ </input>
+
+ <input>
+ <order>4</order>
+ <loop>true</loop>
+ <file_input>
+ <uri>/data/marvin/sport_interrupted.mp4</uri>
+ </file_input>
+ </input>
+
+ <user_data><%= user_data %></user_data>
+ <status><%= status %></status>
+ <% if error_code -%>
+ <error_messages>
+ <error>
+ <code><%= error_code %></code>
+ <message><%= error_msg %></message>
+ </error>
+ </error_messages>
+ <% end -%>
+
+ <audit_messages>
+ <audit>
+ <code>10</code>
+ <created_at>2003-03-03T03:03:03Z</created_at>
+ <message>Initial timecode: 03:03:03:03</message><!-- initial startup: live video -->
+ </audit>
+ <% if switch_timestamp %>
+ <audit>
+ <code>10</code>
+ <created_at><%= (switch_timestamp + 1.second).strftime('%Y-%m-%dT%H:%M:%SZ') %></created_at>
+ <message>Switch to input <%= active_order %>: <%= switch_timestamp.strftime("%H:%M:%S") %>:00</message>
+ </audit>
+ <% end %>
+ </audit_messages>
+
+ <% if start_time -%>
+ <start_time><%= start_time %></start_time>
+ <% end -%>
+ <% if complete_time -%>
+ <complete_time><%= complete_time %></complete_time>
+ <% end -%>
+ <image_inserter>
+ <enable_rest>true</enable_rest>
+ </image_inserter>
+</live_event>
@@ -2,6 +2,5 @@
Capybara.configure do |config|
config.default_driver = :selenium
- #config.app_host = "http://squeaker.heroku.com"
- config.app_host = 'http://10.164.40.182:3000/'
+ config.app_host = "http://squeaker.heroku.com"
end

0 comments on commit f039370

Please sign in to comment.