<commit_before>@testable import Wikipedia
import XCTest

private class MockSchemeHandler: SchemeHandler {
    
    var accessed = false
    
    required init(scheme: String, session: Session) {
        super.init(scheme: scheme, session: session)
        let didReceiveDataCallback: ((WKURLSchemeTask, Data) -> Void)? = { _, _ in
            self.accessed = true
        }
        self.didReceiveDataCallback = didReceiveDataCallback
    }
}

class ArticleViewControllerTests: XCTestCase {
    let timeout: TimeInterval = 10
    
    override func setUp() {
       super.setUp()
       
       LSNocilla.sharedInstance().start()
       ArticleTestHelpers.stubCompleteMobileHTMLResponse(inBundle: wmf_bundle())
    }

    override func tearDown() {
       super.tearDown()
       LSNocilla.sharedInstance().stop()
    }

    func testArticleVCAccessesSchemeHandler() throws {
        
        //test that articleVC converts articleURL to proper scheme and sets up SchemeHandler to ensure it is accessed during a load
        let dataStore = MWKDataStore.temporary()
        let theme = Theme.light
        let url = URL(string: "https://en.wikipedia.org/wiki/Dog")!
        let schemeHandler = MockSchemeHandler(scheme: "app", session: dataStore.session)
        guard let articleVC = ArticleViewController(articleURL: url, dataStore: dataStore, theme: theme, schemeHandler: schemeHandler) else {
            XCTFail("Failure initializing Article View Controller")
            return
        }
        
        let setupExpectation = expectation(description: "Waiting for article initial setup call")
        
        articleVC.initialSetupCompletion = {
            setupExpectation.fulfill()
            XCTAssert(schemeHandler.accessed, "SchemeHandler was not accessed during article load.")
            UIApplication.shared.keyWindow?.rootViewController = nil
            dataStore.clearTemporaryCache()
        }
            
        UIApplication.shared.keyWindow?.rootViewController = articleVC
    
        wait(for: [setupExpectation], timeout: timeout)
        
        UIApplication.shared.keyWindow?.rootViewController = nil
        dataStore.session.cancelAllRequests()
    }

}<commit_msg>Remove duplicate call, consolidate test cleanup<commit_after>@testable import Wikipedia
import XCTest

private class MockSchemeHandler: SchemeHandler {
    
    var accessed = false
    
    required init(scheme: String, session: Session) {
        super.init(scheme: scheme, session: session)
        let didReceiveDataCallback: ((WKURLSchemeTask, Data) -> Void)? = { _, _ in
            self.accessed = true
        }
        self.didReceiveDataCallback = didReceiveDataCallback
    }
}

class ArticleViewControllerTests: XCTestCase {
    let timeout: TimeInterval = 10
    
    override func setUp() {
       super.setUp()
       
       LSNocilla.sharedInstance().start()
       ArticleTestHelpers.stubCompleteMobileHTMLResponse(inBundle: wmf_bundle())
    }

    override func tearDown() {
       super.tearDown()
       LSNocilla.sharedInstance().stop()
    }

    func testArticleVCAccessesSchemeHandler() throws {
        
        //test that articleVC converts articleURL to proper scheme and sets up SchemeHandler to ensure it is accessed during a load
        let dataStore = MWKDataStore.temporary()
        let theme = Theme.light
        let url = URL(string: "https://en.wikipedia.org/wiki/Dog")!
        let schemeHandler = MockSchemeHandler(scheme: "app", session: dataStore.session)
        guard let articleVC = ArticleViewController(articleURL: url, dataStore: dataStore, theme: theme, schemeHandler: schemeHandler) else {
            XCTFail("Failure initializing Article View Controller")
            return
        }
        
        let setupExpectation = expectation(description: "Waiting for article initial setup call")
        
        articleVC.initialSetupCompletion = {
            setupExpectation.fulfill()
            XCTAssert(schemeHandler.accessed, "SchemeHandler was not accessed during article load.")
            UIApplication.shared.keyWindow?.rootViewController = nil
            dataStore.clearTemporaryCache()
            dataStore.session.cancelAllRequests()
        }
            
        UIApplication.shared.keyWindow?.rootViewController = articleVC
    
        wait(for: [setupExpectation], timeout: timeout)
    }

}
{'fraction_non_alphanumeric': 0.07917620137299772, 'fraction_numerical': 0.0009153318077803204, 'mean_word_length': 2.707379134860051, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '824115', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1092, 'n_words': 279}