Exemple #1
0
def test_path_exists_case_sensitive_returns_false_for_incorrect_case():
    current_folder = os.path.dirname(os.path.abspath(__file__))
    output_folder = Path(current_folder).parent.parent
    test_folder = str(output_folder)
    path_name0 = "example/dirTreewithTests/otherFolder/test1"
    path_name1 = "example/dirTreeWithTests/otherfolder/test1"
    path_name2 = "example/dirTreeWithTests/otherFolder/tEst1"

    assert path_exists_case_sensitive(path_name0,
                                      parent_path=test_folder) == False
    assert path_exists_case_sensitive(path_name1,
                                      parent_path=test_folder) == False
    assert path_exists_case_sensitive(path_name2,
                                      parent_path=test_folder) == False
Exemple #2
0
def test_path_exists_case_sensitive_returns_false_for_non_existing_path():
    current_folder = os.path.dirname(os.path.abspath(__file__))
    output_folder = Path(current_folder).parent.parent
    test_folder = str(output_folder)
    path_name0 = "example/dirTreeWithTests/2qffg88assh/test1"
    path_name1 = "example/asdhjgf67qbfa/otherFolder/test1"
    path_name2 = "example/dirTreeWithTests/otherFolder/sd68asd6"

    assert path_exists_case_sensitive(path_name0,
                                      parent_path=test_folder) == False
    assert path_exists_case_sensitive(path_name1,
                                      parent_path=test_folder) == False
    assert path_exists_case_sensitive(path_name2,
                                      parent_path=test_folder) == False
Exemple #3
0
def test_path_exists_case_sensitive_returns_false_for_incorrect_case_with_not_parent(
):
    current_folder = os.path.dirname(os.path.abspath(__file__))
    output_folder = Path(current_folder).parent.parent
    test_folder = str(output_folder)
    path_name0 = os.path.join(test_folder,
                              "example/dirTreewithTests/otherFolder/test1")
    path_name1 = os.path.join(test_folder,
                              "example/dirTreeWithTests/otherfolder/test1")
    path_name2 = os.path.join(test_folder,
                              "example/dirTreeWithTests/otherFolder/tEst1")

    assert path_exists_case_sensitive(path_name0) == False
    assert path_exists_case_sensitive(path_name1) == False
    assert path_exists_case_sensitive(path_name2) == False
Exemple #4
0
def test_path_exists_case_sensitive_returns_true_for_existing_path_no_parent():
    current_folder = os.path.dirname(os.path.abspath(__file__))
    output_folder = Path(current_folder).parent.parent
    test_folder = str(output_folder)
    path_name = os.path.join(test_folder,
                             "example/dirTreeWithTests/otherFolder/test1")

    assert path_exists_case_sensitive(path_name) == True
Exemple #5
0
 def execute(self, outputFolder):
     success = not rules_util.path_exists_case_sensitive(
         self.pathName, parent_path=outputFolder)
     if (not success):
         messager.printError("assertion pathNotExists " + self.pathName +
                             " failed.  path " +
                             os.path.join(outputFolder, self.pathName) +
                             " exists")
     return success
 def execute(self, outputFolder):
     if (not path_exists_case_sensitive(self.fileName,
                                        parent_path=outputFolder)):
         messager.printError(
             "assertion fileContainsSnippet {0} {1} failed. {0} does not exist in {2}."
             .format(self.fileName, self.snippetFile, outputFolder))
         return False
     if (not path_exists_case_sensitive(self.snippetFile,
                                        parent_path=self.testFolder)):
         messager.printError(
             "assertion fileContainsSnippet {0} {1} failed. {1} does not exist in {2}."
             .format(self.fileName, self.snippetFile, self.testFolder))
         return False
     fileLines = readLinesFromFile(self.fileName, folder=outputFolder)
     snippetLines = readLinesFromFile(self.snippetFile,
                                      folder=self.testFolder)
     success = snippetExistsInFile(snippetLines, fileLines)
     if not success:
         messager.printError(
             "assertion fileContainsSnippet {0} {1} failed.  Matching lines from {1} not found in {2}/{0}."
             .format(self.fileName, self.snippetFile, outputFolder))
     return success
Exemple #7
0
 def execute(self, outputFolder):
     if (not path_exists_case_sensitive(self.fileName,
                                        parent_path=outputFolder)):
         messager.printError(
             "assertion fileHasMatchingLine {0} {1} failed. {0} does not exist in {2}."
             .format(self.fileName, self.regex, outputFolder))
         return False
     fileLines = readLinesFromFile(self.fileName, folder=outputFolder)
     filtered = filter(lambda line: re.search(self.regex, line), fileLines)
     success = len(list(filtered)) > 0
     if not success:
         messager.printError(
             "assertion fileHasMatchingLine {0} {1} failed.  Matching line not found in {2}/{0}."
             .format(self.fileName, self.regex, outputFolder))
     return success
    def execute(self, outputFolder):
        if (not path_exists_case_sensitive(self.fileName,
                                           parent_path=outputFolder)):
            messager.printError(
                "assertion fileContainsLine {0} {1} failed. {0} does not exist in {2}."
                .format(self.fileName, self.line, outputFolder))
            return False

        fileLines = readLinesFromFile(self.fileName, folder=outputFolder)
        success = self.line in fileLines
        if not success:
            messager.printError(
                "assertion fileContainsLine {0} {1} failed.  Matching line not found in {2}/{0}."
                .format(self.fileName, self.line, outputFolder))
        return success
 def execute(self, outputFolder):
     fixtureFile = os.path.join(self.testFolder, self.fixturePath)
     outputFile = os.path.join(outputFolder, self.fileName)
     if (not rules_util.path_exists_case_sensitive(fixtureFile)):
         messager.printError(
             "assertion fileMatches " + self.fileName + " " +
             self.fixturePath + " failed.  " + os.path.abspath(
                 os.path.join(self.testFolder, self.fixturePath)) +
             " does not exist")
         return False
     if (not rules_util.path_exists_case_sensitive(outputFile)):
         messager.printError(
             "assertion fileMatches " + self.fileName + " " +
             self.fixturePath + " failed.  " +
             os.path.abspath(os.path.join(outputFolder, self.fileName)) +
             " does not exist")
         return False
     success = filecmp.cmp(outputFile, fixtureFile, shallow=False)
     if (not success):
         messager.printError("assertion fileMatches " + self.fileName +
                             " " + self.fixturePath +
                             " failed.  Files differ")
         self.printDifferences(outputFile, fixtureFile)
     return success