def test(self): factory = UserFactory() factory.graph_api_class = mock.Mock() factory.graph_api_class.return_value.get.return_value = {'id': '123'} user = factory.get_user("123") self.assertEqual(123, user.user_id) factory = UserFactory() factory.graph_api_class = mock.Mock() factory.graph_api_class.return_value.get.side_effect = [ FacebookError("msg", 1), FacebookError("msg", 1), {'id': '123'}] user = factory.get_user("123") self.assertEqual(123, user.user_id) factory = UserFactory() factory.graph_api_class = mock.Mock() factory.graph_api_class.return_value.get.side_effect = [ FacebookError("msg", 1), FacebookError("msg", 1), FacebookError("msg", 1), {'id': '123'}] self.assertEqual(None, factory.get_user("123"))
def test_failure(self, get_graph): factory = UserFactory() get_graph.return_value.get.side_effect = [ FacebookError("msg", 1), FacebookError("msg", 1), FacebookError("msg", 1), {'id': '123'}] with self.assertRaises(FacebookError): factory.get_user("123")
def test_failure(self): factory = UserFactory() factory.graph_api_class = mock.Mock() factory.graph_api_class.return_value.get.side_effect = [ FacebookError("msg", 1), FacebookError("msg", 1), FacebookError("msg", 1), {'id': '123'}] with self.assertRaises(FacebookError): factory.get_user("123")
def test_success_in_retry(self, get_graph): factory = UserFactory() get_graph.return_value.get.side_effect = [ FacebookError("msg", 1), FacebookError("msg", 1), {'id': '123'}] user = factory.get_user("123") self.assertEqual(123, user.user_id)
def test_success(self): factory = UserFactory() factory.graph_api_class = mock.Mock() factory.graph_api_class.return_value.get.return_value = {'id': '123'} user = factory.get_user("123") self.assertEqual(123, user.user_id)
def test_success(self, get_graph): factory = UserFactory() get_graph.return_value.get.return_value = {'id': '123'} user = factory.get_user("123") self.assertEqual(123, user.user_id)