def test_getService_unauthorized(self): nc = NetworkController() data = { "id": "a", "code": "b", "provider": "c", "member": "d", "comment": "e", "status": "f", "date": "g" } nc.truncateServices("AS62ELRB5F0709LERPHZD06JWC0P8QSC") nc.addService("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) response = nc.getService("asdf", "a") self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)
def test_addService_duplicate(self): nc = NetworkController() data = { "id": "a", "code": "b", "provider": "c", "member": "d", "comment": "e", "status": "f", "date": "g" } nc.truncateServices("AS62ELRB5F0709LERPHZD06JWC0P8QSC") nc.addService("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) response = nc.addService("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) self.assertEqual(response.error, consts.ERROR_DUPLICATE_ID)
def test_addService_good(self): nc = NetworkController() data = { "id": "a", "code": "b", "provider": "c", "member": "d", "comment": "e", "status": "f", "date": "g" } nc.truncateServices("AS62ELRB5F0709LERPHZD06JWC0P8QSC") response = nc.addService("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) self.assertEqual(response.error, consts.NO_ERROR) response = nc.getAllServices("AS62ELRB5F0709LERPHZD06JWC0P8QSC") self.assertEqual(response.error, consts.NO_ERROR) self.assertEqual(len(response.payload), 1) response.payload[0].pop( "received") # no way to know what this ought to be self.assertEqual( response.payload[0], { "id": "a", "code": "b", "provider": "c", "member": "d", "comment": "e", "status": "f", "date": "g" })
def test_removeService_unauthorized(self): nc = NetworkController() nc.truncateServices("AS62ELRB5F0709LERPHZD06JWC0P8QSC") nc.addService( "AS62ELRB5F0709LERPHZD06JWC0P8QSC", { "id": "a", "code": "b", "provider": "c", "member": "d", "comment": "e", "status": "f", "date": "g" }) response = nc.removeService("DDPR0TG8EF760QR2J7IUF3UFIRXXL4E3", "a") self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION) response = nc.removeService("asd", "a") self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)
def test_removeService_good(self): nc = NetworkController() nc.truncateServices("AS62ELRB5F0709LERPHZD06JWC0P8QSC") nc.addService( "AS62ELRB5F0709LERPHZD06JWC0P8QSC", { "id": "a", "code": "b", "provider": "c", "member": "d", "comment": "e", "status": "f", "date": "g" }) response = nc.removeService("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a") self.assertEqual(response.error, consts.NO_ERROR) response = nc.getService("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a") self.assertEqual(response.error, consts.ERROR_NONEXISTENT_ENTRY)
def test_addService_incomplete(self): nc = NetworkController() data = { "id": "a", "code": "b", "provider": "c", "member": "d", "comment": "e", "status": "f" } nc.truncateServices("AS62ELRB5F0709LERPHZD06JWC0P8QSC") response = nc.addService("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) self.assertEqual(response.error, consts.ERROR_FAILED_DATABASE_ADD_INCOMPLETE_DATA)