mozilla-it / pocket-proxy-rs

Rust implementation of the Pocket sponsored content proxy
Mozilla Public License 2.0
2 stars 0 forks source link

Add factory function for mock Decision structs. #4

Closed smarnach closed 2 years ago

smarnach commented 2 years ago

This PR reimplements https://github.com/Pocket/proxy-server/blob/main/tests/fixtures/mock_decision.py in Rust.

The new mock_decision() function returns the same Decision structs that were decoded from the mock_decision.json file before. However, with the old approach it was completely opaque how the different JSON objects in the list differ, making it impossible to see what the different structs were actually testing. The new function makes the differences obvious, just like it was in the original code.

We should implement a similar function for mock_spoc.py, but I didn't get there yet.

This PR also fixes the failing test – I simply changed the floating-point numbers to strings, as this is what the Adzerk API returns. The original code support both strings and floating-point numbers, but I don't think we need to do that.