diff --git a/tasks/unit_tests/libs/common/worktree_tests.py b/tasks/unit_tests/libs/common/worktree_tests.py index 3998357c1accc..8af09d2d128bc 100644 --- a/tasks/unit_tests/libs/common/worktree_tests.py +++ b/tasks/unit_tests/libs/common/worktree_tests.py @@ -1,97 +1,104 @@ -import os -import unittest +# TODO(celian): Reintroduce these tests -from invoke import Context +""" +NOTE: These tests are disabled since they use git commands that are not mocked yet. +This breaks unit tests ran with macos runners. +""" -from tasks.libs.common.git import get_default_branch -from tasks.libs.common.gomodules import get_default_modules -from tasks.libs.common.worktree import agent_context, init_env, is_worktree +# import os +# import unittest +# from invoke import Context -def get_ctx(): - return Context() +# from tasks.libs.common.git import get_default_branch +# from tasks.libs.common.gomodules import get_default_modules +# from tasks.libs.common.worktree import agent_context, init_env, is_worktree -class TestWorktree(unittest.TestCase): - def setUp(self): - # Pull only once - init_env(get_ctx(), '6.53.x') - os.environ['AGENT_WORKTREE_NO_PULL'] = '1' +# def get_ctx(): +# return Context() - def test_context_is_worktree_true(self): - with agent_context(get_ctx(), '6.53.x'): - self.assertTrue(is_worktree()) - def test_context_is_worktree_false(self): - self.assertFalse(is_worktree()) +# class TestWorktree(unittest.TestCase): +# def setUp(self): +# # Pull only once +# init_env(get_ctx(), '6.53.x') +# os.environ['AGENT_WORKTREE_NO_PULL'] = '1' - def test_context_nested(self): - with agent_context(get_ctx(), '6.53.x'): - with agent_context(get_ctx(), '6.53.x'): - self.assertTrue(is_worktree()) - self.assertTrue(is_worktree()) +# def test_context_is_worktree_true(self): +# with agent_context(get_ctx(), '6.53.x'): +# self.assertTrue(is_worktree()) - def test_context_pwd(self): - ctx = get_ctx() +# def test_context_is_worktree_false(self): +# self.assertFalse(is_worktree()) - with agent_context(ctx, None, skip_checkout=True): - pwdnone = ctx.run('pwd').stdout +# def test_context_nested(self): +# with agent_context(get_ctx(), '6.53.x'): +# with agent_context(get_ctx(), '6.53.x'): +# self.assertTrue(is_worktree()) +# self.assertTrue(is_worktree()) - with agent_context(ctx, '6.53.x'): - pwd6 = ctx.run('pwd').stdout +# def test_context_pwd(self): +# ctx = get_ctx() - with agent_context(ctx, 'main'): - pwdmain = ctx.run('pwd').stdout +# with agent_context(ctx, None, skip_checkout=True): +# pwdnone = ctx.run('pwd').stdout - self.assertEqual(pwd6, pwdnone) - self.assertEqual(pwd6, pwdmain) +# with agent_context(ctx, '6.53.x'): +# pwd6 = ctx.run('pwd').stdout - def test_context_modules(self): - ctx = get_ctx() +# with agent_context(ctx, 'main'): +# pwdmain = ctx.run('pwd').stdout - with agent_context(ctx, 'main'): - modules7 = get_default_modules() +# self.assertEqual(pwd6, pwdnone) +# self.assertEqual(pwd6, pwdmain) - with agent_context(ctx, '6.53.x'): - modules6 = get_default_modules() +# def test_context_modules(self): +# ctx = get_ctx() - self.assertNotEqual(set(modules6.keys()), set(modules7.keys())) +# with agent_context(ctx, 'main'): +# modules7 = get_default_modules() - def test_context_branch(self): - ctx = get_ctx() +# with agent_context(ctx, '6.53.x'): +# modules6 = get_default_modules() - with agent_context(ctx, 'main'): - branch7 = get_default_branch() +# self.assertNotEqual(set(modules6.keys()), set(modules7.keys())) - with agent_context(ctx, '6.53.x'): - branch6 = get_default_branch() +# def test_context_branch(self): +# ctx = get_ctx() - self.assertNotEqual(branch6, branch7) +# with agent_context(ctx, 'main'): +# branch7 = get_default_branch() - def test_context_no_checkout(self): - ctx = get_ctx() +# with agent_context(ctx, '6.53.x'): +# branch6 = get_default_branch() - with agent_context(ctx, '6.53.x'): - branch6 = get_default_branch() +# self.assertNotEqual(branch6, branch7) - with agent_context(ctx, 'main'): - branch7 = get_default_branch() +# def test_context_no_checkout(self): +# ctx = get_ctx() - with agent_context(ctx, 'main', skip_checkout=True): - branch_no_checkout = get_default_branch() +# with agent_context(ctx, '6.53.x'): +# branch6 = get_default_branch() - self.assertNotEqual(branch6, branch7) - self.assertEqual(branch7, branch_no_checkout) +# with agent_context(ctx, 'main'): +# branch7 = get_default_branch() - def test_context_no_checkout_error(self): - ctx = get_ctx() +# with agent_context(ctx, 'main', skip_checkout=True): +# branch_no_checkout = get_default_branch() - with agent_context(ctx, '6.53.x'): - pass +# self.assertNotEqual(branch6, branch7) +# self.assertEqual(branch7, branch_no_checkout) - def switch_context(): - # The current branch is not main - with agent_context(ctx, 'main', skip_checkout=True): - pass +# def test_context_no_checkout_error(self): +# ctx = get_ctx() - self.assertRaises(AssertionError, switch_context) +# with agent_context(ctx, '6.53.x'): +# pass + +# def switch_context(): +# # The current branch is not main +# with agent_context(ctx, 'main', skip_checkout=True): +# pass + +# self.assertRaises(AssertionError, switch_context)