def test_regular_voted_minority(self, admin_user, thread, charity): setup_thread(thread, charity) UserVoteFactory.create_batch(3, thread=thread, direction=True) UserVoteFactory.create_batch(5, thread=thread, direction=False) UserVoteFactory.create(thread=thread, direction=True, user=UserFactory.create(is_staff=True)) UserVoteFactory.create(thread=thread, direction=True, user=admin_user) assert WantedItem.objects.count() == 0
def test_complete_merge(self, admin_user, thread, charity): setup_thread(thread, charity) UserVoteFactory.create_batch(6, thread=thread, direction=True) UserVoteFactory.create_batch(4, thread=thread, direction=False) UserVoteFactory.create(thread=thread, direction=True, user=UserFactory.create(is_staff=True)) assert WantedItem.objects.count() == 0 UserVoteFactory.create(thread=thread, direction=True, user=admin_user) assert WantedItem.objects.count() == 10 assert ProposedItem.objects.count() == 1 assert ProposedItem.objects.first().closed is True
def handle(self, *args, **options): if not settings.DEBUG: raise Exception("You cannot use this command in production.") print("Creating Forum app data.") for _ in range(2): for thread_type, _ in THREAD_TYPE_CHOICES: ThreadFactory.create(type=thread_type) for thread in Thread.objects.all(): MessageFactory.create_batch(randint(6, 30), thread=thread) for thread in Thread.objects.filter(type__gt=0): UserVoteFactory.create_batch(randint(10, 50), thread=thread) print("Finished creating Forum app data.")
def test_not_enough_staff_votes(self, admin_user, thread, charity): setup_thread(thread, charity) UserVoteFactory.create_batch(4, thread=thread, direction=True) UserVoteFactory.create_batch(4, thread=thread, direction=False) UserVoteFactory.create(thread=thread, direction=True, user=admin_user) assert WantedItem.objects.count() == 0
def add_break_even_amount(thread): UserVoteFactory.create_batch(4, thread=thread, direction=True) UserVoteFactory.create_batch(4, thread=thread, direction=False) UserVoteFactory.create(thread=thread, direction=True, user=UserFactory.create(is_staff=True))