github.com/phrase/openapi@v0.0.0-20240514140800-49e8a106740e/clients/ruby/spec/api/uploads_api_spec.rb (about) 1 require 'spec_helper' 2 require 'json' 3 4 # Unit tests for Phrase::UploadsApi 5 # Automatically generated by openapi-generator (https://openapi-generator.tech) 6 # Please update as you see appropriate 7 describe 'UploadsApi' do 8 before do 9 # run before each test 10 @api_instance = Phrase::UploadsApi.new 11 end 12 13 after do 14 # run after each test 15 end 16 17 describe 'test an instance of UploadsApi' do 18 it 'should create an instance of UploadsApi' do 19 expect(@api_instance).to be_instance_of(Phrase::UploadsApi) 20 end 21 end 22 23 # unit tests for upload_create 24 # Upload a new file 25 # Upload a new language file. Creates necessary resources in your project. 26 # @param project_id Project ID 27 # @param [Hash] opts the optional parameters 28 # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) 29 # @option opts [String] :branch specify the branch to use 30 # @option opts [File] :file File to be imported 31 # @option opts [String] :file_format File format. Auto-detected when possible and not specified. 32 # @option opts [String] :locale_id Locale of the file's content. Can be the name or id of the locale. Preferred is id. 33 # @option opts [String] :tags List of tags separated by comma to be associated with the new keys contained in the upload. 34 # @option opts [Boolean] :update_translations Indicates whether existing translations should be updated with the file content. 35 # @option opts [Boolean] :update_descriptions Existing key descriptions will be updated with the file content. Empty descriptions overwrite existing descriptions. 36 # @option opts [Boolean] :convert_emoji This option is obsolete. Providing the option will cause a bad request error. 37 # @option opts [Boolean] :skip_upload_tags Indicates whether the upload should not create upload tags. 38 # @option opts [Boolean] :skip_unverification Indicates whether the upload should unverify updated translations. 39 # @option opts [String] :file_encoding Enforces a specific encoding on the file contents. Valid options are \\\"UTF-8\\\", \\\"UTF-16\\\" and \\\"ISO-8859-1\\\". 40 # @option opts [Object] :locale_mapping Optional, format specific mapping between locale names and the columns the translations to those locales are contained in. 41 # @option opts [Object] :format_options Additional options available for specific formats. See our format guide for complete list. 42 # @option opts [Boolean] :autotranslate If set, translations for the uploaded language will be fetched automatically. 43 # @option opts [Boolean] :mark_reviewed Indicated whether the imported translations should be marked as reviewed. This setting is available if the review workflow is enabled for the project. 44 # @option opts [Boolean] :tag_only_affected_keys Indicates whether only keys affected (created or updated) by the upload should be tagged. The default is `false` 45 # @return [Upload] 46 describe 'upload_create test' do 47 let(:response_body) { { data: {} }.to_json } 48 before do 49 stub_request(:any, /.*phrase.com/) 50 .to_return(status: 200, body: response_body, headers: { 51 'Content-Type' => 'application/json' 52 }) 53 end 54 55 it 'should work' do 56 @api_instance.upload_create('project_id', File.new('Gemfile'), "yml", "en") 57 58 expect(a_request(:post, 'https://api.phrase.com/v2/projects/project_id/uploads') 59 .with { |req| 60 expect(req.headers['Content-Type']).to eq('multipart/form-data') 61 # expect(req.body).to include('Gemfile') 62 }).to have_been_made 63 end 64 end 65 66 # unit tests for upload_show 67 # Get a single upload 68 # View details and summary for a single upload. 69 # @param project_id Project ID 70 # @param id ID 71 # @param [Hash] opts the optional parameters 72 # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) 73 # @option opts [String] :branch specify the branch to use 74 # @return [Upload] 75 describe 'upload_show test' do 76 it 'should work' do 77 # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers 78 end 79 end 80 81 # unit tests for uploads_list 82 # List uploads 83 # List all uploads for the given project. 84 # @param project_id Project ID 85 # @param [Hash] opts the optional parameters 86 # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) 87 # @option opts [Integer] :page Page number 88 # @option opts [Integer] :per_page Limit on the number of objects to be returned, between 1 and 100. 25 by default 89 # @option opts [String] :branch specify the branch to use 90 # @return [Array<Upload>] 91 describe 'uploads_list test' do 92 it 'should work' do 93 # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers 94 end 95 end 96 97 end