Page MenuHomePhabricator
Paste P7936

(An Untitled Masterwork)

Authored by Halfak on Dec 20 2018, 4:54 PM.
[10:05:59] <halfak> o/ Amir1
[10:06:06] <halfak> Added some notes to
[10:06:08] <Amir1> hey
[10:06:14] <Amir1> Already answered all
[10:06:31] <halfak> I think we should pull redis-service out of the unit tests. You should be able to construct the Redis score_cache with a mock Redis connection.
[10:07:02] <Amir1> That's a lot of work
[10:07:08] <Amir1> for little gain
[10:07:15] <halfak> Is it? It seems like mocking two function calls is pretty straightforward
[10:07:19] <halfak> It's standard practice for a reason.
[10:07:30] <halfak> Two function calls: get/set
[10:08:20] <halfak>
[10:08:31] <halfak>
[10:08:33] <halfak> *setex
[10:08:33] * travis-ci ( has joined
[10:08:34] <travis-ci> wikimedia/ores#1228 (celery_tests - 03208cd : Amir Sarabadani): The build has errored.
[10:08:34] * travis-ci ( has left
[10:09:18] <Amir1> the thing is in any case that redis is not available you can just skip all redis by running pytest -m "not redis"
[10:13:19] <Amir1> + how you are going to mock redis in celery tests? I'm writing tests for that too
[10:20:44] <halfak> In all cases, redis just needs get and setex mocked. They are simple key-value set and get patterns so it should be really easy.
[10:21:27] <halfak> I'd say that redis is possibly the easiest thing to mock that I have ever come across.
[10:21:30] <halfak> :P
[10:21:45] * basile is now known as guillom
[10:23:37] <Amir1> yes but how I'm going to inject the mock into celery app?
[10:23:52] <halfak> apps?
[10:24:12] <halfak> Oh I see what you mean. I think celery will need to be mocked.
[10:24:41] <halfak>
[10:24:49] <halfak> "To test task behavior in unit tests the preferred method is mocking."
[10:26:12] <halfak> I think you can just run celery in single thread mode too.
[10:26:47] <halfak> This seems relevant:

Event Timeline

Halfak created this paste.Dec 20 2018, 4:54 PM