コード例 #1
0
def test_ufodiff_ufo_data_dir_file_false():
    ufo = Ufo()
    test_path_1 = os.path.join("source", "Test-Regular.ufo", "datum",
                               "org.sourcefoundry.coolstuff")  # bad dir path
    test_path_2 = os.path.join("source", "Test-Regular", "data",
                               "org.sourcefoundry.coolstuff")  # not ufo dir
    assert ufo._is_data_directory_file(test_path_1) is False
    assert ufo._is_data_directory_file(test_path_2) is False
コード例 #2
0
 def __init__(self, gitrepo_path, color_diff=False):
     self.gitrepo_path = gitrepo_path  # root path for git repository
     self.is_color_diff = color_diff  # is request for color diff = True
     self.repo = Repo(self.gitrepo_path)  # GitPython Repo object
     self.git = self.repo.git  # GitPython Repo.git object
     self.ufo = Ufo()  # ufodiff.utilities.ufo.Ufo object
     self.current_branch = self.git.rev_parse(
         "--abbrev-ref",
         "HEAD")  # current git branch automatically detected
コード例 #3
0
def test_ufodiff_ufo_images_dir_png_file_false():
    ufo = Ufo()
    test_path_1 = os.path.join("source", "anotherdir", "images",
                               "cap_a.png")  # not a UFO source directory
    test_path_2 = os.path.join("source", "Test-Regular.ufo", "image",
                               "cap_a.png")  # incorrect images dir path
    test_path_3 = os.path.join("source", "Test-Regular.ufo", "images",
                               "cap_a.jpg")  # jpg file, not png
    assert ufo._is_images_directory_file(test_path_1) is False
    assert ufo._is_images_directory_file(test_path_2) is False
    assert ufo._is_images_directory_file(test_path_3) is False
コード例 #4
0
def test_ufodiff_ufo_diff_filters():
    ufo = Ufo()
    filter_test_list = ufo.get_valid_file_filterlist_for_diff()
    # test for each of the nonglyph files
    for acceptable_file in ufo.acceptable_files:
        filter_file = "*" + acceptable_file
        assert filter_file in filter_test_list
    # test for inclusion of glyph files
    assert "*.glif" in filter_test_list
    assert r"*\.ufo/images/*" in filter_test_list
    assert r"*\.ufo/data/*" in filter_test_list
コード例 #5
0
def test_ufodiff_ufo_data_dir_file_via_public_method_call():
    ufo = Ufo()
    test_path_1 = os.path.join(
        "source", "Test-Regular.ufo", "datum",
        "org.sourcefoundry.coolstuff")  # bad dir path (False)
    test_path_2 = os.path.join(
        "source", "Test-Regular", "data",
        "org.sourcefoundry.coolstuff")  # not ufo dir (False)
    test_path_3 = os.path.join(
        "source", "Test-Regular.ufo", "data",
        "org.sourcefoundry.coolstuff")  # good path (True)
    assert ufo.validate_file(test_path_1) is False
    assert ufo.validate_file(test_path_2) is False
    assert ufo.validate_file(test_path_3) is True
コード例 #6
0
def test_ufodiff_ufo_images_dir_png_file_via_public_method_call():
    ufo = Ufo()
    test_path_1 = os.path.join(
        "source", "anotherdir", "images",
        "cap_a.png")  # not a UFO source directory (False)
    test_path_2 = os.path.join(
        "source", "Test-Regular.ufo", "image",
        "cap_a.png")  # incorrect images dir path (False)
    test_path_3 = os.path.join("source", "Test-Regular.ufo", "images",
                               "cap_a.jpg")  # jpg file, not png (False)
    test_path_4 = os.path.join("source", "Test-Regular.ufo", "images",
                               "cap_a.png")  # good path (True)
    assert ufo.validate_file(test_path_1) is False
    assert ufo.validate_file(test_path_2) is False
    assert ufo.validate_file(test_path_3) is False
    assert ufo.validate_file(test_path_4) is True
コード例 #7
0
    def __init__(
        self,
        gitrepo_path,
        ufo_directory_list,
        is_commit_test=False,
        commit_number="0",
        is_branch_test=False,
        compare_branch_name=None,
    ):
        self.gitrepo_path = gitrepo_path  # path to root of git repository
        self.ufo_directory_list = ufo_directory_list  # used to filter results by user defined UFO source directory
        self.is_commit_test = is_commit_test  # commit test flag
        self.commit_number = (
            commit_number  # user defined number of commits in git history to compare
        )
        self.is_branch_test = is_branch_test  # branch test flag
        self.compare_branch_name = (
            compare_branch_name  # comparison branch requested by user (if branch test)
        )
        self.current_branch_name = (
            ""  # defined in _define_and_validate_ufo_diff_lists if branch test
        )
        self.ufo = Ufo()  # Ufo class used for UFO source validations
        self.git = None  # GitPython object (instantiated in class method)
        self.delta_fp_string_dict = DeltaFilepathStringDict(
            ufo_directory_list
        )  # stores delta file strings in .delta_dict attribute

        self.commit_sha1_list = (
            [])  # used to create dictionaries of report data in class methods

        # file string lists
        self.added_ufo_file_list = (
            [])  # used to create dictionaries of report data in class methods
        self.modified_ufo_file_list = (
            [])  # used to create dictionaries of report data in class methods
        self.deleted_ufo_file_list = (
            [])  # used to create dictionaries of report data in class methods

        # filters files for UFO spec and includes only diff files that are part of spec
        self._define_and_validate_ufo_diff_lists(
        )  # defines many of the class properties on object instantiation
コード例 #8
0
def test_ufodiff_ufo_validate_file_true():
    ufo = Ufo()
    for the_file in ufo_acceptable_files:
        assert ufo.validate_file(the_file) is True
コード例 #9
0
def test_ufodiff_ufo_version_false():
    ufo = Ufo()
    assert ufo.is_ufo_version_file("fontinfo.plist") is False
コード例 #10
0
def test_ufodiff_ufo_version_true():
    ufo = Ufo()
    assert ufo.is_ufo_version_file("metainfo.plist") is True
コード例 #11
0
def test_ufodiff_ufo_glyph_false():
    ufo = Ufo()
    for nonglyph_file in ufo_acceptable_files:
        assert ufo.is_glyph_file(nonglyph_file) is False
コード例 #12
0
def test_ufodiff_ufo_glyph_true():
    ufo = Ufo()
    assert ufo.is_glyph_file("A.glif") is True
    assert ufo.is_glyph_file("A__.glif") is True
    assert ufo.is_glyph_file("0012.glif") is True
コード例 #13
0
def test_ufodiff_ufo_nonglyph_false():
    ufo = Ufo()
    assert ufo.is_nonglyph_file("A.glif") is False
コード例 #14
0
def test_ufodiff_ufo_nonglyph_true():
    ufo = Ufo()
    for (nonglyph_file) in (
            ufo_acceptable_files
    ):  # this file set only includes nonglyph files (i.e. not *.glif)
        assert ufo.is_nonglyph_file(nonglyph_file) is True
コード例 #15
0
def test_ufodiff_ufo_validate_file_false():
    ufo = Ufo()
    assert ufo.validate_file("testing.py") is False
コード例 #16
0
def test_ufodiff_ufo_images_dir_png_file_true():
    ufo = Ufo()
    test_path_1 = os.path.join("source", "Test-Regular.ufo", "images",
                               "cap_a.png")
    assert ufo._is_images_directory_file(test_path_1) is True
コード例 #17
0
def test_ufodiff_ufo_unacceptable_file():
    ufo = Ufo()
    assert (unacceptable_file in ufo.acceptable_files) is False
コード例 #18
0
def test_ufodiff_ufo_acceptable_files():
    ufo = Ufo()
    for the_file in ufo.acceptable_files:
        assert the_file in ufo_acceptable_files
コード例 #19
0
def test_ufodiff_ufo_data_dir_file_true():
    ufo = Ufo()
    test_path_1 = os.path.join("source", "Test-Regular.ufo", "data",
                               "org.sourcefoundry.coolstuff")
    assert ufo._is_data_directory_file(test_path_1) is True