Commit 84fb263eab7734271ba5dffb32376c7e6f892ddd

Authored by Gabriela Navarro
1 parent 92cac974

verify_test: Fix software test helper and functional test

Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Signed-off-by: Luiz Matos <luizff.matos@gmail.com>
test/functional/mpog_software_plugin_myprofile_controller_test.rb
... ... @@ -63,12 +63,14 @@ class MpogSoftwarePluginMyprofileControllerTest &lt; ActionController::TestCase
63 63  
64 64 should 'create a new software with all fields filled in' do
65 65 fields = software_fields
66   -
67 66 post :new_software, :profile => person.identifier, :community => fields[6], :license_info => fields[5],
68 67 :software_info => fields[0], :library => fields[1], :database => fields[3],
69 68 :language => fields[2], :operating_system=> fields[4]
70   - assert @response.success?
  69 +
  70 + assert_equal SoftwareInfo.last.name, "Debian"
71 71 end
72 72  
73 73  
  74 +
  75 +
74 76 end
... ...
test/functional/software_test_helper.rb
... ... @@ -0,0 +1,145 @@
  1 +module SoftwareTestHelper
  2 +
  3 + def create_language language_fields
  4 + language = SoftwareLanguage.new
  5 +
  6 + language_fields[0].each do |k,v|
  7 + language[k] = v
  8 + end
  9 + language.save!
  10 + language
  11 + end
  12 +
  13 + def create_database database_fields
  14 +
  15 + database = SoftwareDatabase.new
  16 +
  17 + database_fields[0].each do |k,v|
  18 + database[k] = v
  19 + end
  20 +
  21 + database.save!
  22 + database
  23 + end
  24 +
  25 + def create_library library_fields
  26 + library = Library.new
  27 +
  28 + library_fields[0].each do |k,v|
  29 + library[k] = v
  30 + end
  31 + library.save!
  32 + library
  33 + end
  34 +
  35 + def create_operating_system operating_system_hash
  36 + operating_system = OperatingSystem.new
  37 +
  38 + operating_system_hash[0].each do |k,v|
  39 + operating_system[k] = v
  40 + end
  41 + operating_system.save
  42 + operating_system
  43 + end
  44 +
  45 + def create_license license_hash
  46 + license_info = LicenseInfo.new
  47 +
  48 + license_hash.each do |k,v|
  49 + license_info[k] = v
  50 + end
  51 + license_info.save
  52 + license_info
  53 + end
  54 +
  55 + def create_software fields
  56 +
  57 + software = SoftwareInfo.new
  58 + community = Community.new
  59 + software_hash = fields[0]
  60 + library_hash = fields[1]
  61 + language_hash = fields[2]
  62 + database_hash = fields[3]
  63 + operating_system_hash = fields[4]
  64 + license_system_hash = fields[5]
  65 + community_hash = fields[6]
  66 +
  67 + software_hash.each do |k,v|
  68 + software[k] = v
  69 + end
  70 +
  71 + community_hash.each do |k,v|
  72 + community[k] = v
  73 + end
  74 +
  75 + community.save!
  76 + software.community = community
  77 + software.software_databases << create_database(database_hash)
  78 + software.software_languages << create_language(language_hash)
  79 + software.operating_systems << create_operating_system(operating_system_hash)
  80 + software.license_info_id = license_system_hash
  81 + software.libraries << create_library(library_hash)
  82 +
  83 + software
  84 + end
  85 +
  86 + def software_fields
  87 +
  88 + fields = Hash.new
  89 + fields_library = Hash.new
  90 + fields_language = Hash.new
  91 + fields_database = Hash.new
  92 + fields_operating_system = Hash.new
  93 + fields_community = Hash.new
  94 + fields_license = Hash.new
  95 + list_database = []
  96 + list_language = []
  97 + list_operating_system = []
  98 + list_library = []
  99 +
  100 + #Fields for library
  101 + fields_library['version'] = 'test'
  102 + fields_library['name'] = 'test'
  103 + fields_library['license'] = 'test'
  104 + list_library << fields_library
  105 + list_library << {}
  106 + #Fields for software language
  107 + fields_language['version'] = 'test'
  108 + fields_language['programming_language_id'] = ProgrammingLanguage.last.id
  109 + fields_language['operating_system'] = 'test'
  110 + list_language << fields_language
  111 + list_language << {}
  112 + #Fields for database
  113 + fields_database['version'] = 'test'
  114 + fields_database['database_description_id'] = DatabaseDescription.last.id
  115 + fields_database['operating_system'] = 'test'
  116 + list_database << fields_database
  117 + list_database << {}
  118 + #Fields for license info
  119 + fields_license['version'] = LicenseInfo.last.version
  120 + #Fields for operating system
  121 + fields_operating_system['version'] = 'version'
  122 + fields_operating_system['operating_system_name_id'] = OperatingSystemName.last.id
  123 + list_operating_system << fields_operating_system
  124 + list_operating_system << {}
  125 + #Fields for community
  126 + fields_community['name'] = 'Debian'
  127 + fields_community['identifier'] = 'debian'
  128 +
  129 + fields['acronym'] = 'test'
  130 + fields['objectives'] = 'test'
  131 + fields['features'] = 'test'
  132 + fields['operating_platform'] = 'operating_plataform_test'
  133 + fields['demonstration_url'] = 'test'
  134 +
  135 + hash_list = []
  136 + hash_list << fields
  137 + hash_list << list_library
  138 + hash_list << list_language
  139 + hash_list << list_database
  140 + hash_list << list_operating_system
  141 + hash_list << fields_license
  142 + hash_list << fields_community
  143 + hash_list
  144 + end
  145 +end
0 146 \ No newline at end of file
... ...