def test_getMenuItem_nonexistent(self): nc = NetworkController() data = {"id": "a", "name": "b", "fee": "100"} nc.truncateMenu("AS62ELRB5F0709LERPHZD06JWC0P8QSC") nc.addMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) response = nc.getMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "b") self.assertEqual(response.error, consts.ERROR_NONEXISTENT_ENTRY)
def test_getMenuItem_unauthorized(self): nc = NetworkController() data = {"id": "a", "name": "b", "fee": "100"} nc.truncateMenu("AS62ELRB5F0709LERPHZD06JWC0P8QSC") nc.addMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) response = nc.getMenuItem("asdf", "a") self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)
def test_addMenuItem_duplicate(self): nc = NetworkController() data = {"id": "a", "name": "b", "fee": "100"} nc.truncateMenu("AS62ELRB5F0709LERPHZD06JWC0P8QSC") nc.addMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) response = nc.addMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) self.assertEqual(response.error, consts.ERROR_DUPLICATE_ID)
def test_getMenuItem_good(self): nc = NetworkController() data = {"id": "a", "name": "b", "fee": "100"} nc.truncateMenu("AS62ELRB5F0709LERPHZD06JWC0P8QSC") nc.addMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) response = nc.getMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a") self.assertEqual(response.error, consts.NO_ERROR) self.assertEqual(response.payload, { "id": "a", "name": "b", "fee": "100" })
def test_removeMenuItem_unauthorized(self): nc = NetworkController() nc.truncateMenu("AS62ELRB5F0709LERPHZD06JWC0P8QSC") nc.addMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", { "id": "a", "name": "b", "fee": "100" }) response = nc.removeMenuItem("DDPR0TG8EF760QR2J7IUF3UFIRXXL4E3", "a") self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION) response = nc.removeMenuItem("asd", "a") self.assertEqual(response.error, consts.ERROR_UNAUTHORIZED_OPERATION)
def test_removeMenuItem_good(self): nc = NetworkController() nc.truncateMenu("AS62ELRB5F0709LERPHZD06JWC0P8QSC") nc.addMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", { "id": "a", "name": "b", "fee": "100" }) response = nc.removeMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a") self.assertEqual(response.error, consts.NO_ERROR) response = nc.getMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", "a") self.assertEqual(response.error, consts.ERROR_NONEXISTENT_ENTRY)
def test_addMenuItem_incomplete(self): nc = NetworkController() data = {"id": "a", "name": "b"} nc.truncateMenu("AS62ELRB5F0709LERPHZD06JWC0P8QSC") response = nc.addMenuItem("AS62ELRB5F0709LERPHZD06JWC0P8QSC", data) self.assertEqual(response.error, consts.ERROR_FAILED_DATABASE_ADD_INCOMPLETE_DATA)