Ejemplo n.º 1
0
 def test_database_insert_and_query(self):
     conn = Couch("test")
     test_doc = {"abc": "def"}
     conn.insert(test_doc)
     selector = {"abc": "def"}
     res = conn.query(selector)
     conn.close()
     for item in res:
         self.assertEqual(item['abc'], 'def')
Ejemplo n.º 2
0
 def test_database_insert_and_partial_query(self):
     conn = Couch("test")
     test_doc = {"adsf": {"bbb": "fdsa", "aand": "ssss"}}
     conn.insert(test_doc)
     selector = {"asdf": {"bbb": "fdsa"}}
     res = conn.query(selector)
     conn.close()
     for item in res:
         self.assertEqual(item, test_doc)
Ejemplo n.º 3
0
def login_account():
    data = json.loads(request.get_data().decode('utf-8'))
    platform = data['platform']
    username = data['username']
    password = decrypt(data['password'])
    res = False
    instance = None
    if len(username) == 0 and len(password) == 0:
        return make_response({'result': res})
    if platform == 'Instagram':
        instance = InsUtilsWithLogin(displayed=False)
    elif platform == 'Twitter':
        instance = TwiUtilsWithLogin(displayed=False)
    if instance is None:
        return make_response({'result': False})
    instance.set_account((username, password))
    res = instance.login()
    if res:
        database = Couch(DATABASE_CREDENTIAL)
        database.insert(data)
        database.close()

    return make_response({'result': res})