def test_update_builtin_up_to_date(self): shutil.copyfile(self.original_fabfile, self.local_fabfile) utils.copytree(self.original_theme, self.local_theme) updater.update_builtin(**self.kwargs) original_fn_md5 = utils.get_md5(self.original_fabfile) local_fn_md5 = utils.get_md5(self.local_fabfile) self.assertEqual(original_fn_md5, local_fn_md5) original_fn_md5 = utils.get_dir_md5(self.original_theme) local_fn_md5 = utils.get_dir_md5(self.local_theme) self.assertEqual(original_fn_md5, local_fn_md5)
def test_update_builtin_not_exists_with_yes(self, mock_input): self.assertFalse(os.path.exists(self.local_fabfile)) self.assertFalse(os.path.exists(self.local_theme)) updater.update_builtin(**self.kwargs) original_fn_md5 = utils.get_md5(self.original_fabfile) local_fn_md5 = utils.get_md5(self.local_fabfile) self.assertEqual(original_fn_md5, local_fn_md5) original_fn_md5 = utils.get_dir_md5(self.original_theme) local_fn_md5 = utils.get_dir_md5(self.local_theme) self.assertEqual(original_fn_md5, local_fn_md5) os.remove(self.local_theme_afile) updater.update_builtin(**self.kwargs) original_fn_md5 = utils.get_dir_md5(self.original_theme) local_fn_md5 = utils.get_dir_md5(self.local_theme) self.assertEqual(original_fn_md5, local_fn_md5)
def test_update_builtin_exists_with_no(self, mock_input): # empty fabfile.py with open(self.local_fabfile, 'wb') as _fd: _fd.close() original_fn_md5 = utils.get_md5(self.original_fabfile) local_fn_md5 = utils.get_md5(self.local_fabfile) self.assertNotEqual(original_fn_md5, local_fn_md5) utils.copytree(self.original_theme, self.local_theme) with open(self.local_theme_afile, 'wb') as _fd: _fd.close() original_fn_md5 = utils.get_dir_md5(self.original_theme) local_fn_md5 = utils.get_dir_md5(self.local_theme) self.assertNotEqual(original_fn_md5, local_fn_md5) updater.update_builtin(**self.kwargs) original_fn_md5 = utils.get_md5(self.original_fabfile) local_fn_md5 = utils.get_md5(self.local_fabfile) self.assertNotEqual(original_fn_md5, local_fn_md5) original_fn_md5 = utils.get_dir_md5(self.original_theme) local_fn_md5 = utils.get_dir_md5(self.local_theme) self.assertNotEqual(original_fn_md5, local_fn_md5)
def test_get_dir_md5(self): test_dir = os.path.join(self.content, 'python') self.assertEqual('ab2bf30fc9b8ead85e52fd19d02a819e', utils.get_dir_md5(test_dir))