Skip to content
This repository has been archived by the owner on Jul 8, 2019. It is now read-only.

Commit

Permalink
Splitted Input Tests in Several Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinhard Grandl committed Jun 24, 2015
1 parent 05f997c commit f4eb276
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require 'rake/testtask'

Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/bitcodin_api_input_tests.rb']
t.test_files = FileList['test/input/*_test.rb']
t.verbose = true
end

Expand Down
59 changes: 0 additions & 59 deletions test/bitcodin_api_input_tests.rb

This file was deleted.

55 changes: 55 additions & 0 deletions test/input/bitcodin_api_create_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require 'test/unit'
require 'bitcodin'
require 'json'
require 'coveralls'
Coveralls.wear!


module Bitcodin

class ResponseCodes

GET = 200
POST = 201
DELETE = 204
PATCH = 200

end

class BitcodinApiCreateTest < Test::Unit::TestCase

def setup
# read access information (e.g. api key, etc.) from file
file = File.read('test/resources/settings.json')
data = JSON.parse(file)
@apiKey = data['apikey']

end

def test_createInput
# create new bitcodinAPI instance
bitcodinAPI = BitcodinAPI.new(@apiKey)

# create http config
httpConfig = HTTPInputConfig.new('http://ftp.nluug.nl/pub/graphics/blender/demo/movies/Sintel.2010.720p.mkv')

# parse response to get input ID
response = bitcodinAPI.createInput(httpConfig)
responseData = JSON.parse(response)
@inputId = responseData['inputId']

# check response code
assert_equal(response.code, ResponseCodes::POST)
end

def teardown
# create new bitcodinAPI instance
bitcodinAPI = BitcodinAPI.new(@apiKey)

# delete created Input
bitcodinAPI.deleteInput(@inputId)

end

end
end
58 changes: 58 additions & 0 deletions test/input/bitcodin_api_delete_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
require 'test/unit'
require 'bitcodin'
require 'json'
require 'coveralls'
Coveralls.wear!


module Bitcodin

class ResponseCodes

GET = 200
POST = 201
DELETE = 204
PATCH = 200

end

class BitcodinApiDeleteTest < Test::Unit::TestCase

def setup
# read access information (e.g. api key, etc.) from file
file = File.read('test/resources/settings.json')
data = JSON.parse(file)
@apiKey = data['apikey']

# create new bitcodinAPI instance
bitcodinAPI = BitcodinAPI.new(@apiKey)

# create http config
httpConfig = HTTPInputConfig.new('http://ftp.nluug.nl/pub/graphics/blender/demo/movies/Sintel.2010.720p.mkv')

# create input
response = bitcodinAPI.createInput(httpConfig)

# parse response to get input ID
responseData = JSON.parse(response)
@inputId = responseData['inputId']

end

def test_deleteInput
# create new bitcodinAPI instance
bitcodinAPI = BitcodinAPI.new(@apiKey)

# delete created Input
response = bitcodinAPI.deleteInput(@inputId)

# check response code
assert_equal(response.code, ResponseCodes::DELETE)
end

def teardown

end

end
end
55 changes: 55 additions & 0 deletions test/input/bitcodin_api_details_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require 'test/unit'
require 'bitcodin'
require 'json'
require 'coveralls'
Coveralls.wear!


module Bitcodin

class ResponseCodes

GET = 200
POST = 201
DELETE = 204
PATCH = 200

end

class BitcodinApiDetailsTest < Test::Unit::TestCase

def setup
# read access information (e.g. api key, etc.) from file
file = File.read('test/resources/settings.json')
data = JSON.parse(file)
@apiKey = data['apikey']

# create new bitcodinAPI instance
bitcodinAPI = BitcodinAPI.new(@apiKey)

# create http config
httpConfig = HTTPInputConfig.new('http://ftp.nluug.nl/pub/graphics/blender/demo/movies/Sintel.2010.720p.mkv')

# parse response to get input ID
response = bitcodinAPI.createInput(httpConfig)
responseData = JSON.parse(response)
@inputId = responseData['inputId']
end

def test_getInputDetails
bitcodinAPI = BitcodinAPI.new(@apiKey)
response = bitcodinAPI.getInputDetails(@inputId)
assert_equal(response.code, ResponseCodes::GET)
end

def teardown
# create new bitcodinAPI instance
bitcodinAPI = BitcodinAPI.new(@apiKey)

# delete created Input
bitcodinAPI.deleteInput(@inputId)

end

end
end
41 changes: 41 additions & 0 deletions test/input/bitcodin_api_list_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'test/unit'
require 'bitcodin'
require 'json'
require 'coveralls'
Coveralls.wear!


module Bitcodin

class ResponseCodes

GET = 200
POST = 201
DELETE = 204
PATCH = 200

end

class BitcodinApiListTest < Test::Unit::TestCase

def setup
# read access information (e.g. api key, etc.) from file
file = File.read('test/resources/settings.json')
data = JSON.parse(file)
apiKey = data['apikey']

# create new bitcodinAPI instance
@bitcodinAPI = BitcodinAPI.new(apiKey)
end

def test_listInput
response = @bitcodinAPI.listInput
assert_equal(response.code, ResponseCodes::GET)
end

def teardown
## Nothing up to now
end

end
end

0 comments on commit f4eb276

Please sign in to comment.