Пример #1
0
    def test_login_logout(self):
        mss = HTTPMetawebSession(API_HOST, username=USERNAME, password=PASSWORD)
        mss.login()

        user_info = mss.user_info()
        self.assertNotEqual(None, user_info)
        self.assertEqual(user_info.code, "/api/status/ok")
        self.assertEqual(mss.loggedin(), True)

        mss.logout()
        self.assertRaises(MetawebError, mss.user_info)
        self.assertEqual(mss.loggedin(), False)
Пример #2
0
 def test_login_logout(self):
     mss = HTTPMetawebSession(API_HOST, username=USERNAME,
                              password=PASSWORD)
     mss.login()
     
     user_info = mss.user_info()
     self.assertNotEqual(None, user_info)
     self.assertEqual(user_info.code, "/api/status/ok")
     self.assertEqual(mss.loggedin(), True)
     
     mss.logout()
     self.assertRaises(MetawebError, mss.user_info)
     self.assertEqual(mss.loggedin(), False)
Пример #3
0
def login(api_host, username=None, password=None):
    
    s = HTTPMetawebSession(api_host)
    if not username:
        print "In order to perform this operation, we need to use a valid freebase username and password"
        username = raw_input("Please enter your username: "******"Please enter your password: "******"Please enter your password: "******"Thanks!"
    return s
Пример #4
0
    def test_write(self):
        read_query = {"type": "/music/artist", "name": "Yanni's Cousin Tom", "id": {}}
        mss = HTTPMetawebSession(API_HOST, username=USERNAME, password=PASSWORD)
        result = mss.mqlread(read_query)
        self.assertEqual(None, result)

        write_query = {"create": "unless_exists", "type": "/music/artist", "name": "Yanni"}

        mss.login()
        write_result = mss.mqlwrite(write_query)
        self.assertNotEqual(None, write_result)
        self.assert_(write_result.has_key("create"))
        self.assert_(write_result.has_key("type"))
        self.assert_(write_result.has_key("name"))
        self.assertEqual("existed", write_result["create"])
        self.assertEqual("Yanni", write_result["name"])
        self.assertEqual("/music/artist", write_result["type"])
Пример #5
0
 def test_write(self):
     read_query = {'type':'/music/artist','name':'Yanni\'s Cousin Tom', 'id':{}}
     mss = HTTPMetawebSession(API_HOST, username=USERNAME, password=PASSWORD)
     result = mss.mqlread(read_query)
     self.assertEqual(None, result)
     
     write_query = {'create':'unless_exists', 'type':'/music/artist','name':'Yanni'}
     
     mss.login()
     write_result = mss.mqlwrite(write_query)
     self.assertNotEqual(None, write_result)
     self.assert_(write_result.has_key('create'))
     self.assert_(write_result.has_key('type'))
     self.assert_(write_result.has_key('name'))
     self.assertEqual('existed', write_result['create'])
     self.assertEqual('Yanni', write_result['name'])
     self.assertEqual('/music/artist', write_result['type'])
Пример #6
0
import getlogindetails

from freebase.api import HTTPMetawebSession, MetawebError


USERNAME = "******"
PASSWORD = "******"
API_HOST = "http://sandbox-freebase.com"
TEST_QUERY = {"id": "null", "name": "Sting"}

s = HTTPMetawebSession(API_HOST)

if USERNAME == "username" and PASSWORD == "password":
    USERNAME, PASSWORD = getlogindetails.main()

s.login(USERNAME, PASSWORD)


class TestFreebase(unittest.TestCase):
    def test_freebase_dot_login_logout(self):
        freebase.login(username=USERNAME, password=PASSWORD)
        self.assertNotEqual(freebase.user_info(), None)
        self.assertEqual(freebase.loggedin(), True)
        freebase.logout()
        self.assertRaises(MetawebError, freebase.user_info)
        self.assertEqual(freebase.loggedin(), False)

    def test_login_logout(self):
        mss = HTTPMetawebSession(API_HOST, username=USERNAME, password=PASSWORD)
        mss.login()
Пример #7
0
import getlogindetails

from freebase.api import HTTPMetawebSession, MetawebError


USERNAME = '******'
PASSWORD = '******'
API_HOST = 'http://sandbox-freebase.com'
TEST_QUERY = {'id': 'null', 'name': 'Sting'}

s = HTTPMetawebSession(API_HOST)

if USERNAME == "username" and PASSWORD == "password":
    USERNAME, PASSWORD = getlogindetails.main()

s.login(USERNAME, PASSWORD)

class TestFreebase(unittest.TestCase):
    def test_freebase_dot_login_logout(self):
        freebase.login(username=USERNAME, password=PASSWORD)
        self.assertNotEqual(freebase.user_info(), None)
        self.assertEqual(freebase.loggedin(), True)
        freebase.logout()
        self.assertRaises(MetawebError, freebase.user_info)
        self.assertEqual(freebase.loggedin(), False)
    
    def test_login_logout(self):
        mss = HTTPMetawebSession(API_HOST, username=USERNAME,
                                 password=PASSWORD)
        mss.login()