# Path: errors.py
# class TaintedLove(Exception):
# 
#     def __init__(self, user_message, is_error=True):
#         self.user_message = user_message
#         self.is_error = (is_error is True)
# 
# Path: testing/factories/alias.py
# def create_alias_with_employee_username(
#     name='jda',
#     username='jd',
# ):
#     alias = Alias(
#         name=name,
#         owner_key=Employee.get_key_for_username(username),
#     )
#     alias.put()
#     return alias
# 
# Path: testing/factories/employee.py
# def create_employee(
#     username='johndoe',
#     department='Engineering',
#     first_name='John',
#     last_name='Doe',
#     photo_url=None,
#     office=None,
# ):
# 
#     if photo_url is None:
#         photo_url = 'http://example.com/photos/{0}.jpg'.format(username)
# 
#     return Employee.create_from_dict({
#         'username': username,
#         'department': department,
#         'first_name': first_name,
#         'last_name': last_name,
#         'photo_url': photo_url,
#         'office': office,
#     })


import mock
import unittest
import logic.love
from config import CompanyValue
from errors import TaintedLove
from testing.factories import create_alias_with_employee_username
from testing.factories import create_employee
                set(['alice']),
                self.message,
                sender_username='alice',
            )

    def test_invalid_recipient(self):
        with self.assertRaises(TaintedLove):
            logic.love.send_loves(
                set(['bob', 'dean']),
                'hallo',
                sender_username='alice',
            )

        loves_for_bob = logic.love.get_love('alice', 'bob').get_result()
        self.assertEqual(loves_for_bob, [])

    def test_send_loves_with_alias(self):
        message = 'Loving your alias'
        create_alias_with_employee_username(name='bobby', username=self.bob.username)

        logic.love.send_loves(['bobby'], message, sender_username=self.carol.username)

        loves_for_bob = logic.love.get_love('carol', 'bob').get_result()
        self.assertEqual(len(loves_for_bob), 1)
        self.assertEqual(loves_for_bob[0].sender_key, self.carol.key)
        self.assertEqual(loves_for_bob[0].message, message)

    def test_send_loves_with_alias_and_username_for_same_user(self):
        create_alias_with_employee_username(name='bobby', username=self.bob.username)


# Path: errors.py
# class TaintedLove(Exception):
# 
#     def __init__(self, user_message, is_error=True):
#         self.user_message = user_message
#         self.is_error = (is_error is True)
# 
# Path: testing/factories/alias.py
# def create_alias_with_employee_username(
#     name='jda',
#     username='jd',
# ):
#     alias = Alias(
#         name=name,
#         owner_key=Employee.get_key_for_username(username),
#     )
#     alias.put()
#     return alias
# 
# Path: testing/factories/employee.py
# def create_employee(
#     username='johndoe',
#     department='Engineering',
#     first_name='John',
#     last_name='Doe',
#     photo_url=None,
#     office=None,
# ):
# 
#     if photo_url is None:
#         photo_url = 'http://example.com/photos/{0}.jpg'.format(username)
# 
#     return Employee.create_from_dict({
#         'username': username,
#         'department': department,
#         'first_name': first_name,
#         'last_name': last_name,
#         'photo_url': photo_url,
#         'office': office,
#     })


# Path: tests/logic/love_test.py
import mock
import unittest
import logic.love
from config import CompanyValue
from errors import TaintedLove
from testing.factories import create_alias_with_employee_username
from testing.factories import create_employee

                set(['alice']),
                self.message,
                sender_username='alice',
            )

    def test_invalid_recipient(self):
        with self.assertRaises(TaintedLove):
            logic.love.send_loves(
                set(['bob', 'dean']),
                'hallo',
                sender_username='alice',
            )

        loves_for_bob = logic.love.get_love('alice', 'bob').get_result()
        self.assertEqual(loves_for_bob, [])

    def test_send_loves_with_alias(self):
        message = 'Loving your alias'
        create_alias_with_employee_username(name='bobby', username=self.bob.username)

        logic.love.send_loves(['bobby'], message, sender_username=self.carol.username)

        loves_for_bob = logic.love.get_love('carol', 'bob').get_result()
        self.assertEqual(len(loves_for_bob), 1)
        self.assertEqual(loves_for_bob[0].sender_key, self.carol.key)
        self.assertEqual(loves_for_bob[0].message, message)

    def test_send_loves_with_alias_and_username_for_same_user(self):
        create_alias_with_employee_username(name='bobby', username=self.bob.username)


        with self.assertRaises(TaintedLove):