# Path: tests/blindrtest.py
# class BlindrTest(TestCase):
#     def create_app(self):
#         return create_app('config.test')
# 
#     def setUp(self):
#         db.create_all()
#         self.auth_user = UserFactory(
#             id='auth_user',
#             fake_name='Foo Bar',
#             real_name='Auth User',
#             last_poll=datetime(2000,1,1)
#         )
# 
#     def tearDown(self):
#         db.session.remove()
#         db.drop_all()
# 
#     def auth_post(self, *args, **kwargs):
#         self._add_header_auth_token(kwargs)
#         return self.client.post(*args, **kwargs)
# 
#     def auth_get(self, *args, **kwargs):
#         self._add_header_auth_token(kwargs)
#         return self.client.get(*args, **kwargs)
# 
#     def _add_header_auth_token(self, kwargs):
#         s = itsdangerous.Signer(self.app.config['AUTH_SECRET'])
#         token = s.sign(b'auth_user').decode('utf-8')
# 
#         if not 'headers' in kwargs:
#             kwargs['headers'] = {}
# 
#         kwargs['headers']['X-User-Token'] = token
# 
# Path: tests/factory_boy/match_factory.py
# class MatchFactory(factory.alchemy.SQLAlchemyModelFactory):
#     class Meta:
#         model = Match
#         sqlalchemy_session = db.session
# 
#     @staticmethod
#     def mutual_match(user1,user2):
#         MatchFactory(
#             match_to_id=user2.id,
#             match_from_id=user1.id,
#             mutual=True
#         )
#         MatchFactory(
#             match_to_id=user1.id,
#             match_from_id=user2.id,
#             mutual=True
#         )
# 
#     match_from_id = factory.SubFactory(UserFactory)
#     match_to_id = factory.SubFactory(UserFactory)
#     mutual = False
# 
# Path: tests/factory_boy/user_factory.py
# class UserFactory(factory.alchemy.SQLAlchemyModelFactory):
#     class Meta:
#         model = User
#         sqlalchemy_session = db.session
# 
#     id = factory.Sequence(lambda n: str(n))
# 
#     fake_name = 'Fakename'
#     real_name = 'Realname'
#     gender = 'm'
# 
# Path: blindr/models/match.py
# class Match(db.Model):
#     __tablename__ = 'matches'
# 
#     match_from_id = 	db.Column(db.String, db.ForeignKey('users.id'))
#     match_to_id =	db.Column(db.String, db.ForeignKey('users.id'))
#     mutual =		db.Column(db.Boolean)
# 
#     __table_args__ = (db.PrimaryKeyConstraint('match_from_id', 'match_to_id'),)


from tests.blindrtest import BlindrTest
from tests.factory_boy.match_factory import MatchFactory
from tests.factory_boy.user_factory import UserFactory
from blindr.models.match import Match
from unittest import mock
import json
            'src': 'user2',
            'src_real_name': 'Realname',
            'src_fake_name': 'Fakename'
        })

    def test_like_unvalid_user(self):
        rv = self.auth_post('/events/like', data=dict(dst_user='foobar'))
        self.assert_status(rv, 422)

    def test_get_like_from_user(self):
        MatchFactory(
            match_from_id=self.auth_user.id,
            match_to_id=UserFactory(id='user2').id,
            mutual=False
        )

        rv = self.auth_get('/events/like')
        self.assert_200(rv)
        rv_data = json.loads(rv.data.decode('utf-8'))[0]

        self.assertEqual(rv_data, {
            'other': 'user2',
            'other_fake_name': 'Fakename',
            'mutual': False
        })

        self.assertNotIn('other_real_name', rv_data)

    def test_get_like_mutual_like_to_user(self):
        MatchFactory(

# Path: tests/blindrtest.py
# class BlindrTest(TestCase):
#     def create_app(self):
#         return create_app('config.test')
# 
#     def setUp(self):
#         db.create_all()
#         self.auth_user = UserFactory(
#             id='auth_user',
#             fake_name='Foo Bar',
#             real_name='Auth User',
#             last_poll=datetime(2000,1,1)
#         )
# 
#     def tearDown(self):
#         db.session.remove()
#         db.drop_all()
# 
#     def auth_post(self, *args, **kwargs):
#         self._add_header_auth_token(kwargs)
#         return self.client.post(*args, **kwargs)
# 
#     def auth_get(self, *args, **kwargs):
#         self._add_header_auth_token(kwargs)
#         return self.client.get(*args, **kwargs)
# 
#     def _add_header_auth_token(self, kwargs):
#         s = itsdangerous.Signer(self.app.config['AUTH_SECRET'])
#         token = s.sign(b'auth_user').decode('utf-8')
# 
#         if not 'headers' in kwargs:
#             kwargs['headers'] = {}
# 
#         kwargs['headers']['X-User-Token'] = token
# 
# Path: tests/factory_boy/match_factory.py
# class MatchFactory(factory.alchemy.SQLAlchemyModelFactory):
#     class Meta:
#         model = Match
#         sqlalchemy_session = db.session
# 
#     @staticmethod
#     def mutual_match(user1,user2):
#         MatchFactory(
#             match_to_id=user2.id,
#             match_from_id=user1.id,
#             mutual=True
#         )
#         MatchFactory(
#             match_to_id=user1.id,
#             match_from_id=user2.id,
#             mutual=True
#         )
# 
#     match_from_id = factory.SubFactory(UserFactory)
#     match_to_id = factory.SubFactory(UserFactory)
#     mutual = False
# 
# Path: tests/factory_boy/user_factory.py
# class UserFactory(factory.alchemy.SQLAlchemyModelFactory):
#     class Meta:
#         model = User
#         sqlalchemy_session = db.session
# 
#     id = factory.Sequence(lambda n: str(n))
# 
#     fake_name = 'Fakename'
#     real_name = 'Realname'
#     gender = 'm'
# 
# Path: blindr/models/match.py
# class Match(db.Model):
#     __tablename__ = 'matches'
# 
#     match_from_id = 	db.Column(db.String, db.ForeignKey('users.id'))
#     match_to_id =	db.Column(db.String, db.ForeignKey('users.id'))
#     mutual =		db.Column(db.Boolean)
# 
#     __table_args__ = (db.PrimaryKeyConstraint('match_from_id', 'match_to_id'),)


# Path: tests/api/test_like.py
from tests.blindrtest import BlindrTest
from tests.factory_boy.match_factory import MatchFactory
from tests.factory_boy.user_factory import UserFactory
from blindr.models.match import Match
from unittest import mock
import json

            'src': 'user2',
            'src_real_name': 'Realname',
            'src_fake_name': 'Fakename'
        })

    def test_like_unvalid_user(self):
        rv = self.auth_post('/events/like', data=dict(dst_user='foobar'))
        self.assert_status(rv, 422)

    def test_get_like_from_user(self):
        MatchFactory(
            match_from_id=self.auth_user.id,
            match_to_id=UserFactory(id='user2').id,
            mutual=False
        )

        rv = self.auth_get('/events/like')
        self.assert_200(rv)
        rv_data = json.loads(rv.data.decode('utf-8'))[0]

        self.assertEqual(rv_data, {
            'other': 'user2',
            'other_fake_name': 'Fakename',
            'mutual': False
        })

        self.assertNotIn('other_real_name', rv_data)

    def test_get_like_mutual_like_to_user(self):
        MatchFactory(

            match_from_id=UserFactory(id='user2').id,