def __test_plugin_commit_message(hg_project): hg_plugin = FSPlugin(hg_project) NEW_COMMIT_MSG = "New commit message" hg_plugin.pull() assert not hg_plugin.config.get("pootle_fs.commit_message") # make some updates hg_plugin.push_translations() # check that commit message uses default when not set in config with tmp_hg(hg_plugin.fs_url) as (tmp_repo_path, tmp_repo): last_commit = tmp_repo.hg.log('-1', '--pretty=%s') assert last_commit == DEFAULT_COMMIT_MSG # update the config hg_plugin.config["pootle_fs.commit_message"] = NEW_COMMIT_MSG # make further updates hg_plugin.add_translations() hg_plugin.sync_translations() # test that sync_translations committed with new commit message with tmp_hg(hg_plugin.fs_url) as (tmp_repo_path, tmp_repo): last_commit = tmp_repo.hg.log('-1', '--pretty=%s') assert last_commit == NEW_COMMIT_MSG
def __test_plugin_commit_committer(hg_project): plugin = FSPlugin(hg_project) NEW_COMMITTER_NAME = "New Committer" NEW_COMMITTER_EMAIL = "*****@*****.**" plugin.pull() assert not plugin.config.get("pootle_fs.committer_name") assert not plugin.config.get("pootle_fs.committer_email") # make some updates plugin.push_translations() # check that commit message uses system default when not set in config with tmp_hg(plugin.fs_url) as (tmp_repo_path, tmp_repo): last_committer_name = tmp_repo.hg.log('-1', '--pretty=%an') last_committer_email = tmp_repo.hg.log('-1', '--pretty=%ae') hg_config = tmp_repo.config_reader() default_user = os.environ["USER"] default_email = ( "%s@%s" % (default_user, os.environ.get("HOSTNAME", ""))) assert ( last_committer_name == hg_config.get_value("user", "name", default_user)) assert ( last_committer_email == hg_config.get_value("user", "email", default_email)) # update the committer name/email in config plugin.config["pootle_fs.committer_name"] = NEW_COMMITTER_NAME plugin.config["pootle_fs.committer_email"] = NEW_COMMITTER_EMAIL # make further updates plugin.add_translations() plugin.sync_translations() # test that sync_translations committed with new commit committer with tmp_hg(plugin.fs_url) as (tmp_repo_path, tmp_repo): last_committer_name = tmp_repo.hg.log('-1', '--pretty=%cn') last_committer_email = tmp_repo.hg.log('-1', '--pretty=%ce') assert last_committer_name == NEW_COMMITTER_NAME assert last_committer_email == NEW_COMMITTER_EMAIL
def __test_plugin_commit_committer(hg_project): plugin = FSPlugin(hg_project) NEW_COMMITTER_NAME = "New Committer" NEW_COMMITTER_EMAIL = "*****@*****.**" plugin.pull() assert not plugin.config.get("pootle_fs.committer_name") assert not plugin.config.get("pootle_fs.committer_email") # make some updates plugin.push_translations() # check that commit message uses system default when not set in config with tmp_hg(plugin.fs_url) as (tmp_repo_path, tmp_repo): last_committer_name = tmp_repo.hg.log('-1', '--pretty=%an') last_committer_email = tmp_repo.hg.log('-1', '--pretty=%ae') hg_config = tmp_repo.config_reader() default_user = os.environ["USER"] default_email = ("%s@%s" % (default_user, os.environ.get("HOSTNAME", ""))) assert (last_committer_name == hg_config.get_value( "user", "name", default_user)) assert (last_committer_email == hg_config.get_value( "user", "email", default_email)) # update the committer name/email in config plugin.config["pootle_fs.committer_name"] = NEW_COMMITTER_NAME plugin.config["pootle_fs.committer_email"] = NEW_COMMITTER_EMAIL # make further updates plugin.add_translations() plugin.sync_translations() # test that sync_translations committed with new commit committer with tmp_hg(plugin.fs_url) as (tmp_repo_path, tmp_repo): last_committer_name = tmp_repo.hg.log('-1', '--pretty=%cn') last_committer_email = tmp_repo.hg.log('-1', '--pretty=%ce') assert last_committer_name == NEW_COMMITTER_NAME assert last_committer_email == NEW_COMMITTER_EMAIL
def __test_plugin_pull(hg_project_1): hg_plugin = FSPlugin(hg_project_1) assert hg_plugin.is_cloned is False hg_plugin.pull() assert hg_plugin.is_cloned is True