def test_forum_post_might__restricted(self): thread = ThreadPrototype.create(self.restricted_subcategory, 'caption', self.account_2, 'text') PostPrototype.create(thread, self.account, 'text') self.assertEqual(calculate_might(self.account), 0) self.assertEqual(calculate_might(self.account_2), 0)
def test_might_for_linguistics__templaes___different_sources(self): account_3 = self.accounts_factory.create_account() old_might = calculate_might(self.account) self.create_author_contrubutors(range(1, 5), self.contribute_to_template) self.contribute_to_template(self.account.id, entity_id=1) self.contribute_to_template(self.account.id, entity_id=2) self.contribute_to_template( self.account_2.id, entity_id=2, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR) self.contribute_to_template(self.account.id, entity_id=3) self.contribute_to_template( self.account_2.id, entity_id=3, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR) self.contribute_to_template(account_3.id, entity_id=3) self.contribute_to_template( self.account_2.id, entity_id=4, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR) self.contribute_to_template(account_3.id, entity_id=4) self.assertEqual(calculate_might(self.account), old_might + 15.0 + 15.0 / 1 + 15.0 / 2)
def test_forum_post_might(self): thread = ThreadPrototype.create(self.bills_subcategory, 'caption', self.account_2, 'text') PostPrototype.create(thread, self.account, 'text') self.assertTrue(calculate_might(self.account) > 0) self.assertTrue(calculate_might(self.account_2) > 0)
def test_folclor_might(self): old_might = calculate_might(self.account) post = BlogPostPrototype.create(author=self.account, caption='caption', text='text') Post.objects.all().delete() Thread.objects.all().delete() Vote.objects.all().delete() new_might = calculate_might(self.account) self.assertTrue(new_might > old_might) post = BlogPostPrototype.create(author=self.account_2, caption='caption', text='text') Post.objects.all().delete() # Thread.objects.all().delete() Vote.objects.all().delete() post.state = BLOG_POST_STATE.ACCEPTED post._model.votes = 1 post.save() self.assertEqual(new_might, calculate_might(self.account))
def test_might_for_linguistics__templates(self): account_3 = self.accounts_factory.create_account() old_might = calculate_might(self.account) author_account = self.create_author_contrubutors( range(1, 6), self.contribute_to_template) self.contribute_to_template(self.account.id, entity_id=1) self.contribute_to_template(self.account.id, entity_id=2) self.contribute_to_template(self.account_2.id, entity_id=2) self.contribute_to_template(self.account.id, entity_id=3) self.contribute_to_template(self.account_2.id, entity_id=3) self.contribute_to_template(account_3.id, entity_id=3) self.contribute_to_template(self.account_2.id, entity_id=4) self.contribute_to_template(account_3.id, entity_id=4) self.contribute_to_template( self.account.id, entity_id=5, state=linguistics_relations.CONTRIBUTION_STATE.ON_REVIEW) self.assertEqual(calculate_might(self.account), old_might + 15.0 + 15.0 / 2 + 15.0 / 3) self.assertEqual(calculate_might(author_account), old_might + 15.0 * 5)
def test_might_for_linguistics__templaes___different_sources(self): account_3 = self.accounts_factory.create_account() old_might = calculate_might(self.account) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.TEMPLATE, account_id=self.account.id, entity_id=1, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.TEMPLATE, account_id=self.account.id, entity_id=2, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.TEMPLATE, account_id=self.account_2.id, entity_id=2, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.TEMPLATE, account_id=self.account.id, entity_id=3, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.TEMPLATE, account_id=self.account_2.id, entity_id=3, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.TEMPLATE, account_id=account_3.id, entity_id=3, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.TEMPLATE, account_id=self.account_2.id, entity_id=4, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.TEMPLATE, account_id=account_3.id, entity_id=4, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) self.assertEqual(calculate_might(self.account), old_might + 15.0 + 15.0 / 1 + 15.0 / 2)
def test_rejected_bill_might(self): old_might = calculate_might(self.account) bill_data = PlaceRenaming(place_id=self.place_1.id, name_forms=names.generator.get_test_name('bill_place')) bill = BillPrototype.create(self.account, 'caption', 'rationale', bill_data, chronicle_on_accepted='chronicle-on-accepted') bill.state = BILL_STATE.REJECTED bill.save() Post.objects.all().delete() Thread.objects.all().delete() Vote.objects.all().delete() self.assertEqual(calculate_might(self.account), old_might) self.assertEqual(calculate_might(self.account_2), 0)
def test_folclor_might__only_text(self): self.assertEqual(calculate_might(self.account), 0) BlogPostPrototype.create(author=self.account, caption='caption', text='text') Post.objects.all().delete() Thread.objects.all().delete() Vote.objects.all().delete() might = calculate_might(self.account) BlogPostPrototype.create(author=self.account, caption='caption', text='[b]text[/b]') self.assertEqual(calculate_might(self.account), might * 2)
def test_folclor_might__from_characters(self): with self.check_delta(lambda: calculate_might(self.account), relations.MIGHT_AMOUNT.FOR_MIN_FOLCLOR_POST.amount*(1 + 1.5 + 2.1)): BlogPostPrototype.create(author=self.account, caption='caption', text='x'*blogs_conf.settings.MIN_TEXT_LENGTH) BlogPostPrototype.create(author=self.account, caption='caption-2', text='y'*blogs_conf.settings.MIN_TEXT_LENGTH*2) BlogPostPrototype.create(author=self.account, caption='caption-3', text='z'*blogs_conf.settings.MIN_TEXT_LENGTH*4) Post.objects.all().delete() Thread.objects.all().delete() Vote.objects.all().delete()
def test_forum_vote_might(self): old_might = calculate_might(self.account) bill_data = PlaceRenaming( place_id=self.place_1.id, name_forms=names.generator().get_test_name('bill_place')) bill = BillPrototype.create( self.account_2, 'caption', bill_data, chronicle_on_accepted='chronicle-on-accepted') bill.state = BILL_STATE.REJECTED bill.save() Post.objects.all().delete() Thread.objects.all().delete() Vote.objects.all().delete() self.assertEqual(calculate_might(self.account_2), old_might) self.assertEqual(calculate_might(self.account), 0) VotePrototype.create(self.account, bill, VOTE_TYPE.FOR) self.assertTrue(calculate_might(self.account) > 0) Vote.objects.all().delete() VotePrototype.create(self.account, bill, VOTE_TYPE.AGAINST) self.assertTrue(calculate_might(self.account) > 0) Vote.objects.all().delete() VotePrototype.create(self.account, bill, VOTE_TYPE.REFRAINED) self.assertEqual(calculate_might(self.account), 0)
def test_might_for_linguistics__words___two_sources(self): account_3 = self.accounts_factory.create_account() old_might = calculate_might(self.account) author_account = self.create_author_contrubutors( range(1, 4), self.contribute_to_word) self.contribute_to_word(self.account.id, entity_id=1) self.contribute_to_word(self.account.id, entity_id=2) self.contribute_to_word( self.account_2.id, entity_id=2, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR) self.contribute_to_word(self.account.id, entity_id=3) self.contribute_to_word( self.account_2.id, entity_id=3, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR) self.contribute_to_word(account_3.id, entity_id=3) self.contribute_to_word( author_account.id, entity_id=4, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR) self.contribute_to_word( self.account.id, entity_id=4, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR) self.contribute_to_word( self.account_2.id, entity_id=4, source=linguistics_relations.CONTRIBUTION_SOURCE.MODERATOR) self.contribute_to_word(account_3.id, entity_id=4) self.assertEqual(calculate_might(self.account), old_might + 5.0 + 5.0 / 1 + 5.0 / 2 + 5.0 / 2)
def test_might_for_linguistics__words(self): account_3 = self.accounts_factory.create_account() old_might = calculate_might(self.account) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.WORD, account_id=self.account.id, entity_id=1, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.WORD, account_id=self.account.id, entity_id=2, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.WORD, account_id=self.account_2.id, entity_id=2, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.WORD, account_id=self.account.id, entity_id=3, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.WORD, account_id=self.account_2.id, entity_id=3, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.WORD, account_id=account_3.id, entity_id=3, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.WORD, account_id=self.account_2.id, entity_id=4, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.WORD, account_id=account_3.id, entity_id=4, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.IN_GAME) linguistics_prototypes.ContributionPrototype.create(type=linguistics_relations.CONTRIBUTION_TYPE.WORD, account_id=self.account.id, entity_id=5, source=linguistics_relations.CONTRIBUTION_SOURCE.PLAYER, state=linguistics_relations.CONTRIBUTION_STATE.ON_REVIEW) self.assertEqual(calculate_might(self.account), old_might + 5.0 + 5.0 / 2 + 5.0 / 3)
def test_folclor_might(self): old_might = calculate_might(self.account) post = BlogPostPrototype.create(author=self.account, caption='caption', text='text') Post.objects.all().delete() Thread.objects.all().delete() Vote.objects.all().delete() new_might = calculate_might(self.account) self.assertTrue(new_might > old_might) post = BlogPostPrototype.create(author=self.account_2, caption='caption', text='text') Post.objects.all().delete() Thread.objects.all().delete() Vote.objects.all().delete() post.state = BLOG_POST_STATE.ACCEPTED post._model.votes = 1 post.save() self.assertEqual(new_might, calculate_might(self.account))
def test_forum_thread_might__restricted(self): ThreadPrototype.create(self.restricted_subcategory, 'caption', self.account, 'text') self.assertEqual(calculate_might(self.account), 0)
def test_forum_thread_might(self): ThreadPrototype.create(self.bills_subcategory, 'caption', self.account, 'text') self.assertTrue(calculate_might(self.account) > 0) self.assertEqual(calculate_might(self.account_2), 0)
def test_no_might(self): self.assertEqual(calculate_might(self.account), 0)
def test_referral_custom_might(self): self.account_2.set_might(666) self.assertTrue(calculate_might(self.account) > 0)
def test_custom_might(self): Award.objects.create(account=self.account._model, type=relations.AWARD_TYPE.BUG_MINOR) self.assertTrue(calculate_might(self.account) > 0)