'Test state writes (or lack thereof) based on config values.'

def test_writes_with_config(self):

    CrawlersConfig.objects.create(known_user_agents='edX-downloader,crawler_foo', enabled=True)
    with patch('courseware.model_data.UserStateCache.set_many') as patched_state_client_set_many:
        self._load_courseware('crawler_foo')
        self.assertFalse(patched_state_client_set_many.called)
        self._load_courseware('edX-downloader/0.1')
        self.assertFalse(patched_state_client_set_many.called)
        self._load_courseware('Mozilla/5.0    AppleWebKit/537.36')
        self.assertTrue(patched_state_client_set_many.called)
    CrawlersConfig.objects.create(enabled=False)
    self.test_write_by_default()
