示例#1
0
    def test_setMember_good(self):
        nc = NetworkController()
        data = {
            "id": "a",
            "name": "b",
            "address": "c",
            "city": "d",
            "state": "e",
            "zip": "f",
            "status": consts.STATUS_UNBANNED
        }

        nc.truncateMembers("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addMember("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        nc.setMember("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a", {"name": "c"})
        response = nc.getMember("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a")
        self.assertEqual(response.error, consts.NO_ERROR)
        self.assertEqual(
            response.payload, {
                "id": "a",
                "name": "c",
                "address": "c",
                "city": "d",
                "state": "e",
                "zip": "f",
                "status": consts.STATUS_UNBANNED
            })
示例#2
0
    def test_getMember_nonexistent(self):
        nc = NetworkController()
        data = {
            "id": "a",
            "name": "b",
            "address": "c",
            "city": "d",
            "state": "e",
            "zip": "f"
        }

        nc.truncateMembers("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addMember("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        response = nc.getMember("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "b")
        self.assertEqual(response.error, consts.ERROR_NONEXISTENT_ENTRY)
示例#3
0
    def test_getMember_unauthorized(self):
        nc = NetworkController()
        data = {
            "id": "a",
            "name": "b",
            "address": "c",
            "city": "d",
            "state": "e",
            "zip": "f"
        }

        nc.truncateMembers("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addMember("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        response = nc.getMember("asdf", "a")
        self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)
示例#4
0
    def test_removeMember_good(self):
        nc = NetworkController()

        nc.truncateMembers("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addMember(
            "AS62ELRB5F0709LERPHZD06JWC0P8QSC", {
                "id": "a",
                "name": "b",
                "address": "c",
                "city": "d",
                "state": "e",
                "zip": "f"
            })
        response = nc.removeMember("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a")
        self.assertEqual(response.error, consts.NO_ERROR)

        response = nc.getMember("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a")
        self.assertEqual(response.error, consts.ERROR_NONEXISTENT_ENTRY)