~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ssh_transport.py

  • Committer: Dmitry Vasiliev
  • Date: 2007-03-02 14:10:15 UTC
  • mto: (2327.1.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 2328.
  • Revision ID: dima@hlabs.spb.ru-20070302141015-sjn7kthbdgylt3bp
Added comments for test_get_vendor_search_order

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
        manager.clear_cache()
94
94
        self.assertRaises(SSHVendorNotFound, manager.get_vendor, {})
95
95
 
96
 
    def test_vendor_getting_methods_precedence(self):
 
96
    def test_get_vendor_search_order(self):
 
97
        # The 'get_vendor' method search for SSH vendors as following:
 
98
        #
 
99
        #   1. Check previously cached value
 
100
        #   2. Check BZR_SSH environment variable
 
101
        #   3. Check the system for known SSH vendors
 
102
        #   4. Fall back to the default vendor if registered
 
103
        #
 
104
        # Let's now check the each check method in the reverse order
 
105
        # clearing the cache between each invocation:
 
106
 
97
107
        manager = TestSSHVendorManager()
 
108
        # At first no vendors are found
98
109
        self.assertRaises(SSHVendorNotFound, manager.get_vendor, {})
99
110
 
 
111
        # If the default vendor is registered it will be returned
100
112
        default_vendor = object()
101
113
        manager.register_default_vendor(default_vendor)
102
114
        self.assertIs(manager.get_vendor({}), default_vendor)
103
115
 
 
116
        # If the known vendor is found in the system it will be returned
104
117
        manager.clear_cache()
105
118
        manager.set_ssh_version_string("OpenSSH")
106
119
        self.assertIsInstance(manager.get_vendor({}), OpenSSHSubprocessVendor)
107
120
 
 
121
        # If the BZR_SSH environment variable is found it will be treated as
 
122
        # the vendor name
108
123
        manager.clear_cache()
109
124
        vendor = object()
110
125
        manager.register_vendor("vendor", vendor)
111
126
        self.assertIs(manager.get_vendor({"BZR_SSH": "vendor"}), vendor)
112
127
 
 
128
        # Last cached value always checked first
113
129
        self.assertIs(manager.get_vendor({}), vendor)
114
130
 
115
131