Mocking and testing the same data object between python and node

128
May 24, 2019, at 00:40 AM

TL;DR:

How to mock (for ut) the same object in python and node without code duplication

Explanation:

In my project architecture we have two servers, one is written in python and the other in node (I'm not familiar with the node server).

They both dealing with the same logic object, for the example we will use "Map" object. On the python side we a have objects which describe the "Map" object, like Map, Place, Point and so on.

We perform the communication between the servers in json that describe the map object, so out python Map object has ".to_json" and ".create_from_json" functions.

The node server is what the user actually using, lets say the user can create "surprising map" which is something we know in our terminology (for our exmaple, that a map with 5 places which one of them is on a mountain), Means that the node has the code which create "surprising map" (not for testing).

When the python side write unit-testing, we should mock a "surprising map", At the moment we have some helper classes which create some mock maps, one of them is "surprising map". There is no guarantee that our mocking code and the node code working in the same way - that is the problem.

The solution we have came to is: writing node server which implement the mocking logic for the "Map" object and will return jsons, so there will be an api for "create map", "add place" and maybe "create surprising map" - both servers will use this for unit-testing.

That will make us to start a node server for all the unit-testing which sound a overhead.

I'll be glad for any suggestions about how to solve the code duplication for both python and node unit-testing with the minimum overhead.

Thank you!

READ ALSO
ws websocket will not send data to server

ws websocket will not send data to server

I need the websocket to send a request after it has been openedCurrently the websocket is successfully being opened but won't send that request afterwards

91
How to set schema with node-postgres

How to set schema with node-postgres

I'm trying to query against a schema called DOCUMENT in my postgres db using node-postgres

121
What takes place where in reactjs build system?

What takes place where in reactjs build system?

You type create-react-app and hit enter and voila! Some magic happens and everything gets set up in a flashBut during the rest of the development process you suffer from lack of knowledge of what really happens behind the scene

110
Setting express-handlebars default layout to false or custom one for a template is not working

Setting express-handlebars default layout to false or custom one for a template is not working

I am working on a node server with express and I did set a default layout for all pages and it works fine, however, when I try to avoid the layout in some pages, it still gets used, my code is bellow maybe someone can help me

108