<commit_before>//
//  UploadDescriptorTests.swift
//  VimeoUpload-iOSTests
//
//  Created by <NAME> on 11/13/18.
//  Copyright © 2018 <NAME>. All rights reserved.
//

import XCTest
import AFNetworking
@testable import VimeoNetworking
@testable import VimeoUpload

class UploadDescriptorTests: XCTestCase
{
    private var urlSessionManager: VimeoSessionManager!
    
    override func setUp()
    {
        super.setUp()
        
        self.urlSessionManager = VimeoSessionManager.defaultSessionManager(appConfiguration: AppConfiguration(clientIdentifier: "", clientSecret: "", scopes: [], keychainService: ""), configureSessionManagerBlock: nil)
    }
    
    override func tearDown()
    {
        self.urlSessionManager?.invalidateSessionCancelingTasks(true)
        
        self.urlSessionManager = nil
    }
    
    func test_uploadLink_returnsStreamingLink_whenStreamingLinkIsAvailable()
    {
        let (descriptor, video) = self.descriptor(fromResponseWithFile: "clip_streaming.json")
        
        XCTAssertEqual(descriptor.uploadLink(from: video), "https://www.google.com")
    }
    
    func test_uploadLink_returnsGCSLink_whenGCSLinkIsAvailable()
    {
        let (descriptor, video) = self.descriptor(fromResponseWithFile: "clip_gcs.json")
        
        XCTAssertEqual(descriptor.uploadLink(from: video), "https://www.google.com")
    }
    
    func test_uploadLink_returnsNil_whenNeitherStreamLinkNorGCSLinkIsAvailable()
    {
        let (descriptor, video) = self.descriptor(fromResponseWithFile: "clip.json")
        
        XCTAssertNil(descriptor.uploadLink(from: video))
    }
    
    private func descriptor(fromResponseWithFile fileName: String) -> (UploadDescriptor, VIMVideo)
    {
        do
        {
            let bundle = Bundle(for: type(of: self))<commit_msg>Add messages for unit tests<commit_after>//
//  UploadDescriptorTests.swift
//  VimeoUpload-iOSTests
//
//  Created by <NAME> on 11/13/18.
//  Copyright © 2018 <NAME>. All rights reserved.
//

import XCTest
import AFNetworking
@testable import VimeoNetworking
@testable import VimeoUpload

class UploadDescriptorTests: XCTestCase
{
    private var urlSessionManager: VimeoSessionManager!
    
    override func setUp()
    {
        super.setUp()
        
        self.urlSessionManager = VimeoSessionManager.defaultSessionManager(appConfiguration: AppConfiguration(clientIdentifier: "", clientSecret: "", scopes: [], keychainService: ""), configureSessionManagerBlock: nil)
    }
    
    override func tearDown()
    {
        self.urlSessionManager?.invalidateSessionCancelingTasks(true)
        
        self.urlSessionManager = nil
    }
    
    func test_uploadLink_returnsStreamingLink_whenStreamingLinkIsAvailable()
    {
        let (descriptor, video) = self.descriptor(fromResponseWithFile: "clip_streaming.json")
        
        XCTAssertEqual(descriptor.uploadLink(from: video), "https://www.google.com", "`uploadLink` should have returned a streaming link.")
    }
    
    func test_uploadLink_returnsGCSLink_whenGCSLinkIsAvailable()
    {
        let (descriptor, video) = self.descriptor(fromResponseWithFile: "clip_gcs.json")
        
        XCTAssertEqual(descriptor.uploadLink(from: video), "https://www.google.com", "`uploadLink` should have returned an GCS link.")
    }
    
    func test_uploadLink_returnsNil_whenNeitherStreamLinkNorGCSLinkIsAvailable()
    {
        let (descriptor, video) = self.descriptor(fromResponseWithFile: "clip.json")
        
        XCTAssertNil(descriptor.uploadLink(from: video), "`uploadLink` should have returned nil.")
    }
    
    private func descriptor(fromResponseWithFile fileName: String) -> (UploadDescriptor, VIMVideo)
    {
        do
        {
            let bundle = Bundle(for: type(of: self))
{'fraction_non_alphanumeric': 0.09685101878803916, 'fraction_numerical': 0.005292405398253507, 'mean_word_length': 3.290578887627696, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3230043', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1072, 'n_words': 206}