# python -m unittest discover

import unittest
from datetime import datetime
from tasks.issue_score_calculator import ScoreCalculator


class TestScore(unittest.TestCase):

    def test_each_contribution(self):
        scorer = ScoreCalculator(data={
            'contributors': [
                { 'login': 'user1', 'contributions': 10 }
            ],
            'issue': {
                'user': {
                    'login': 'user1'
                }
            }
        })
        scorer.each_contribution(add=2, max_contribution=100)
        self.assertEquals(scorer.score, 20)

        scorer = ScoreCalculator(data={
            'contributors': [
                { 'login': 'user1', 'contributions': 10000 }
            ],
            'issue': {
                'user': {
                    'login': 'user1'
                }
            }
        })
        scorer.each_contribution(add=2, max_contribution=100)
        self.assertEquals(scorer.score, 100)

        scorer = ScoreCalculator(data={
            'contributors': [
                { 'login': 'user2', 'contributions': 10000 }
            ],
            'issue': {
                'user': {
                    'login': 'user1'
                }
            }
        })
        scorer.each_contribution(add=2, max_contribution=100)
        self.assertEquals(scorer.score, 0)

        scorer = ScoreCalculator(data={
            'contributors': [
                { 'login': 'abe', 'contributions': 10000 }
            ],
            'issue': {
                'user': {
                    'login': 'abe'
                }
            },
            'org_members': ['abe', 'jeb', 'rocky']
        })
        scorer.each_contribution(add=2, max_contribution=100)
        self.assertEquals(scorer.score, 0)


    def test_short_title_text(self):
        scorer = ScoreCalculator(data={