コード例 #1
0
ファイル: tests.py プロジェクト: pdxwebdev/yadapy
    def forceJoinFriends(self):
        serverObject = YadaServer({}, {"name" : "yada server"})
        
        data = Node({}, { 'name' : 'node 1'})
        
        host = str(uuid4()).replace('-','') + '.com'
        indexer = Node({}, {"name" : host})

        serverObject.add('data/managed_nodes', [data.get(), indexer.get()], True)
        
        self.assertTrue(indexer.matchFriend(data)==None)
        
        serverObject.forceJoinNodes(data, indexer)
        
        self.assertTrue(len(indexer.matchFriend(data))>0)
コード例 #2
0
    def forceJoinFriends(self):
        serverObject = YadaServer({}, {"name": "yada server"})

        data = Node({}, {'name': 'node 1'})

        host = str(uuid4()).replace('-', '') + '.com'
        indexer = Node({}, {"name": host})

        serverObject.add('data/managed_nodes',
                         [data.get(), indexer.get()], True)

        self.assertTrue(indexer.matchFriend(data) == None)

        serverObject.forceJoinNodes(data, indexer)

        self.assertTrue(len(indexer.matchFriend(data)) > 0)
コード例 #3
0
    def Indexer_managedFriendRequest(self):

        #setup the server
        serverObject = YadaServer({}, {"name": "yada server"})

        #setup the nodes
        data = Node({}, {'name': 'node 1'})
        friend = Node({}, {'name': 'node 2'})

        #setup the indexer
        host = str(uuid4()).replace('-', '') + '.com'
        indexer = Node({}, {"name": host})

        #make the nodes and indexer hosted on server
        serverObject.add(
            'data/managed_nodes',
            [data.get(), friend.get(), indexer.get()], True)

        #for the sake of the test, just force approved friendships on the nodes and indexer with the server
        serverObject.forceJoinNodes(data, serverObject)
        serverObject.forceJoinNodes(friend, serverObject)
        serverObject.forceJoinNodes(indexer, serverObject)

        #also force joining the nodes to the indexer so they will be able to route and retrieve friend requests
        newFriend = serverObject.forceJoinNodes(data, indexer)
        newFriend = serverObject.forceJoinNodes(friend, indexer)

        #test to see if any friend requests exists in the indexer already, this should fail
        self.assertEqual([], indexer.get('data/routed_friend_requests'))

        nc = NodeCommunicator(serverObject)
        #now we do the actual friend request where we route a request from data to indexer
        newFriend = nc.routeRequestThroughNode(indexer,
                                               newFriend['public_key'])
        #we now assert that the friend request was added successfully to the routed_friend_requests array of the indexer
        self.assertTrue(len(indexer.get('data/routed_friend_requests')) > 0)

        friendRequests = serverObject.getFriendRequestsFromIndexer(
            friend, indexer)
        self.assertEqual(friendRequests.keys(), {'friend_requests': ''}.keys())
        self.assertEqual(friendRequests['friend_requests'][0]['public_key'],
                         newFriend['public_key'])
コード例 #4
0
ファイル: tests.py プロジェクト: pdxwebdev/yadapy
    def Indexer_managedFriendRequest(self):
        
        #setup the server
        serverObject = YadaServer({}, {"name" : "yada server"})
        
        #setup the nodes
        data = Node({}, { 'name' : 'node 1'})
        friend = Node({}, { 'name' : 'node 2'})
        
        #setup the indexer
        host = str(uuid4()).replace('-','') + '.com'
        indexer = Node({}, {"name" : host})

        #make the nodes and indexer hosted on server
        serverObject.add('data/managed_nodes', [data.get(), friend.get(), indexer.get()], True)
        
        #for the sake of the test, just force approved friendships on the nodes and indexer with the server
        serverObject.forceJoinNodes(data, serverObject)
        serverObject.forceJoinNodes(friend, serverObject)
        serverObject.forceJoinNodes(indexer, serverObject)
        
        #also force joining the nodes to the indexer so they will be able to route and retrieve friend requests
        newFriend = serverObject.forceJoinNodes(data, indexer)
        newFriend = serverObject.forceJoinNodes(friend, indexer)
        
        #test to see if any friend requests exists in the indexer already, this should fail
        self.assertEqual([], indexer.get('data/routed_friend_requests'))
        
        nc = NodeCommunicator(serverObject)
        #now we do the actual friend request where we route a request from data to indexer
        newFriend = nc.routeRequestThroughNode(indexer, newFriend['public_key'])
        #we now assert that the friend request was added successfully to the routed_friend_requests array of the indexer
        self.assertTrue(len(indexer.get('data/routed_friend_requests')) > 0)
        
        friendRequests = serverObject.getFriendRequestsFromIndexer(friend, indexer)
        self.assertEqual(friendRequests.keys(),{'friend_requests' : ''}.keys())
        self.assertEqual(friendRequests['friend_requests'][0]['public_key'], newFriend['public_key'])