

def test_get_pending_suggestions(self):
    total = Suggestion.objects.get_pending_suggestions().count()
    self.assertEqual(total, 0)
    total_mk1 = Suggestion.objects.get_pending_suggestions_for(self.member1).count()
    self.assertEqual(total_mk1, 0)
    total_mk2 = Suggestion.objects.get_pending_suggestions_for(self.member2).count()
    self.assertEqual(total_mk2, 0)
    suggestion1 = Suggestion.objects.create_suggestion(suggested_by=self.regular_user, actions=[{
        'action': consts.SET,
        'fields': {
            'website': self.MK_SITE,
        },
        'subject': self.member1,
    }])
    suggestion2 = Suggestion.objects.create_suggestion(suggested_by=self.regular_user, actions=[{
        'action': consts.SET,
        'fields': {
            'website': self.MK_SITE,
        },
        'subject': self.member2,
    }])
    total = Suggestion.objects.get_pending_suggestions().count()
    self.assertEqual(total, 2)
    total_mk1 = Suggestion.objects.get_pending_suggestions_for(self.member1).count()
    self.assertEqual(total_mk1, 1)
    total_mk2 = Suggestion.objects.get_pending_suggestions_for(self.member2).count()
    self.assertEqual(total_mk2, 1)
    suggestion1.auto_apply(self.editor)
    total = Suggestion.objects.get_pending_suggestions().count()
    self.assertEqual(total, 1)
    total_mk1 = Suggestion.objects.get_pending_suggestions_for(self.member1).count()
    self.assertEqual(total_mk1, 0)
    suggestions_mks2 = Suggestion.objects.get_pending_suggestions_for(self.member2)
    total_mk2 = suggestions_mks2.count()
    self.assertEqual(total_mk2, 1)
    self.assertEqual(list(suggestions_mks2), [suggestion2])
    Suggestion.objects.all().delete()

dataset/ETHPy150Open ofri/Open-Knesset/suggestions/tests.py SuggestionsTests.test_get_pending_suggestions/original