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 })
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)
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)
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)