# Path: example/generic_social_network/tests/controllers/controller_test_case.py
# class ControllerTestCase(unittest.TestCase):
#     def setUp(self):
#         from generic_social_network.app import my_app, db
# 
#         my_app.config['TESTING'] = True
#         self.app = my_app.test_client()
#         self.db = db
#         from generic_social_network.app.services import db_wrapper
#         db_wrapper.reset(self.db)
# 
#     def tearDown(self):
#         from generic_social_network.app.services import db_wrapper
#         db_wrapper.reset(self.db)
# 
#     def check_response(self, response, expected_code, expected_json):
#         # print('comparing', response.status_code, 'to', expected_code,
#         #       "\nand comparing", json.loads(response.data), 'to', expected_json)
#         if response.status_code != expected_code:
#             print(response.status_code, expected_code)
#         assert response.status_code == expected_code
#         if expected_json is not None:
#             self.assertEqual(json.loads(response.data.decode('utf-8')),expected_json)
# 
#     def check_jsonapi_response(self, response, expected_code, expected_json):
#         # print('comparing', response.status_code, 'to', expected_code,
#         #       "\nand comparing", json.loads(response.data), 'to', expected_json)
#         if response.status_code != expected_code:
#             print(response.status_code, expected_code)
#         assert response.status_code == expected_code
#         if expected_json is not None:
#             response_json = json.loads(response.data.decode('utf-8'))
#             if response_json.get('data') != expected_json.get('data'):
#                 print(response_json.get('data'), 'not equal to', expected_json.get('data'))
#             self.assertEqual(response_json.get('data'), expected_json.get('data'))
#             response_included = response_json.get('included', [])
#             expected_included = expected_json.get('included', [])
#             for i in response_included:
#                 if i not in expected_included:
#                     print(i, 'not in', expected_included)
#                 assert i in expected_included
#             for i in expected_included:
#                 assert i in response_included
# 
#     @classmethod
#     def suite(cls):
#         return unittest.TestLoader().loadTestsFromTestCase(cls)


import json
from .controller_test_case import ControllerTestCase
                    'type': 'text',
                },
                'relationships': {
                    'author': {
                        'data': {
                            'id': str(author_id),
                            'type': 'user'
                        }
                    }
                }
            }
        }
        return self.app.post('/posts/{0}'.format(post_id),
                             data=json.dumps(post_json),
                             content_type='application/json')

    def make_a_follow(self, follower_id, followed_id):
        return self.app.post('/follows/{0}/{1}'.format(follower_id, followed_id))

    def make_a_reasonable_newsfeed(self, user_id=1, author_ids=[20, 30]):
        self.make_a_user(user_id)
        for author_id in author_ids:
            self.make_a_user(author_id)
            for i in range(3):
                post_id = author_id + i
                self.make_a_post(post_id=post_id, author_id=author_id)
            self.make_a_follow(user_id, author_id)

    def test_get_news_feed(self):
        id_ = 1

# Path: example/generic_social_network/tests/controllers/controller_test_case.py
# class ControllerTestCase(unittest.TestCase):
#     def setUp(self):
#         from generic_social_network.app import my_app, db
# 
#         my_app.config['TESTING'] = True
#         self.app = my_app.test_client()
#         self.db = db
#         from generic_social_network.app.services import db_wrapper
#         db_wrapper.reset(self.db)
# 
#     def tearDown(self):
#         from generic_social_network.app.services import db_wrapper
#         db_wrapper.reset(self.db)
# 
#     def check_response(self, response, expected_code, expected_json):
#         # print('comparing', response.status_code, 'to', expected_code,
#         #       "\nand comparing", json.loads(response.data), 'to', expected_json)
#         if response.status_code != expected_code:
#             print(response.status_code, expected_code)
#         assert response.status_code == expected_code
#         if expected_json is not None:
#             self.assertEqual(json.loads(response.data.decode('utf-8')),expected_json)
# 
#     def check_jsonapi_response(self, response, expected_code, expected_json):
#         # print('comparing', response.status_code, 'to', expected_code,
#         #       "\nand comparing", json.loads(response.data), 'to', expected_json)
#         if response.status_code != expected_code:
#             print(response.status_code, expected_code)
#         assert response.status_code == expected_code
#         if expected_json is not None:
#             response_json = json.loads(response.data.decode('utf-8'))
#             if response_json.get('data') != expected_json.get('data'):
#                 print(response_json.get('data'), 'not equal to', expected_json.get('data'))
#             self.assertEqual(response_json.get('data'), expected_json.get('data'))
#             response_included = response_json.get('included', [])
#             expected_included = expected_json.get('included', [])
#             for i in response_included:
#                 if i not in expected_included:
#                     print(i, 'not in', expected_included)
#                 assert i in expected_included
#             for i in expected_included:
#                 assert i in response_included
# 
#     @classmethod
#     def suite(cls):
#         return unittest.TestLoader().loadTestsFromTestCase(cls)


# Path: example/generic_social_network/tests/controllers/news_feed_controller_tests.py
import json
from .controller_test_case import ControllerTestCase

                    'type': 'text',
                },
                'relationships': {
                    'author': {
                        'data': {
                            'id': str(author_id),
                            'type': 'user'
                        }
                    }
                }
            }
        }
        return self.app.post('/posts/{0}'.format(post_id),
                             data=json.dumps(post_json),
                             content_type='application/json')

    def make_a_follow(self, follower_id, followed_id):
        return self.app.post('/follows/{0}/{1}'.format(follower_id, followed_id))

    def make_a_reasonable_newsfeed(self, user_id=1, author_ids=[20, 30]):
        self.make_a_user(user_id)
        for author_id in author_ids:
            self.make_a_user(author_id)
            for i in range(3):
                post_id = author_id + i
                self.make_a_post(post_id=post_id, author_id=author_id)
            self.make_a_follow(user_id, author_id)

    def test_get_news_feed(self):
        id_ = 1

        self.make_a_reasonable_newsfeed(user_id=id_)