aurelg / feedspora

FeedSpora posts RSS/Atom feeds to your social network accounts.
35 stars 5 forks source link

Occasional test failures because of unpredictable client ordering #44

Closed aurelg closed 5 years ago

aurelg commented 5 years ago

While trying to setup CI with github/travis-ci, I noticed that the feed and post tests were occasionally failing. It comes from the order of clients, which is different between the expected and tested outputs. Clients are instantiated from a dict which loaded from the configuration file using PyYAML. Such a dict is not ordered (python<3.7).

A workaround would be to use this trick. However, the root cause of the issue comes from the test itself: it checks the standard output of feedspora instead of testing the code logic. It would be enough to check the output of each client independently (this would be required for #43 as well).

Proposed implementation: each client should be able to store entries, perhaps as list stored as an attribute. Once all clients/entries have been processed, feedspora_runner.py could check whether we were in testing mode, retrieve the list from all clients, and merge them in a JSON structure [{'client1_name': client1_list, 'client2_name': client2_list, ...} that can be later loaded. The comparison with the expected output stored in the golden file (in the same format) would have to take into account dict keys and values, instead of their string representations.

aurelg commented 5 years ago

Fixed w/commit f730897.

I had to significantly change the format of the golden files, but this shouldn't have any impact.