98 lines
2.9 KiB
Ruby
98 lines
2.9 KiB
Ruby
# typed: false
|
|
FactoryBot.define do
|
|
factory :telegram_bot_log do
|
|
sequence(:telegram_user_id) { |n| 100_000_000 + n }
|
|
sequence(:telegram_chat_id) { |n| 200_000_000 + n }
|
|
telegram_username { "user#{SecureRandom.alphanumeric(6)}" }
|
|
telegram_first_name { "Test" }
|
|
telegram_last_name { "User" }
|
|
request_timestamp { Time.current }
|
|
status { :success }
|
|
search_results_count { 3 }
|
|
download_time { 0.08 }
|
|
image_processing_time { 0.05 }
|
|
fingerprint_computation_time { 0.15 }
|
|
search_computation_time { 0.25 }
|
|
total_request_time { 0.53 }
|
|
response_data { { matches: 3, threshold: 90 } }
|
|
|
|
trait :with_image do
|
|
association :processed_image, factory: %i[blob_file image_blob]
|
|
end
|
|
|
|
trait :successful do
|
|
status { :success }
|
|
search_results_count { 5 }
|
|
download_time { 0.06 }
|
|
image_processing_time { 0.04 }
|
|
fingerprint_computation_time { 0.12 }
|
|
search_computation_time { 0.18 }
|
|
total_request_time { 0.40 }
|
|
response_data { { matches: 5, threshold: 90, posts: [1, 2, 3, 4, 5] } }
|
|
end
|
|
|
|
trait :with_no_results do
|
|
status { :no_results }
|
|
search_results_count { 0 }
|
|
download_time { 0.07 }
|
|
image_processing_time { 0.03 }
|
|
fingerprint_computation_time { 0.10 }
|
|
search_computation_time { 0.05 }
|
|
total_request_time { 0.25 }
|
|
response_data { { matches: 0, threshold: 90 } }
|
|
end
|
|
|
|
trait :with_error do
|
|
status { :error }
|
|
search_results_count { 0 }
|
|
download_time { 0.05 }
|
|
image_processing_time { nil }
|
|
fingerprint_computation_time { nil }
|
|
search_computation_time { nil }
|
|
total_request_time { 0.15 }
|
|
error_message { "Failed to process image: Invalid format" }
|
|
response_data { { error: "Invalid image format" } }
|
|
end
|
|
|
|
trait :invalid_image do
|
|
status { :invalid_image }
|
|
search_results_count { 0 }
|
|
download_time { 0.04 }
|
|
image_processing_time { nil }
|
|
fingerprint_computation_time { nil }
|
|
search_computation_time { nil }
|
|
total_request_time { 0.12 }
|
|
error_message { "Image format not supported" }
|
|
response_data { { error: "Unsupported format" } }
|
|
end
|
|
|
|
trait :minimal_user_info do
|
|
telegram_username { nil }
|
|
telegram_first_name { nil }
|
|
telegram_last_name { nil }
|
|
end
|
|
|
|
trait :username_only do
|
|
telegram_first_name { nil }
|
|
telegram_last_name { nil }
|
|
telegram_username { "anonymous_user" }
|
|
end
|
|
|
|
trait :slow_processing do
|
|
download_time { 0.5 }
|
|
image_processing_time { 0.3 }
|
|
fingerprint_computation_time { 2.5 }
|
|
search_computation_time { 1.8 }
|
|
total_request_time { 5.1 }
|
|
end
|
|
|
|
trait :fast_processing do
|
|
download_time { 0.01 }
|
|
image_processing_time { 0.005 }
|
|
fingerprint_computation_time { 0.02 }
|
|
search_computation_time { 0.01 }
|
|
total_request_time { 0.045 }
|
|
end
|
|
end
|
|
end
|