~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Patch Queue Manager
  • Date: 2012-02-02 12:39:18 UTC
  • mfrom: (6449.5.7 ,branch=pending)
  • Revision ID: pqm@pqm.ubuntu.com-20120202123918-18gyztydwlr8jys6
(jelmer) Use config stacks for 'mail_client' configuration option. (Jelmer
 Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1904
1904
            location='http://example.com/specific')
1905
1905
        self.assertEqual(my_config.get_user_option('option'), 'exact')
1906
1906
 
1907
 
    def test_get_mail_client(self):
1908
 
        config = self.get_branch_config()
1909
 
        client = config.get_mail_client()
1910
 
        self.assertIsInstance(client, mail_client.DefaultMail)
1911
 
 
1912
 
        # Specific clients
1913
 
        config.set_user_option('mail_client', 'evolution')
1914
 
        client = config.get_mail_client()
1915
 
        self.assertIsInstance(client, mail_client.Evolution)
1916
 
 
1917
 
        config.set_user_option('mail_client', 'kmail')
1918
 
        client = config.get_mail_client()
1919
 
        self.assertIsInstance(client, mail_client.KMail)
1920
 
 
1921
 
        config.set_user_option('mail_client', 'mutt')
1922
 
        client = config.get_mail_client()
1923
 
        self.assertIsInstance(client, mail_client.Mutt)
1924
 
 
1925
 
        config.set_user_option('mail_client', 'thunderbird')
1926
 
        client = config.get_mail_client()
1927
 
        self.assertIsInstance(client, mail_client.Thunderbird)
1928
 
 
1929
 
        # Generic options
1930
 
        config.set_user_option('mail_client', 'default')
1931
 
        client = config.get_mail_client()
1932
 
        self.assertIsInstance(client, mail_client.DefaultMail)
1933
 
 
1934
 
        config.set_user_option('mail_client', 'editor')
1935
 
        client = config.get_mail_client()
1936
 
        self.assertIsInstance(client, mail_client.Editor)
1937
 
 
1938
 
        config.set_user_option('mail_client', 'mapi')
1939
 
        client = config.get_mail_client()
1940
 
        self.assertIsInstance(client, mail_client.MAPIClient)
1941
 
 
1942
 
        config.set_user_option('mail_client', 'xdg-email')
1943
 
        client = config.get_mail_client()
1944
 
        self.assertIsInstance(client, mail_client.XDGEmail)
1945
 
 
1946
 
        config.set_user_option('mail_client', 'firebird')
1947
 
        self.assertRaises(errors.UnknownMailClient, config.get_mail_client)
1948
 
 
1949
1907
 
1950
1908
class TestMailAddressExtraction(tests.TestCase):
1951
1909
 
4889
4847
        self.overrideEnv('BZR_EMAIL', None)
4890
4848
        self.overrideEnv('EMAIL', 'jelmer@samba.org')
4891
4849
        self.assertEquals('jelmer@debian.org', conf.get('email'))
 
4850
 
 
4851
 
 
4852
class MailClientOptionTests(tests.TestCase):
 
4853
 
 
4854
    def test_default(self):
 
4855
        conf = config.MemoryStack('')
 
4856
        client = conf.get('mail_client')
 
4857
        self.assertIs(client, mail_client.DefaultMail)
 
4858
 
 
4859
    def test_evolution(self):
 
4860
        conf = config.MemoryStack('mail_client=evolution')
 
4861
        client = conf.get('mail_client')
 
4862
        self.assertIs(client, mail_client.Evolution)
 
4863
 
 
4864
    def test_kmail(self):
 
4865
        conf = config.MemoryStack('mail_client=kmail')
 
4866
        client = conf.get('mail_client')
 
4867
        self.assertIs(client, mail_client.KMail)
 
4868
 
 
4869
    def test_mutt(self):
 
4870
        conf = config.MemoryStack('mail_client=mutt')
 
4871
        client = conf.get('mail_client')
 
4872
        self.assertIs(client, mail_client.Mutt)
 
4873
 
 
4874
    def test_thunderbird(self):
 
4875
        conf = config.MemoryStack('mail_client=thunderbird')
 
4876
        client = conf.get('mail_client')
 
4877
        self.assertIs(client, mail_client.Thunderbird)
 
4878
 
 
4879
    def test_explicit_default(self):
 
4880
        conf = config.MemoryStack('mail_client=default')
 
4881
        client = conf.get('mail_client')
 
4882
        self.assertIs(client, mail_client.DefaultMail)
 
4883
 
 
4884
    def test_editor(self):
 
4885
        conf = config.MemoryStack('mail_client=editor')
 
4886
        client = conf.get('mail_client')
 
4887
        self.assertIs(client, mail_client.Editor)
 
4888
 
 
4889
    def test_mapi(self):
 
4890
        conf = config.MemoryStack('mail_client=mapi')
 
4891
        client = conf.get('mail_client')
 
4892
        self.assertIs(client, mail_client.MAPIClient)
 
4893
 
 
4894
    def test_xdg_email(self):
 
4895
        conf = config.MemoryStack('mail_client=xdg-email')
 
4896
        client = conf.get('mail_client')
 
4897
        self.assertIs(client, mail_client.XDGEmail)
 
4898
 
 
4899
    def test_unknown(self):
 
4900
        conf = config.MemoryStack('mail_client=firebird')
 
4901
        self.assertRaises(errors.ConfigOptionValueError, conf.get,
 
4902
                'mail_client')