<commit_before>import XCTest
import OctoKit

class LabelTests: XCTestCase {
    static var allTests = [
        ("testGetLabel", testGetLabel),
        ("testGetLabelEncodesSpaceCorrectly", testGetLabelEncodesSpaceCorrectly),
        ("testGetLabels", testGetLabels),
        ("testGetLabelsSetsPagination", testGetLabelsSetsPagination),
        ("testParsingLabel", testParsingLabel),
        ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests)
    ]

    // MARK: Request Tests
    func testGetLabel() {
        let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/hello-world/labels/bug", expectedHTTPMethod: "GET", jsonFile: "label", statusCode: 200)
        let task = Octokit().label(session, owner: "octocat", repository: "hello-world", name: "bug") { response in
            switch response {
            case .success(let label):
                XCTAssertEqual(label.name, "bug")
            case .failure:
                XCTAssert(false, "should not get an error")
            }
        }
        XCTAssertNotNil(task)
        XCTAssertTrue(session.wasCalled)
    }
    
    func testGetLabelEncodesSpaceCorrectly() {
        let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/hello-world/labels/help%20wanted", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 200)
        let task = Octokit().label(session, owner: "octocat", repository: "hello-world", name: "help wanted") { response in
            switch response {
            case .success:
                XCTAssert(true)
            case .failure:
                XCTAssert(false, "should not get an error")
            }
        }
        XCTAssertNotNil(task)
        XCTAssertTrue(session.wasCalled)
    }
    
    func testGetLabels() {
        let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/hello-world/labels?page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "labels", statusCode: 200)
        let task = Octokit().labels(session, owner: "octocat", repository: "hello-world") { response in
            switch response {
            case .success(let labels):
                XCTAssertEqual(labels.count, 7)
            case .failure:
                XCTAssert(false, "should not get an error")
            }
        }
        XCTAssertNotNil(task)
        XCTAssertTrue(session.wasCalled)
    }
    
    func testGetLabelsSetsPagination() {
        let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/hello-world/labels?page=2&per_page=50", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 200)
        let task = Octokit().labels(session, owner: "octocat", repository: "hello-world", page: "2", perPage: "50") { response in
            switch response {
            case .success:
                XCTAssert(true)
            case .failure:
                XCTAssert(false, "should not get an error")
            }
        }
        XCTAssertNotNil(task)
        XCTAssertTrue(session.wasCalled)
    }

    
    // MARK: Parsing Tests
    func testParsingLabel() {
        let label = Helper.codableFromFile("label", type: Label.self)
        XCTAssertEqual(label.name, "bug")<commit_msg>Test for .createLabels<commit_after>import XCTest
import OctoKit

class LabelTests: XCTestCase {
    static var allTests = [
        ("testGetLabel", testGetLabel),
        ("testGetLabelEncodesSpaceCorrectly", testGetLabelEncodesSpaceCorrectly),
        ("testGetLabels", testGetLabels),
        ("testGetLabelsSetsPagination", testGetLabelsSetsPagination),
        ("testCreateLabel", testCreateLabel),
        ("testParsingLabel", testParsingLabel),
        ("testLinuxTestSuiteIncludesAllTests", testLinuxTestSuiteIncludesAllTests)
    ]

    // MARK: Request Tests
    func testGetLabel() {
        let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/hello-world/labels/bug", expectedHTTPMethod: "GET", jsonFile: "label", statusCode: 200)
        let task = Octokit().label(session, owner: "octocat", repository: "hello-world", name: "bug") { response in
            switch response {
            case .success(let label):
                XCTAssertEqual(label.name, "bug")
            case .failure:
                XCTAssert(false, "should not get an error")
            }
        }
        XCTAssertNotNil(task)
        XCTAssertTrue(session.wasCalled)
    }
    
    func testGetLabelEncodesSpaceCorrectly() {
        let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/hello-world/labels/help%20wanted", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 200)
        let task = Octokit().label(session, owner: "octocat", repository: "hello-world", name: "help wanted") { response in
            switch response {
            case .success:
                XCTAssert(true)
            case .failure:
                XCTAssert(false, "should not get an error")
            }
        }
        XCTAssertNotNil(task)
        XCTAssertTrue(session.wasCalled)
    }
    
    func testGetLabels() {
        let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/hello-world/labels?page=1&per_page=100", expectedHTTPMethod: "GET", jsonFile: "labels", statusCode: 200)
        let task = Octokit().labels(session, owner: "octocat", repository: "hello-world") { response in
            switch response {
            case .success(let labels):
                XCTAssertEqual(labels.count, 7)
            case .failure:
                XCTAssert(false, "should not get an error")
            }
        }
        XCTAssertNotNil(task)
        XCTAssertTrue(session.wasCalled)
    }
    
    func testGetLabelsSetsPagination() {
        let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/hello-world/labels?page=2&per_page=50", expectedHTTPMethod: "GET", jsonFile: nil, statusCode: 200)
        let task = Octokit().labels(session, owner: "octocat", repository: "hello-world", page: "2", perPage: "50") { response in
            switch response {
            case .success:
                XCTAssert(true)
            case .failure:
                XCTAssert(false, "should not get an error")
            }
        }
        XCTAssertNotNil(task)
        XCTAssertTrue(session.wasCalled)
    }

    func testCreateLabel() {
        let session = OctoKitURLTestSession(expectedURL: "https://api.github.com/repos/octocat/hello-world/labels", expectedHTTPMethod: "POST", jsonFile: "label", statusCode: 200)
        let task = Octokit().postLabel(session, owner: "octocat", repository: "hello-world", name: "<NAME>", color: "ffffff") { response in
            switch response {
            case .success(let label):
                XCTAssertNotNil(label)
            case .failure:
                XCTAssert(false, "should not get an error")
            }
        }
        XCTAssertNotNil(task)
        XCTAssertTrue(session.wasCalled)
    }
    
    
    // MARK: Parsing Tests
    func testParsingLabel() {
        let label = Helper.codableFromFile("label", type: Label.self)
        XCTAssertEqual(label.name, "bug")
{'fraction_non_alphanumeric': 0.1116046640755136, 'fraction_numerical': 0.007357023875624653, 'mean_word_length': 2.51806640625, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 9, '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': '3499856', 'n_tokens_mistral': 2136, 'n_tokens_neox': 2059, 'n_words': 432}