Init version of integration tests.
This commit is contained in:
parent
27885a097e
commit
6f4511967f
3 changed files with 161 additions and 16 deletions
|
@ -297,7 +297,7 @@ module Import::OTRS2
|
|||
next
|
||||
end
|
||||
_ticket_result(records, locks)
|
||||
sleep 1
|
||||
#sleep 1
|
||||
end
|
||||
}
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ module Import::OTRS2
|
|||
:updated_by_id => 1,
|
||||
}
|
||||
map.each { |key,value|
|
||||
if state[key.to_s]
|
||||
if state.has_key?(key.to_s)
|
||||
state_new[value] = state[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -767,7 +767,7 @@ module Import::OTRS2
|
|||
:updated_by_id => 1,
|
||||
}
|
||||
map.each { |key,value|
|
||||
if priority[key.to_s]
|
||||
if priority.has_key?(key.to_s)
|
||||
priority_new[value] = priority[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ module Import::OTRS2
|
|||
:updated_by_id => 1,
|
||||
}
|
||||
map.each { |key,value|
|
||||
if group[key.to_s]
|
||||
if group.has_key?(key.to_s)
|
||||
group_new[value] = group[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -866,7 +866,7 @@ module Import::OTRS2
|
|||
:group_ids => group_ids,
|
||||
}
|
||||
map.each { |key,value|
|
||||
if user[key.to_s]
|
||||
if user.has_key?(key.to_s)
|
||||
user_new[value] = user[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -985,7 +985,7 @@ module Import::OTRS2
|
|||
:role_ids => [ role_customer.id ],
|
||||
}
|
||||
map.each { |key,value|
|
||||
if user[key.to_s]
|
||||
if user.has_key?(key.to_s)
|
||||
user_new[value] = user[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -1049,7 +1049,7 @@ module Import::OTRS2
|
|||
:updated_by_id => 1,
|
||||
}
|
||||
map.each { |key,value|
|
||||
if organization[key.to_s]
|
||||
if organization.has_key?(key.to_s)
|
||||
organization_new[value] = organization[key.to_s]
|
||||
end
|
||||
}
|
||||
|
@ -1075,20 +1075,16 @@ module Import::OTRS2
|
|||
|
||||
# map
|
||||
if record['ValidID'].to_s == '3'
|
||||
record['ValidID'] = '2'
|
||||
end
|
||||
if record['ValidID'].to_s == '2'
|
||||
record['ValidID'] = false
|
||||
end
|
||||
if record['ValidID'].to_s == '1'
|
||||
elsif record['ValidID'].to_s == '2'
|
||||
record['ValidID'] = false
|
||||
elsif record['ValidID'].to_s == '1'
|
||||
record['ValidID'] = true
|
||||
end
|
||||
if record['ValidID'].to_s == '0'
|
||||
elsif record['ValidID'].to_s == '0'
|
||||
record['ValidID'] = false
|
||||
end
|
||||
|
||||
# fallback
|
||||
if !record['ValidID']
|
||||
else
|
||||
record['ValidID'] = true
|
||||
end
|
||||
end
|
||||
|
|
120
test/integration/otrs_import_test.rb
Normal file
120
test/integration/otrs_import_test.rb
Normal file
|
@ -0,0 +1,120 @@
|
|||
# encoding: utf-8
|
||||
require 'integration_test_helper'
|
||||
|
||||
class OtrsImportTest < ActiveSupport::TestCase
|
||||
test 'check counts' do
|
||||
#agent_count = User.where()
|
||||
assert_equal( 600, Ticket.count, 'tickets' )
|
||||
assert_equal( 10, Ticket::State.count, 'ticket states' )
|
||||
assert_equal( 24, Group.count, 'groups' )
|
||||
|
||||
end
|
||||
|
||||
test 'check users' do
|
||||
role_admin = Role.where( :name => 'Admin' ).first
|
||||
role_agent = Role.where( :name => 'Agent' ).first
|
||||
role_customer = Role.where( :name => 'Customer' ).first
|
||||
#role_report = Role.where( :name => 'Report' ).first
|
||||
|
||||
user1 = User.find(2)
|
||||
assert_equal( 'agent-1 firstname', user1.firstname )
|
||||
assert_equal( 'agent-1 lastname', user1.lastname )
|
||||
assert_equal( 'agent-1', user1.login )
|
||||
assert_equal( 'agent-1@example.com', user1.email )
|
||||
assert_equal( true, user1.active )
|
||||
|
||||
|
||||
assert( user1.roles.include?( role_agent ) )
|
||||
assert( !user1.roles.include?( role_admin ) )
|
||||
assert( !user1.roles.include?( role_customer ) )
|
||||
#assert( !user1.roles.include?( role_report ) )
|
||||
|
||||
group_dasa = Group.where( :name => 'dasa' ).first
|
||||
group_raw = Group.where( :name => 'Raw' ).first
|
||||
|
||||
assert( !user1.groups.include?( group_dasa ) )
|
||||
assert( user1.groups.include?( group_raw ) )
|
||||
|
||||
|
||||
user2 = User.find(3)
|
||||
assert_equal( 'agent-2 firstname äöüß', user2.firstname )
|
||||
assert_equal( 'agent-2 lastname äöüß', user2.lastname )
|
||||
assert_equal( 'agent-2', user2.login )
|
||||
assert_equal( 'agent-2@example.com', user2.email )
|
||||
assert_equal( true, user2.active )
|
||||
|
||||
assert( user2.roles.include?( role_agent ) )
|
||||
assert( user2.roles.include?( role_admin ) )
|
||||
assert( !user2.roles.include?( role_customer ) )
|
||||
#assert( user2.roles.include?( role_report ) )
|
||||
|
||||
assert( user2.groups.include?( group_dasa ) )
|
||||
assert( user2.groups.include?( group_raw ) )
|
||||
|
||||
user3 = User.find(7)
|
||||
assert_equal( 'invalid', user3.firstname )
|
||||
assert_equal( 'invalid', user3.lastname )
|
||||
assert_equal( 'invalid', user3.login )
|
||||
assert_equal( 'invalid@example.com', user3.email )
|
||||
assert_equal( false, user3.active )
|
||||
|
||||
assert( user3.roles.include?( role_agent ) )
|
||||
assert( !user3.roles.include?( role_admin ) )
|
||||
assert( !user3.roles.include?( role_customer ) )
|
||||
#assert( user3.roles.include?( role_report ) )
|
||||
|
||||
assert( !user3.groups.include?( group_dasa ) )
|
||||
assert( !user3.groups.include?( group_raw ) )
|
||||
|
||||
user4 = User.find(8)
|
||||
assert_equal( 'invalid-temp', user4.firstname )
|
||||
assert_equal( 'invalid-temp', user4.lastname )
|
||||
assert_equal( 'invalid-temp', user4.login )
|
||||
assert_equal( 'invalid-temp@example.com', user4.email )
|
||||
assert_equal( false, user4.active )
|
||||
|
||||
assert( user4.roles.include?( role_agent ) )
|
||||
assert( !user4.roles.include?( role_admin ) )
|
||||
assert( !user4.roles.include?( role_customer ) )
|
||||
#assert( user4.roles.include?( role_report ) )
|
||||
|
||||
assert( !user4.groups.include?( group_dasa ) )
|
||||
assert( !user4.groups.include?( group_raw ) )
|
||||
|
||||
end
|
||||
|
||||
test 'check ticket stats' do
|
||||
state_new = Ticket::State.find(1)
|
||||
assert_equal( 'new', state_new.name )
|
||||
assert_equal( 'new', state_new.state_type.name )
|
||||
end
|
||||
|
||||
test 'check groups' do
|
||||
group1 = Group.find(1)
|
||||
assert_equal( 'Postmaster', group1.name )
|
||||
assert_equal( true, group1.active )
|
||||
|
||||
group2 = Group.find(19)
|
||||
assert_equal( 'UnitTestQueue20668', group2.name )
|
||||
assert_equal( false, group2.active )
|
||||
end
|
||||
|
||||
test 'check customers / organizations' do
|
||||
user1 = User.where( :login => 'jn' ).first
|
||||
assert_equal( 'Johannes', user1.firstname )
|
||||
assert_equal( 'Nickel', user1.lastname )
|
||||
assert_equal( 'jn', user1.login )
|
||||
assert_equal( 'jn@example.com', user1.email )
|
||||
organization1 = user1.organization
|
||||
assert_equal( 'Znuny GmbH Berlin', organization1.name )
|
||||
assert_equal( 'äöüß', organization1.note )
|
||||
|
||||
user2 = User.where( :login => 'test90133' ).first
|
||||
assert_equal( 'test90133', user2.firstname )
|
||||
assert_equal( 'test90133', user2.lastname )
|
||||
assert_equal( 'test90133', user2.login )
|
||||
assert_equal( 'qa4711@t-online.de', user2.email )
|
||||
organization2 = user2.organization
|
||||
assert( organization2, nil )
|
||||
end
|
||||
end
|
29
test/integration_test_helper.rb
Normal file
29
test/integration_test_helper.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
ENV["RAILS_ENV"] = "test"
|
||||
require File.expand_path('../../config/environment', __FILE__)
|
||||
require 'rails/test_help'
|
||||
require 'cache'
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
# disable transactions
|
||||
#self.use_transactional_fixtures = false
|
||||
|
||||
# clear cache
|
||||
Cache.clear
|
||||
|
||||
# load seeds
|
||||
load "#{Rails.root}/db/seeds.rb"
|
||||
|
||||
Setting.set("import_otrs_endpoint", "http://vz305.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator")
|
||||
Setting.set("import_otrs_endpoint_key", "01234567899876543210")
|
||||
Setting.set("import_mode", true)
|
||||
Import::OTRS2.start
|
||||
|
||||
setup do
|
||||
|
||||
# set current user
|
||||
#puts 'reset UserInfo.current_user_id'
|
||||
#UserInfo.current_user_id = nil
|
||||
end
|
||||
|
||||
# Add more helper methods to be used by all tests here...
|
||||
end
|
Loading…
Reference in a new issue