Exemplo n.º 1
0
    def test_get_user(self):
        self.assertEqual(self.kba.get_user(self.token1), self.user1)
        self.assertEqual(self.kba.get_user(self.token2), self.user2)

        # test getting from cache
        self.assertEqual(self.kba.get_user(self.token1), self.user1)
        self.assertEqual(self.kba.get_user(self.token2), self.user2)

        # test default url
        kba2 = KBaseAuth()
        self.assertEqual(kba2.get_user(self.token1), self.user1)
        self.assertEqual(kba2.get_user(self.token2), self.user2)
Exemplo n.º 2
0
    def test_get_user(self):
        self.assertEqual(self.kba.get_user(self.token1), self.user1)
        self.assertEqual(self.kba.get_user(self.token2), self.user2)

        # test getting from cache
        self.assertEqual(self.kba.get_user(self.token1), self.user1)
        self.assertEqual(self.kba.get_user(self.token2), self.user2)

        # test default url
        kba2 = KBaseAuth()
        self.assertEqual(kba2.get_user(self.token1), self.user1)
        self.assertEqual(kba2.get_user(self.token2), self.user2)
Exemplo n.º 3
0
 def setUpClass(cls):
     configfile = os.path.abspath(
         os.path.dirname(os.path.abspath(__file__)) + '/../test.cfg')
     print('Loading test config from ' + configfile)
     cfg = ConfigParser()
     cfg.read(configfile)
     authurl = cfg.get(cls.CFG_SEC, cls.AUTHURL)
     cls.token1 = cfg.get(cls.CFG_SEC, cls.TOKEN1)
     cls.token2 = cfg.get(cls.CFG_SEC, cls.TOKEN2)
     if not authurl:
         raise ValueError('Missing {} from test config'.format(cls.AUTHURL))
     if not cls.token1:
         raise ValueError('Missing {} from test config'.format(cls.TOKEN1))
     if not cls.token2:
         raise ValueError('Missing {} from test config'.format(cls.TOKEN2))
     cls.user1 = cls.get_user(authurl, cls.token1)
     cls.user2 = cls.get_user(authurl, cls.token2)
     if cls.user1 == cls.user2:
         raise ValueError('{} and {} users are the same: {}'.format(
             cls.TOKEN1, cls.TOKEN2, cls.user1))
     cls.kba = KBaseAuth(authurl)
Exemplo n.º 4
0
 def test_bad_url(self):
     kba2 = KBaseAuth('https://thisisasuperfakeurlihope.com')
     with self.assertRaises(ConnectionError) as context:
         kba2.get_user(self.token1)
     self.assertIn('not known', str(context.exception.message))
Exemplo n.º 5
0
 def test_bad_url(self):
     kba2 = KBaseAuth('https://thisisasuperfakeurlihope.com')
     with self.assertRaises(ConnectionError) as context:
         kba2.get_user(self.token1)
     self.assertIn('not known', str(context.exception.message))