Fix git plugin tests.

Add fake author info to environment while running the tests to avoid
failure of the git commit commands.
main
Olivier Mangin 4 years ago
parent 526ed05c41
commit fd2227b548
No known key found for this signature in database
GPG Key ID: D72FEC1C3120A884

@ -20,6 +20,13 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r dev_requirements.txt
- name: Configure git author (fix issue with environment variable)
run: |
# Manually sets some git user and email to avoid failure of the test
# (For some reason the environment variables set in the test are not
# taken into account by git on the runner.)
git config --global user.name "Pubs test"
git config --global user.email "unittest@pubs.org"
- name: Test with pytest (mock API mode)
env:
PUBS_TESTS_MODE: MOCK

@ -1,5 +1,6 @@
import unittest
import os
import subprocess
import unittest
import sand_env
@ -16,12 +17,22 @@ class TestGitPlugin(sand_env.SandboxedCommandTestCase):
def setUp(self, nsec_stat=True):
super(TestGitPlugin, self).setUp()
# Backup environment variables and set git author
self.env_backup = os.environ.copy()
os.environ['GIT_AUTHOR_NAME'] = "Pubs test"
os.environ['GIT_AUTHOR_EMAIL'] = "unittest@pubs.org"
# Setup pubs repository
self.execute_cmds([('pubs init',)])
conf = config.load_conf(path=self.default_conf_path)
conf['plugins']['active'] = ['git']
config.save_conf(conf, path=self.default_conf_path)
def tearDown(self):
super().tearDown()
os.environ = self.env_backup
def test_git(self):
print(self.default_pubs_dir)
self.execute_cmds([('pubs add data/pagerank.bib',)])
hash_a = git_hash(self.default_pubs_dir)
@ -72,6 +83,7 @@ class TestGitPlugin(sand_env.SandboxedCommandTestCase):
# self.assertEqual(hash_i, hash_j)
def test_manual(self):
print(self.default_pubs_dir)
conf = config.load_conf(path=self.default_conf_path)
conf['plugins']['active'] = ['git']
conf['plugins']['git']['manual'] = True

Loading…
Cancel
Save