示例#1
0
def test_fileparser_test4():
    """
    Test with a binary file.
    """

    filename = "namdcoordfile.coor"
    path = os.path.join(os.getcwd(), "tests/standards/")
    files = []
    substitutions = {}

    file_parser(filename, path, files, substitutions)

    assert files == ["namdcoordfile.coor"]
示例#2
0
def test_fileparser_test3():
    """
    Test with simple dependant files.
    """

    filename = "apps_fileparsernamd.txt"
    path = os.path.join(os.getcwd(), "tests/standards/")
    files = []
    substitutions = {}

    file_parser(filename, path, files, substitutions)

    assert files == ["apps_fileparsernamd.txt", "apps_recursivetest.txt"]
示例#3
0
def test_fileparser_test2(m_subs):
    """
    Test that with a blank file the recursive checks aren't attempted.
    """

    filename = "apps_fileparserblank.txt"
    path = os.path.join(os.getcwd(), "tests/standards/")
    files = ["anotherfile"]
    substitutions = {}

    file_parser(filename, path, files, substitutions)

    assert m_subs.call_count == 0
示例#4
0
def test_fileparser_test1(m_check, m_file):
    """
    Test that if add file is already in the files list that nothing happens.
    """

    filename = "testfile"
    path = ""
    files = ["testfile", "anotherfile"]
    substitutions = {}

    m_check.return_value = "testfile"

    file_parser(filename, path, files, substitutions)

    assert m_file.call_count == 0
示例#5
0
def test_fileparser_test5(subs):
    """
    Test with a binary file check file still added for upload on mocked except.

    This is test is really a bit of a fake, since it is difficult to mock the
    exception in the way it is thrown organically. But this test does do the
    trick!
    """

    filename = "namdcoordfile.coor"
    path = os.path.join(os.getcwd(), "tests/standards/")
    files = []
    substitutions = {}

    subs.side_effect = UnicodeDecodeError('blah', b'', 80, 0, '')

    file_parser(filename, path, files, substitutions)

    assert files == ["namdcoordfile.coor"]