Fix git plugin tests.
Add fake author info to environment while running the tests to avoid failure of the git commit commands.
This commit is contained in:
parent
526ed05c41
commit
fd2227b548
7
.github/workflows/tests.yaml
vendored
7
.github/workflows/tests.yaml
vendored
@ -20,6 +20,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r dev_requirements.txt
|
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)
|
- name: Test with pytest (mock API mode)
|
||||||
env:
|
env:
|
||||||
PUBS_TESTS_MODE: MOCK
|
PUBS_TESTS_MODE: MOCK
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import unittest
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import unittest
|
||||||
|
|
||||||
import sand_env
|
import sand_env
|
||||||
|
|
||||||
@ -16,12 +17,22 @@ class TestGitPlugin(sand_env.SandboxedCommandTestCase):
|
|||||||
|
|
||||||
def setUp(self, nsec_stat=True):
|
def setUp(self, nsec_stat=True):
|
||||||
super(TestGitPlugin, self).setUp()
|
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',)])
|
self.execute_cmds([('pubs init',)])
|
||||||
conf = config.load_conf(path=self.default_conf_path)
|
conf = config.load_conf(path=self.default_conf_path)
|
||||||
conf['plugins']['active'] = ['git']
|
conf['plugins']['active'] = ['git']
|
||||||
config.save_conf(conf, path=self.default_conf_path)
|
config.save_conf(conf, path=self.default_conf_path)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super().tearDown()
|
||||||
|
os.environ = self.env_backup
|
||||||
|
|
||||||
def test_git(self):
|
def test_git(self):
|
||||||
|
print(self.default_pubs_dir)
|
||||||
self.execute_cmds([('pubs add data/pagerank.bib',)])
|
self.execute_cmds([('pubs add data/pagerank.bib',)])
|
||||||
hash_a = git_hash(self.default_pubs_dir)
|
hash_a = git_hash(self.default_pubs_dir)
|
||||||
|
|
||||||
@ -72,6 +83,7 @@ class TestGitPlugin(sand_env.SandboxedCommandTestCase):
|
|||||||
# self.assertEqual(hash_i, hash_j)
|
# self.assertEqual(hash_i, hash_j)
|
||||||
|
|
||||||
def test_manual(self):
|
def test_manual(self):
|
||||||
|
print(self.default_pubs_dir)
|
||||||
conf = config.load_conf(path=self.default_conf_path)
|
conf = config.load_conf(path=self.default_conf_path)
|
||||||
conf['plugins']['active'] = ['git']
|
conf['plugins']['active'] = ['git']
|
||||||
conf['plugins']['git']['manual'] = True
|
conf['plugins']['git']['manual'] = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user