~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Vincent Ladeuil
  • Date: 2016-02-01 18:09:18 UTC
  • mfrom: (6614.1.3 assert)
  • mto: This revision was merged to the branch mainline in revision 6615.
  • Revision ID: v.ladeuil+lp@free.fr-20160201180918-jqtq8ol6gdbbbtpv
Fix deprecated assertions to unblock release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012 Canonical Ltd
 
1
# Copyright (C) 2006-2012, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
944
944
        self.assertEqual(
945
945
            smart_req.SmartServerResponse(('ok', )),
946
946
            request.do_body('foo bar baz'))
947
 
        self.assertEquals(
 
947
        self.assertEqual(
948
948
            branch.control_transport.get_bytes('branch.conf'),
949
949
            'foo bar baz')
950
950
        branch.unlock()
1033
1033
        response = request.do_chunk(tag_bytes)
1034
1034
        self.assertEqual(None, response)
1035
1035
        response = request.do_end()
1036
 
        self.assertEquals(
 
1036
        self.assertEqual(
1037
1037
            smart_req.SuccessfulSmartServerResponse(()), response)
1038
1038
        base_branch.unlock()
1039
1039
 
1295
1295
        base_branch = self.make_branch('base')
1296
1296
        request = smart_branch.SmartServerBranchGetParent(self.get_transport())
1297
1297
        response = request.execute('base')
1298
 
        self.assertEquals(
 
1298
        self.assertEqual(
1299
1299
            smart_req.SuccessfulSmartServerResponse(('',)), response)
1300
1300
 
1301
1301
    def test_get_parent_something(self):
1303
1303
        base_branch.set_parent(self.get_url('foo'))
1304
1304
        request = smart_branch.SmartServerBranchGetParent(self.get_transport())
1305
1305
        response = request.execute('base')
1306
 
        self.assertEquals(
 
1306
        self.assertEqual(
1307
1307
            smart_req.SuccessfulSmartServerResponse(("../foo",)),
1308
1308
            response)
1309
1309
 
1352
1352
        request = smart_branch.SmartServerBranchGetTagsBytes(
1353
1353
            self.get_transport())
1354
1354
        response = request.execute('base')
1355
 
        self.assertEquals(
 
1355
        self.assertEqual(
1356
1356
            smart_req.SuccessfulSmartServerResponse(('',)), response)
1357
1357
 
1358
1358
 
1366
1366
        request = smart_branch.SmartServerBranchRequestGetStackedOnURL(
1367
1367
            self.get_transport())
1368
1368
        response = request.execute('stacked')
1369
 
        self.assertEquals(
 
1369
        self.assertEqual(
1370
1370
            smart_req.SmartServerResponse(('ok', '../base')),
1371
1371
            response)
1372
1372
 
1484
1484
            backing)
1485
1485
        branch = self.make_branch('.')
1486
1486
        branch_token, repo_token = self.get_lock_tokens(branch)
1487
 
        self.assertEquals(True, branch.get_physical_lock_status())
 
1487
        self.assertEqual(True, branch.get_physical_lock_status())
1488
1488
        response = request.execute('')
1489
1489
        self.assertEqual(
1490
1490
            smart_req.SmartServerResponse(('yes',)), response)
1495
1495
        request = smart_branch.SmartServerBranchRequestGetPhysicalLockStatus(
1496
1496
            backing)
1497
1497
        branch = self.make_branch('.')
1498
 
        self.assertEquals(False, branch.get_physical_lock_status())
 
1498
        self.assertEqual(False, branch.get_physical_lock_status())
1499
1499
        response = request.execute('')
1500
1500
        self.assertEqual(
1501
1501
            smart_req.SmartServerResponse(('no',)), response)
1601
1601
        backing = self.get_transport()
1602
1602
        request = smart_repo.SmartServerRepositoryAllRevisionIds(backing)
1603
1603
        self.make_repository('.')
1604
 
        self.assertEquals(
 
1604
        self.assertEqual(
1605
1605
            smart_req.SuccessfulSmartServerResponse(("ok", ), ""),
1606
1606
            request.execute(''))
1607
1607
 
1615
1615
        tree.commit(rev_id='origineel', message="message")
1616
1616
        tree.commit(rev_id='nog-een-revisie', message="message")
1617
1617
        tree.unlock()
1618
 
        self.assertEquals(
 
1618
        self.assertEqual(
1619
1619
            smart_req.SuccessfulSmartServerResponse(("ok", ),
1620
1620
                "origineel\nnog-een-revisie"),
1621
1621
            request.execute(''))
1783
1783
        response = request.do_body("rev1\nrev2")
1784
1784
        self.assertTrue(response.is_successful())
1785
1785
        # Format 2a uses serializer format 10
1786
 
        self.assertEquals(response.args, ("ok", "10"))
 
1786
        self.assertEqual(response.args, ("ok", "10"))
1787
1787
 
1788
1788
        self.addCleanup(tree.branch.lock_read().unlock)
1789
1789
        entries = [zlib.compress(record.get_bytes_as("fulltext")) for record in
1804
1804
        response = request.do_body("rev1\nrev2")
1805
1805
        self.assertTrue(response.is_successful())
1806
1806
        # Format 2a uses serializer format 10
1807
 
        self.assertEquals(response.args, ("ok", "10"))
 
1807
        self.assertEqual(response.args, ("ok", "10"))
1808
1808
 
1809
1809
        contents = "".join(response.body_stream)
1810
 
        self.assertEquals(contents, "")
 
1810
        self.assertEqual(contents, "")
1811
1811
 
1812
1812
 
1813
1813
class GetStreamTestBase(tests.TestCaseWithMemoryTransport):
1902
1902
        self.assertIs(None, request.execute(''))
1903
1903
        response = request.do_body("thefileid\0somerev\n")
1904
1904
        self.assertTrue(response.is_successful())
1905
 
        self.assertEquals(response.args, ("ok", ))
1906
 
        self.assertEquals("".join(response.body_stream),
 
1905
        self.assertEqual(response.args, ("ok", ))
 
1906
        self.assertEqual("".join(response.body_stream),
1907
1907
            "ok\x000\n" + zlib.compress("somecontents"))
1908
1908
 
1909
1909
    def test_missing(self):
1914
1914
        self.assertIs(None, request.execute(''))
1915
1915
        response = request.do_body("thefileid\0revision\n")
1916
1916
        self.assertTrue(response.is_successful())
1917
 
        self.assertEquals(response.args, ("ok", ))
1918
 
        self.assertEquals("".join(response.body_stream),
 
1917
        self.assertEqual(response.args, ("ok", ))
 
1918
        self.assertEqual("".join(response.body_stream),
1919
1919
            "absent\x00thefileid\x00revision\x000\n")
1920
1920
 
1921
1921
 
2238
2238
    def test_without_write_lock(self):
2239
2239
        backing = self.get_transport()
2240
2240
        repo = self.make_repository('.')
2241
 
        self.assertEquals(False, repo.get_physical_lock_status())
 
2241
        self.assertEqual(False, repo.get_physical_lock_status())
2242
2242
        request_class = smart_repo.SmartServerRepositoryGetPhysicalLockStatus
2243
2243
        request = request_class(backing)
2244
2244
        self.assertEqual(smart_req.SuccessfulSmartServerResponse(('no',)),
2611
2611
            None)
2612
2612
        self.server._sockname = ('example.com', 42)
2613
2613
        self.server.run_server_started_hooks()
2614
 
        self.assertEquals(started_calls,
 
2614
        self.assertEqual(started_calls,
2615
2615
            [([self.get_transport().base], 'bzr://example.com:42/')])
2616
 
        self.assertEquals(started_ex_calls,
 
2616
        self.assertEqual(started_ex_calls,
2617
2617
            [([self.get_transport().base], self.server)])
2618
2618
 
2619
2619
    def test_run_server_started_hooks_ipv6(self):
2624
2624
            lambda backing_urls, url: started_calls.append((backing_urls, url)),
2625
2625
            None)
2626
2626
        self.server.run_server_started_hooks()
2627
 
        self.assertEquals(started_calls,
 
2627
        self.assertEqual(started_calls,
2628
2628
                [([self.get_transport().base], 'bzr://:::42/')])
2629
2629
 
2630
2630
    def test_run_server_stopped_hooks(self):
2635
2635
            lambda backing_urls, url: stopped_calls.append((backing_urls, url)),
2636
2636
            None)
2637
2637
        self.server.run_server_stopped_hooks()
2638
 
        self.assertEquals(stopped_calls,
 
2638
        self.assertEqual(stopped_calls,
2639
2639
            [([self.get_transport().base], 'bzr://example.com:42/')])
2640
2640
 
2641
2641
 
2674
2674
        self.assertIs(None, request.execute('', 'unordered'))
2675
2675
        response = request.do_body("somerev\n")
2676
2676
        self.assertTrue(response.is_successful())
2677
 
        self.assertEquals(response.args, ("ok", ))
 
2677
        self.assertEqual(response.args, ("ok", ))
2678
2678
        stream = [('inventory-deltas', [
2679
2679
            versionedfile.FulltextContentFactory('somerev', None, None,
2680
2680
                self._get_serialized_inventory_delta(
2681
2681
                    t.branch.repository, 'null:', 'somerev'))])]
2682
2682
        fmt = controldir.format_registry.get('2a')().repository_format
2683
 
        self.assertEquals(
 
2683
        self.assertEqual(
2684
2684
            "".join(response.body_stream),
2685
2685
            "".join(smart_repo._stream_to_byte_stream(stream, fmt)))
2686
2686
 
2695
2695
        self.assertIs(None, request.execute('', 'unordered'))
2696
2696
        response = request.do_body("")
2697
2697
        self.assertTrue(response.is_successful())
2698
 
        self.assertEquals(response.args, ("ok", ))
2699
 
        self.assertEquals("".join(response.body_stream),
 
2698
        self.assertEqual(response.args, ("ok", ))
 
2699
        self.assertEqual("".join(response.body_stream),
2700
2700
            "Bazaar pack format 1 (introduced in 0.18)\nB54\n\nBazaar repository format 2a (needs bzr 1.16 or later)\nE")