502
502
request.execute(''))
505
class SetLastRevisionTestBase(tests.TestCaseWithMemoryTransport):
505
class TestLockedBranch(tests.TestCaseWithMemoryTransport):
507
def get_lock_tokens(self, branch):
508
branch_token = branch.lock_write()
509
repo_token = branch.repository.lock_write()
510
branch.repository.unlock()
511
return branch_token, repo_token
514
class TestSmartServerBranchRequestSetConfigOption(TestLockedBranch):
516
def test_value_name(self):
517
branch = self.make_branch('.')
518
request = smart.branch.SmartServerBranchRequestSetConfigOption(
519
branch.bzrdir.root_transport)
520
branch_token, repo_token = self.get_lock_tokens(branch)
521
config = branch._get_config()
522
result = request.execute('', branch_token, repo_token, 'bar', 'foo',
524
self.assertEqual(SuccessfulSmartServerResponse(()), result)
525
self.assertEqual('bar', config.get_option('foo'))
527
def test_value_name_section(self):
528
branch = self.make_branch('.')
529
request = smart.branch.SmartServerBranchRequestSetConfigOption(
530
branch.bzrdir.root_transport)
531
branch_token, repo_token = self.get_lock_tokens(branch)
532
config = branch._get_config()
533
result = request.execute('', branch_token, repo_token, 'bar', 'foo',
535
self.assertEqual(SuccessfulSmartServerResponse(()), result)
536
self.assertEqual('bar', config.get_option('foo', 'gam'))
539
class SetLastRevisionTestBase(TestLockedBranch):
506
540
"""Base test case for verbs that implement set_last_revision."""
512
546
self.tree = self.make_branch_and_memory_tree('.')
514
548
def lock_branch(self):
516
branch_token = b.lock_write()
517
repo_token = b.repository.lock_write()
518
b.repository.unlock()
519
return branch_token, repo_token
549
return self.get_lock_tokens(self.tree.branch)
521
551
def unlock_branch(self):
522
552
self.tree.branch.unlock()
1377
1407
smart.request.request_handlers.get('Branch.revision_history'),
1378
1408
smart.branch.SmartServerRequestRevisionHistory)
1379
1409
self.assertEqual(
1410
smart.request.request_handlers.get('Branch.set_config_option'),
1411
smart.branch.SmartServerBranchRequestSetConfigOption)
1380
1413
smart.request.request_handlers.get('Branch.set_last_revision'),
1381
1414
smart.branch.SmartServerBranchRequestSetLastRevision)
1382
1415
self.assertEqual(