Updated Database Query error handling.

Add support for user profiles.
Updated test case.
This commit is contained in:
jvelilla
2014-09-18 18:05:20 -03:00
parent 5d551f7fe1
commit cf3c4060c8
4 changed files with 132 additions and 5 deletions

View File

@@ -5,7 +5,7 @@ note
author: "EiffelStudio test wizard"
date: "$Date$"
revision: "$Revision$"
testing: "type/manual"
testing:"execution/serial"
class
USER_TEST_SET
@@ -36,6 +36,7 @@ feature {NONE} -- Events
on_clean
-- <Precursor>
do
-- (create {CLEAN_DB}).clean_db(connection)
end
feature -- Test routines
@@ -51,9 +52,9 @@ feature -- Test routines
test_user_not_exist
-- Uset test does not exist.
do
assert ("Void", user_provider.user_by_email ("test@admin.com") = Void)
assert ("Void", user_provider.user(2) = Void )
assert ("Void", user_provider.user_by_name ("test") = Void)
assert ("User by email: Void", user_provider.user_by_email ("test1@test.com") = Void)
assert ("User by id: Void", user_provider.user(5) = Void )
assert ("User by name: Void", user_provider.user_by_name ("test1") = Void)
end
test_new_user
@@ -74,6 +75,34 @@ feature -- Test routines
assert ("Not empty roles for given user", not user_provider.user_roles (1).after)
end
test_new_user_without_profile
do
user_provider.new_user ("test", "test","test@admin.com")
assert ("Empty", user_provider.user_profile (1).new_cursor.after)
end
test_new_user_with_profile
local
l_profile: CMS_USER_PROFILE
l_db_profile: CMS_USER_PROFILE
do
user_provider.new_user ("test", "test","test@admin.com")
if attached {CMS_USER} user_provider.user_by_name ("test") as l_user then
assert ("Empty", user_provider.user_profile (l_user.id).new_cursor.after)
create l_profile.make
l_profile.force ("Eiffel", "language")
l_profile.force ("Argentina", "country")
l_profile.force ("GMT-3", "time zone")
user_provider.save_profile (l_user.id, l_profile)
l_db_profile := user_provider.user_profile (l_user.id)
assert ("Not Empty", not l_db_profile.new_cursor.after)
assert ("Expected language Eiffel", attached l_db_profile.item ("language") as l_language and then l_language ~ "Eiffel")
assert ("Expected time zone GMT-3", attached l_db_profile.item ("time zone") as l_language and then l_language ~ "GMT-3")
end
end
feature {NONE} -- Implementation
user_provider: USER_DATA_PROVIDER

View File

@@ -10,6 +10,7 @@ note
date: "$Date$"
revision: "$Revision$"
EIS: "name=Database Testing", "src=http://www.agiledata.org/essays/databaseTesting.html", "protocol=uri"
testing:"execution/serial"
class
CLEAN_DB
@@ -24,6 +25,10 @@ feature
create l_parameters.make (0)
-- Clean Profiles
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_user_profiles, l_parameters))
db_handler(a_connection).execute_change
-- Clean Permissions
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Sql_delete_permissions, l_parameters))
db_handler(a_connection).execute_change
@@ -58,6 +63,9 @@ feature
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Rest_permissions_autoincrement, l_parameters))
db_handler(a_connection).execute_change
db_handler(a_connection).set_query (create {DATABASE_QUERY}.data_reader (Rest_profiles_autoincrement, l_parameters))
db_handler(a_connection).execute_change
end
@@ -88,6 +96,9 @@ feature -- Sql delete queries
Sql_delete_users_roles: STRING = "delete from Users_roles"
-- Clean User roles.
Sql_delete_user_profiles: STRING = "delete from profiles"
-- Clean profiles.
Rest_users_autoincrement: STRING = "ALTER TABLE Users AUTO_INCREMENT = 1"
-- reset autoincrement
@@ -100,4 +111,9 @@ feature -- Sql delete queries
Rest_permissions_autoincrement: STRING = "ALTER TABLE Permissions AUTO_INCREMENT = 1"
-- reset autoincrement.
Rest_profiles_autoincrement: STRING = "ALTER TABLE Profiles AUTO_INCREMENT = 1"
-- reset autoincrement.
end