コード例 #1
0
ファイル: clan.py プロジェクト: hyakugei/netwrok-server
def test_create_join():
    idA, handle, A = yield from core.client()
    idB, handle, B = yield from core.client()
    clan = core.rndstr()
    yield from core.send(A, "clan.create", clan, "Test")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.create"
    assert rs["args"][0] == True
    clan_id = rs["args"][1]
    yield from core.send(B, "clan.join", clan_id)
    rs = yield from core.recv(B)
    assert rs["name"] == "clan.join"
    assert rs["args"][0] == True
    yield from core.send(A, "clan.members")
    rs = yield from core.recv(A)
    members = {i[0]:i for i in rs["args"][0]["members"]}
    assert idB in members
    assert members[idB][2] == "Pending"
    assert members[idB][3] == False
    yield from core.send(A, "clan.setmembertype", idB, "Member")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.setmembertype"
    assert rs["args"][0] == idB
    assert rs["args"][1] == "Member"
    assert rs["args"][2] == True
    yield from core.send(B, "clan.members")
    rs = yield from core.recv(B)
    members = {i[0]:i for i in rs["args"][0]["members"]}
    assert idB in members
    assert members[idB][2] == "Member", members
コード例 #2
0
ファイル: array.py プロジェクト: steder/maroonmpi
def recv( source, tag, communicator ):
    datatype = core.recv( 1, core.MPI_INT, source, tag, communicator )
    rank = core.recv( 1, core.MPI_INT, source, tag+1, communicator )
    shape = core.recv( rank, core.MPI_INT, source, tag+2, communicator )
    size = core.recv( 1, core.MPI_INT, source, tag+3, communicator )
    data = core.recv( size, datatype, source, tag+4, communicator )
    array = nm.asarray(data)
    array.shape = shape
    return array
コード例 #3
0
ファイル: clan.py プロジェクト: hyakugei/netwrok-server
def test_list():
    id, handle, A = yield from core.client()
    clan = core.rndstr()
    yield from core.send(A, "clan.create", clan, "Test")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.create"
    assert rs["args"][0] == True
    yield from core.send(A, "clan.list")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.list"
    assert type(rs["args"][0]) == type([])
コード例 #4
0
ファイル: auth.py プロジェクト: hyakugei/netwrok-server
def test_authenticate_falure():
    ws = yield from core.conn()
    assert ws is not None
    obj = yield from core.recv(ws)
    handle = core.rndstr()
    email = core.rndstr()
    passwd = core.rndstr()
    yield from core.send(ws, "auth.register", handle, email, passwd)
    msg = yield from core.recv(ws)
    yield from core.send(ws, "auth.authenticate", email, passwd)
    msg = yield from core.recv(ws)
    assert msg["name"] == "auth.authenticate"
    assert msg["args"][0] == False
コード例 #5
0
ファイル: auth.py プロジェクト: hyakugei/netwrok-server
def test_authenticate_success():
    ws = yield from core.conn()
    assert ws is not None
    msg = yield from core.recv(ws)
    uid = msg["args"][0]

    handle = core.rndstr()
    email = core.rndstr()
    passwd = hashlib.sha256(core.rndstr().encode("utf8")).hexdigest()

    yield from core.send(ws, "auth.register", handle, email, passwd)
    msg = yield from core.recv(ws)
    digest = hashlib.sha256((uid+passwd).encode("utf8")).hexdigest()
    yield from core.send(ws, "auth.authenticate", email, digest)
    msg = yield from core.recv(ws)
    assert msg["name"] == "auth.authenticate"
    assert msg["args"][0] == True
コード例 #6
0
ファイル: auth.py プロジェクト: hyakugei/netwrok-server
def test_register():
    ws = yield from core.conn()
    assert ws is not None
    obj = yield from core.recv(ws)
    assert obj["name"] == "welcome"
    assert obj["args"][0] is not None
    handle = core.rndstr()
    email = core.rndstr()
    passwd = core.rndstr()
    yield from core.send(ws, "auth.register", handle, email, passwd)
    msg = yield from core.recv(ws)
    assert msg["name"] == "auth.register"
    assert msg["args"][0] == True
    yield from core.send(ws, "auth.register", handle, email, passwd)
    msg = yield from core.recv(ws)
    assert msg["name"] == "auth.register"
    assert msg["args"][0] == False
コード例 #7
0
ファイル: pythonic.py プロジェクト: steder/maroonmpi
def recv( source=ANY_SOURCE, tag=ANY_TAG, comm=core.MPI_COMM_WORLD ):
    """
    message = comm.recv( [destination(defaults to ANY_SOURCE), tag(defaults to ANY_TAG)])
    
    Receives a message from any source and tag by default, or from specified source
    and tag.
    """
    messageType = int(core.recv( 1, core.MPI_INT, source, tag, comm ))
    if messageType == SINGLE: #single elements (integers, characters)
        print "Single Element Case:"
        dataType = int(core.recv( 1, core.MPI_INT, source, tag+1, comm ))
        returnvalue = core.recv( message, 1, dataType, source, tag+2, comm )
        returnvalue = formatReturnValue( returnvalue, "single" )
    elif messageType == SEQUENCE: #non-array sequences
        print "Sequence Case:"
        dataType = int(core.recv( 1, core.MPI_INT, source, tag+1, comm ))
        length = int(core.recv( 1, core.MPI_INT, source,tag+2, comm))
        returnvalue = core.recv( length, dataType, source, tag+3, comm )
        returnvalue = formatReturnValue( returnvalue, "sequence" )
    elif messageType == ARRAY: #Array Case
        print "Array Case:"
        returnvalue = array.recv(message, source, tag+1, comm )
    else: #object case
        print "Generic Object Case:"
        returnvalue = sobj.recv( message, destinaion, tag+1, comm )# (2) are the same
    return returnvalue
コード例 #8
0
ファイル: pympi.py プロジェクト: steder/maroonmpi
    def recv(self, source=ANY_SOURCE, tag=ANY_TAG):
        """
        message = comm.recv( [destination(defaults to ANY_SOURCE), tag(defaults to ANY_TAG)])

        Receives a message from any source and tag by default, or from specified source
        and tag.

        This method receives messages as arrays of characters.
        This method trades efficency for generality: i.e. It takes extra time and bandwidth
        to serialize and transmit the serialized object.  However, any Python object
        that can be Pickled can be received.

        Currently this method uses the python pickle module(rather then cPickle).
        """
        core.probe(source, tag, WORLD)
        count = core.get_count(core.MPI_CHAR)
        data = core.recv(count, core.MPI_CHAR, source, tag, self.id)
        message = pickle.loads(data)
        return message
コード例 #9
0
ファイル: auth.py プロジェクト: hyakugei/netwrok-server
def test_welcome():
    ws = yield from core.conn()
    assert ws is not None
    obj = yield from core.recv(ws)
    assert obj["name"] == "welcome"