# Path: account/factories.py
# class AccountFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Account
# 
#     user = factory.SubFactory(UserFactory)
# 
# DEFAULT_PASSWORD = 'abc@123'
# 
# Path: link/factories.py
# class PostFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Post
# 
#     owner = factory.SubFactory(AccountFactory)
#     publisher = factory.SubFactory(AccountFactory)
#     url = 'http://test.tst'
#     type = 'html'
#     title = factory.sequence(lambda n: 'Title Link Test {}'.format(n))
#     summary = factory.sequence(lambda n: 'Summary Link Test {}'.format(n))
#     text = factory.sequence(lambda n: 'Summary Link Test {}'.format(n))
#     image_url = factory.sequence(lambda n: 'Summary Link Test {}'.format(n))
# 
# class ReactionFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Reaction
# 
#     owner = factory.SubFactory(AccountFactory)
#     post = factory.SubFactory(PostFactory)


import requests
from unittest.mock import patch
from django.test import TestCase
from django.core.urlresolvers import reverse
from account.factories import AccountFactory, DEFAULT_PASSWORD
from link.factories import PostFactory, ReactionFactory





class TestLink(TestCase):
    def setUp(self):
        self.other_user = AccountFactory.create()
        self.other_user_post = PostFactory.create(owner=self.other_user, publisher=self.other_user)
        self.account = AccountFactory.create()
        self.user = self.account.user
        [PostFactory.create(owner=self.account, publisher=self.account) for _ in range(2)]

    def test_access_links_anonymous(self):
        response = self.client.get(reverse('links', args=[self.user.username]))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'link/link.html')

    def test_access_profile_logged_in(self):

# Path: account/factories.py
# class AccountFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Account
# 
#     user = factory.SubFactory(UserFactory)
# 
# DEFAULT_PASSWORD = 'abc@123'
# 
# Path: link/factories.py
# class PostFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Post
# 
#     owner = factory.SubFactory(AccountFactory)
#     publisher = factory.SubFactory(AccountFactory)
#     url = 'http://test.tst'
#     type = 'html'
#     title = factory.sequence(lambda n: 'Title Link Test {}'.format(n))
#     summary = factory.sequence(lambda n: 'Summary Link Test {}'.format(n))
#     text = factory.sequence(lambda n: 'Summary Link Test {}'.format(n))
#     image_url = factory.sequence(lambda n: 'Summary Link Test {}'.format(n))
# 
# class ReactionFactory(factory.DjangoModelFactory):
#     class Meta:
#         model = Reaction
# 
#     owner = factory.SubFactory(AccountFactory)
#     post = factory.SubFactory(PostFactory)


# Path: link/tests.py
import requests
from unittest.mock import patch
from django.test import TestCase
from django.core.urlresolvers import reverse
from account.factories import AccountFactory, DEFAULT_PASSWORD
from link.factories import PostFactory, ReactionFactory






class TestLink(TestCase):
    def setUp(self):
        self.other_user = AccountFactory.create()
        self.other_user_post = PostFactory.create(owner=self.other_user, publisher=self.other_user)
        self.account = AccountFactory.create()
        self.user = self.account.user
        [PostFactory.create(owner=self.account, publisher=self.account) for _ in range(2)]

    def test_access_links_anonymous(self):
        response = self.client.get(reverse('links', args=[self.user.username]))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'link/link.html')

    def test_access_profile_logged_in(self):

        self.client.login(username=self.user.username, password=DEFAULT_PASSWORD)