<commit_before>//
//  BFileManagerTests.swift
//  BartlebyKit
//
//  Created by <NAME> on 06/05/2016.
//
//

import XCTest
import BartlebyKit

class BFileManagerTests: TestCase {
    let fm = Bartleby.fileManager

    func test101_writeString() {
        let folder = BFileManagerTests.assetPath + Bartleby.randomStringWithLength(6) + "/"

        // Checking no items (directory or file) exists
        let directoryShouldNotExist1 = self.expectationWithDescription("Directory should not exist")
        self.fm.directoryExistsAtPath(folder,
                                      handlers: Handlers { (existence) in
                                        directoryShouldNotExist1.fulfill()
                                        XCTAssertFalse(existence.success)
                                        XCTAssertEqual(404, existence.statusCode)
            })
        let itemShouldNotExist = self.expectationWithDescription("Directory should not exist")
        self.fm.itemExistsAtPath(folder,
                                 handlers: Handlers { (existence) in
                                    itemShouldNotExist.fulfill()
                                    XCTAssertFalse(existence.success)
                                    XCTAssertEqual(404, existence.statusCode)
            })
        let fileShouldNotExist = self.expectationWithDescription("Directory should not exist")
        self.fm.fileExistsAtPath(folder,
                                 handlers: Handlers { (existence) in
                                    fileShouldNotExist.fulfill()
                                    XCTAssertFalse(existence.success)
                                    XCTAssertEqual(404, existence.statusCode)
            })

        // Create directory
        let directoryShouldBeCreated = self.expectationWithDescription("Directory should be created")
        self.fm.createDirectoryAtPath(folder, handlers: Handlers { (creation) in
            directoryShouldBeCreated.fulfill()
            XCTAssert(creation.success, creation.message)

            // Check the new directory exists
            let directoryShouldExist = self.expectationWithDescription("Directory should exist")
            self.fm.directoryExistsAtPath(folder,
                handlers: Handlers { (existence) in
                    directoryShouldExist.fulfill()
                    XCTAssertTrue(existence.success)
                    XCTAssertEqual(200, existence.statusCode)
                })
            let itemShouldExist1 = self.expectationWithDescription("Item should exist")
            self.fm.itemExistsAtPath(folder,
                handlers: Handlers { (existence) in
                    itemShouldExist1.fulfill()
                    XCTAssertTrue(existence.success)
                    XCTAssertEqual(200, existence.statusCode)
                })
            let itemIsNotAFile = self.expectationWithDescription("Item is not a file")
            self.fm.fileExistsAtPath(folder,
                handlers: Handlers { (existence) in
                    itemIsNotAFile.fulfill()
                    XCTAssertFalse(existence.success)
                    XCTAssertEqual(415, existence.statusCode)
                })

            // Create file
            let aaa = Bartleby.randomStringWithLength(6)
            let filePath = folder + "test.txt"
            let writeExpectation = self.expectationWithDescription("A string should be written")
            self.fm.writeString(aaa, path: filePath, handlers: Handlers { (write) in
                writeExpectation.fulfill()
                XCTAssert(write.success, write.message)

                // Check the new file exists
                let directoryShouldNotExist2 = self.expectationWithDescription("Directory should not exist")
                self.fm.directoryExistsAtPath(filePath,
                    handlers: Handlers { (existence) in
                        directoryShouldNotExist2.fulfill()
                        XCTAssertFalse(existence.success)
                        XCTAssertEqual(415, existence.statusCode)
                    })
                let itemShouldExist2 = self.expectationWithDescription("Item should exist")
                self.fm.itemExistsAtPath(filePath,
                    handlers: Handlers { (existence) in
                        itemShouldExist2.fulfill()
                        XCTAssertTrue(existence.success)
                        XCTAssertEqual(200, existence.statusCode)
                    })
                let itemIsNotADirectory = self.expectationWithDescription("Item is not a directory")
                self.fm.fileExistsAtPath(filePath,
                    handlers: Handlers { (existence) in
                        itemIsNotADirectory.fulfill()
                        XCTAssertTrue(existence.success)
                        XCTAssertEqual(200, existence.statusCode)
                    })

                // Check the file content
                let readExpectation = self.expectationWithDescription("A string shoudl be read")
                self.fm.readString(contentsOfFile: filePath, handlers: Handlers { (read) in
                    readExpectation.fulfill()
                    if let bbb = read.getStringResult() where read.success {
                        XCTAssertEqual(bbb, aaa)
                    } else {
                        XCTFail(read.message)
                    }
                })

                // Retrieve the folder content
                let listExpectation = self.expectationWithDescription("A list should be returned")
                self.fm.contentsOfDirectoryAtPath(folder, handlers: Handlers { (content) in
                    listExpectation.fulfill()
                    XCTAssertEqual(200, content.statusCode)
                    if let list = content.getStringArrayResult() where content.success {
                        XCTAssertEqual(list, ["test.txt"])
                    } else {
                        XCTFail(content.message)
                    }
                })

            })


        })

        waitForExpectationsWithTimeout(TestsConfiguration.TIME_OUT_DURATION, handler: nil)
    }
}
<commit_msg>Erasing martin's stupid file manager tests  ( we need to write tests with multiple dispatch_queue )<commit_after>//
//  BFileManagerTests.swift
//  BartlebyKit
//
//  Created by <NAME> on 06/05/2016.
//
//

import XCTest
import BartlebyKit

class BFileManagerTests: TestCase {


    let fm = BFileManager(onQueue:dispatch_get_main_queue())

    static let folder = BFileManagerTests.assetPath + Bartleby.randomStringWithLength(6) + "/"


    func test100_folder_should_not_exists() {

        // Checking no items (directory or file) exists
        let directoryShouldNotExist = self.expectationWithDescription("Directory should not exist")
        self.fm.directoryExistsAtPath(BFileManagerTests.folder,
                                      handlers: Handlers { (existence) in
                                        directoryShouldNotExist.fulfill()
                                        XCTAssertFalse(existence.success)
                                        XCTAssertEqual(404, existence.statusCode)
        })
        waitForExpectationsWithTimeout(TestsConfiguration.TIME_OUT_DURATION, handler: nil)
    }


}

{'fraction_non_alphanumeric': 0.07118365107666987, 'fraction_numerical': 0.009052256206281717, 'mean_word_length': 1.637251356238698, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3431358', 'n_tokens_mistral': 1816, 'n_tokens_neox': 1658, 'n_words': 341}