mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] *: testing helpers
* add a sorted method on fake models * fix recordset equality to ignore ids order * when creating commits on a ref, add a param to only *update* the ref (forcefully): when simulating a force-push we don't want to *create* a ref as that might silently be done in the wrong repository entirely * fix pytest.skip call at the module level, not sure where it came from and why I missed it until now
This commit is contained in:
parent
cc029c2891
commit
8f3f773eef
11
conftest.py
11
conftest.py
@ -523,7 +523,7 @@ class Repo:
|
|||||||
)
|
)
|
||||||
return h
|
return h
|
||||||
|
|
||||||
def make_commits(self, root, *commits, ref=None):
|
def make_commits(self, root, *commits, ref=None, make=True):
|
||||||
assert self.hook
|
assert self.hook
|
||||||
if isinstance(root, list):
|
if isinstance(root, list):
|
||||||
parents = root
|
parents = root
|
||||||
@ -567,7 +567,8 @@ class Repo:
|
|||||||
parents = [hashes[-1]]
|
parents = [hashes[-1]]
|
||||||
|
|
||||||
if ref:
|
if ref:
|
||||||
self.make_ref(ref, hashes[-1], force=True)
|
fn = self.make_ref if make else self.update_ref
|
||||||
|
fn(ref, hashes[-1], force=True)
|
||||||
|
|
||||||
return hashes
|
return hashes
|
||||||
|
|
||||||
@ -925,7 +926,7 @@ class Model:
|
|||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if not isinstance(other, Model):
|
if not isinstance(other, Model):
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
return self._model == other._model and self._ids == other._ids
|
return self._model == other._model and set(self._ids) == set(other._ids)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "{}({})".format(self._model, ', '.join(str(id_) for id_ in self._ids))
|
return "{}({})".format(self._model, ', '.join(str(id_) for id_ in self._ids))
|
||||||
@ -950,6 +951,10 @@ class Model:
|
|||||||
def unlink(self):
|
def unlink(self):
|
||||||
return self._env(self._model, 'unlink', self._ids)
|
return self._env(self._model, 'unlink', self._ids)
|
||||||
|
|
||||||
|
def sorted(self, field):
|
||||||
|
rs = sorted(self.read([field]), key=lambda r: r[field])
|
||||||
|
return Model(self._env, self._model, [r['id'] for r in rs])
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
if isinstance(index, str):
|
if isinstance(index, str):
|
||||||
return getattr(self, index)
|
return getattr(self, index)
|
||||||
|
@ -283,7 +283,8 @@ More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port
|
|||||||
[new_c] = pr_repo.make_commits(
|
[new_c] = pr_repo.make_commits(
|
||||||
pr1.target.name,
|
pr1.target.name,
|
||||||
Commit('whop whop', tree={'x': '5'}),
|
Commit('whop whop', tree={'x': '5'}),
|
||||||
ref='heads/%s' % pr_ref
|
ref='heads/%s' % pr_ref,
|
||||||
|
make=False
|
||||||
)
|
)
|
||||||
env.run_crons()
|
env.run_crons()
|
||||||
|
|
||||||
@ -398,7 +399,8 @@ xxx
|
|||||||
# "b" was cloned before that branch got rolled back
|
# "b" was cloned before that branch got rolled back
|
||||||
prod.commit('b').id,
|
prod.commit('b').id,
|
||||||
Commit('g should indeed b xxx', tree={'g': 'xxx'}),
|
Commit('g should indeed b xxx', tree={'g': 'xxx'}),
|
||||||
ref='heads/%s' % pr_ref
|
ref='heads/%s' % pr_ref,
|
||||||
|
make=False,
|
||||||
)
|
)
|
||||||
env.run_crons()
|
env.run_crons()
|
||||||
assert prod.read_tree(prod.commit(pr1.head)) == {
|
assert prod.read_tree(prod.commit(pr1.head)) == {
|
||||||
@ -502,7 +504,8 @@ def test_conflict_deleted(env, config, make_repo):
|
|||||||
# "b" was cloned before that branch got rolled back
|
# "b" was cloned before that branch got rolled back
|
||||||
prod.commit('b').id,
|
prod.commit('b').id,
|
||||||
Commit('f should indeed be removed', tree={'g': 'c'}, reset=True),
|
Commit('f should indeed be removed', tree={'g': 'c'}, reset=True),
|
||||||
ref='heads/%s' % pr_ref
|
ref='heads/%s' % pr_ref,
|
||||||
|
make=False,
|
||||||
)
|
)
|
||||||
env.run_crons()
|
env.run_crons()
|
||||||
assert prod.read_tree(prod.commit(pr1.head)) == {
|
assert prod.read_tree(prod.commit(pr1.head)) == {
|
||||||
|
@ -809,7 +809,7 @@ def test_forward_port(env, repo, config):
|
|||||||
commits = {c['sha'] for c in repo.log('heads/master')}
|
commits = {c['sha'] for c in repo.log('heads/master')}
|
||||||
assert len(commits) == 112
|
assert len(commits) == 112
|
||||||
|
|
||||||
@pytest.skip("Needs to find a way to make set_ref fail on *second* call.")
|
@pytest.mark.skip("Needs to find a way to make set_ref fail on *second* call.")
|
||||||
def test_rebase_failure(env, repo, users, config):
|
def test_rebase_failure(env, repo, users, config):
|
||||||
""" It looks like gh.rebase() can fail in the final ref-setting after
|
""" It looks like gh.rebase() can fail in the final ref-setting after
|
||||||
the merging & commits creation has been performed. At this point, the
|
the merging & commits creation has been performed. At this point, the
|
||||||
|
Loading…
Reference in New Issue
Block a user