Test the install function
(self)
| 84 | ''' |
| 85 | |
| 86 | def test_install(self): |
| 87 | """Test the install function""" |
| 88 | |
| 89 | # dotpath location |
| 90 | tmp = get_tempdir() |
| 91 | self.assertTrue(os.path.exists(tmp)) |
| 92 | self.addCleanup(clean, tmp) |
| 93 | |
| 94 | # where dotfiles will be installed |
| 95 | dst = get_tempdir() |
| 96 | self.assertTrue(os.path.exists(dst)) |
| 97 | self.addCleanup(clean, dst) |
| 98 | |
| 99 | # create the dotfile in dotdrop |
| 100 | fcontent1, _ = create_random_file(tmp) |
| 101 | dst1 = os.path.join(dst, get_string(6)) |
| 102 | dotfile1 = Dotfile(get_string(5), dst1, os.path.basename(fcontent1)) |
| 103 | # fake a __str__ |
| 104 | self.assertTrue(str(dotfile1) != '') |
| 105 | fcontent2, _ = create_random_file(tmp) |
| 106 | dst2 = os.path.join(dst, get_string(6)) |
| 107 | dotfile2 = Dotfile(get_string(5), dst2, os.path.basename(fcontent2)) |
| 108 | with open(fcontent2, 'w', encoding='utf-8') as file: |
| 109 | file.write(self.TEMPLATE) |
| 110 | fcontent3, _ = create_random_file(tmp, binary=True) |
| 111 | dst3 = os.path.join(dst, get_string(6)) |
| 112 | dotfile3 = Dotfile(get_string(5), dst3, os.path.basename(fcontent3)) |
| 113 | |
| 114 | # create a directory dotfile |
| 115 | dir1 = os.path.join(tmp, 'somedir') |
| 116 | create_dir(dir1) |
| 117 | fildfd, _ = create_random_file(dir1) |
| 118 | dstd = os.path.join(dst, get_string(6)) |
| 119 | ddot = Dotfile(get_string(5), dstd, os.path.basename(dir1)) |
| 120 | |
| 121 | # to test backup |
| 122 | fcontent4, _ = create_random_file(tmp) |
| 123 | dst4 = os.path.join(dst, get_string(6)) |
| 124 | dotfile4 = Dotfile(key=get_string(6), |
| 125 | dst=dst4, |
| 126 | src=os.path.basename(fcontent4)) |
| 127 | with open(dst4, 'w', |
| 128 | encoding='utf-8') as file: |
| 129 | file.write(get_string(16)) |
| 130 | |
| 131 | # to test link |
| 132 | fcontent5, _ = create_random_file(tmp) |
| 133 | dst5 = os.path.join(dst, get_string(6)) |
| 134 | self.addCleanup(clean, dst5) |
| 135 | dotfile5 = Dotfile(get_string(6), dst5, |
| 136 | os.path.basename(fcontent5), link=LinkTypes.LINK) |
| 137 | |
| 138 | # create the dotfile directories in dotdrop |
| 139 | dir1 = create_dir(os.path.join(tmp, get_string(6))) |
| 140 | self.assertTrue(os.path.exists(dir1)) |
| 141 | self.addCleanup(clean, dir1) |
| 142 | dst6 = os.path.join(dst, get_string(6)) |
| 143 | # fill with files |
nothing calls this directly
no test coverage detected