Exemplo n.º 1
0
    def test_setMember_duplicate(self):
        nc = NetworkController()

        nc.truncateMembers("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        nc.addMember(
            "AS62ELRB5F0709LERPHZD06JWC0P8QSC", {
                "id": "aaaa",
                "name": "b",
                "address": "c",
                "city": "d",
                "state": "e",
                "zip": "f",
                "status": consts.STATUS_UNBANNED
            })
        nc.addMember(
            "AS62ELRB5F0709LERPHZD06JWC0P8QSC", {
                "id": "bbbb",
                "name": "b",
                "address": "c",
                "city": "d",
                "state": "e",
                "zip": "f",
                "status": consts.STATUS_UNBANNED
            })
        response = nc.setMember("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "aaaa",
                                {"id": "bbbb"})
        self.assertEqual(response.error, consts.ERROR_DUPLICATE_ID)
Exemplo n.º 2
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
            })
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
    def test_removeMember_unauthorized(self):
        nc = NetworkController()

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

        response = nc.removeMember("asd", "a")
        self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)
Exemplo n.º 6
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)
Exemplo n.º 7
0
    def test_getAllMembers_lots(self):
        nc = NetworkController()

        nc.truncateMembers("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        for i in range(0, 9):
            nc.addMember(
                "AS62ELRB5F0709LERPHZD06JWC0P8QSC", {
                    "id": str(i),
                    "name": "b",
                    "address": "c",
                    "city": "d",
                    "state": "e",
                    "zip": "f",
                    "status": consts.STATUS_UNBANNED
                })

        response = nc.getAllMembers("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        print(response.serialize())
Exemplo n.º 8
0
    def test_addMember_incomplete(self):
        nc = NetworkController()
        data = {
            "id": "a",
            "name": "b",
            "address": "c",
            "city": "d",
            "state": "e"
        }

        nc.truncateMembers("AS62ELRB5F0709LERPHZD06JWC0P8QSC")
        response = nc.addMember("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data)
        self.assertEqual(response.error,
                         consts.ERROR_FAILED_DATABASE_ADD_INCOMPLETE_DATA)