{"action":"created","comment":{"url":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/comments/67201384","id":67201384,"diff_hunk":"@@ -0,0 +1,211 @@\n+# Testing Guidelines\n+This document contains the guidelines when working with tests in LendingFront repositories. The testing guidelines \n+are focused on two different types or types or repositories: front end and apis.\n+\n+The first iteration of testing in LendingFront would consist on creating unit tests to flask endpoints following these\n+guidelines:\n+\n+- Create unit tests ONLY for the entpoints that you just created or you are modifying\n+- Calls to API's have to be mocked (for examples of mocking take a look to [this](https://github.com/jhonjairoroa87/flask-endpoint-test-mocking/blob/master/test/unit/views_test.py) link)\n+- Do not mock interaction with database, make use of database interaction but instead of PostgreSQL use SQLite: \n+ (For further detail take a look to [this](https://pythonhosted.org/Flask-Testing/) link )\n+ ```python\n+ def setUp(self):\n+    self.db_uri = 'sqlite:///' + os.path.join(basedir, 'test.db')\n+    app.config['TESTING'] = True\n+    app.config['WTF_CSRF_ENABLED'] = False\n+    app.config['SQLALCHEMY_DATABASE_URI'] = self.db_uri\n+    self.app = app.test_client()\n+    db.create_all()\n+ ```\n+ \n+## DOM tests:\n+\n+### Repositories\n+\n+The repositories where DOM validations have to be implemented are:\n+\n+- [LendingPortal](https://github.com/dariofvergara/lendingportal)\n+- [CustomerPortal](https://github.com/dariofvergara/customerportal)\n+\n+### Project structure\n+\n+An example of project structure for test is:\n+ ```\n+    lendingportal\n+    ├── app\n+    │   ├── __init__.py         # make it a package\n+    │   └── views\n+    │       └── application.py\n+    │       └── business.py\n+    └── test\n+        ├── __init__.py         # also make test a package\n+        └── unit                # unit tests folder\n+            └── views\n+                └── application_test.py\n+                └── business_test.py\n+ ```\n+ \n+### Mocks\n+\n+The mocks will be placed in 'general' repository so they can be shared among other repository tests\n+ ```\n+ general\n+    └── test\n+        └── common\n+            └── mocks \n+                └── ls_api  # folder for every internal api mock\n+                    └── business_loan_api.py\n+                    └── funding_source_api.py\n+                    └── one_time_payment.py\n+ ```\n+        \n+### Validations\n+\n+The validations have to be done comparing the elements in the DOM with the elements in memory:\n+\n+    ```python\n+    # this is the rendered html\n+    response_data = \"\"\"\n+    <html lang=\"en\">\n+        <head>\n+            <meta charset=\"UTF-8\">\n+            <title>Hello from Flask</title>\n+        </head>\n+        <body>\n+            <div class=\"flash\">Medellin Python y Django Meetup</div>\n+            <div class=\"flash\">PyLadies Medellin </div>\n+        </body>\n+    </html>\n+    \"\"\"\n+    \n+    # this is the data in memory\n+    get_all_groups_mock_return = [{\n+        \"city\": \"Medellin\",\n+        \"country_code\": \"CO\",\n+        \"country_name\": \"Colombia\",\n+        \"members\": 848,\n+        \"name\": \"Medellin Python y Django Meetup\"\n+    }, {\n+        \"city\": \"Medellin\",\n+        \"country_code\": \"CO\",\n+        \"country_name\": \"Colombia\",\n+        \"members\": 150,\n+        \"name\": \"PyLadies Medellin \"\n+    }]\n+    \n+    # create soup object with the returned html file\n+    soup = BeautifulSoup(response_data, \"html.parser\")\n+    \n+    # look for all divs that it's class is 'flash'\n+    flask_divs = soup.find_all('div', {'class': \"flash\"})\n+    \n+    # verify the rendered divs number is the same number of the groups in memory\n+    self.assertEqual(len(flask_divs), len(get_all_groups_mock_return))\n+    \n+    # verify each div text is exactly the same of the the groups in memory\n+    for index, item in enumerate(get_all_groups_mock_return):\n+        text_div_element = flask_divs[index].text\n+        name_group_memory = get_all_groups_mock_return[index]['name']\n+        self.assertEqual(text_div_element, name_group_memory)\n+    ```\n+\n+For further reference take a look to the following project : [flask-view-dom-testing](https://github.com/jhonjairoroa87/flask-view-dom-testing/blob/master/test/unit/views_test.py)\n+ \n+## API tests:\n+","path":"README.md","position":116,"original_position":116,"commit_id":"33610ac5cf41998dae561992b01f7c24625828cf","original_commit_id":"33610ac5cf41998dae561992b01f7c24625828cf","user":{"login":"jhonjairoroa87","id":619203,"avatar_url":"https://avatars.githubusercontent.com/u/619203?v=3","gravatar_id":"","url":"https://api.github.com/users/jhonjairoroa87","html_url":"https://github.com/jhonjairoroa87","followers_url":"https://api.github.com/users/jhonjairoroa87/followers","following_url":"https://api.github.com/users/jhonjairoroa87/following{/other_user}","gists_url":"https://api.github.com/users/jhonjairoroa87/gists{/gist_id}","starred_url":"https://api.github.com/users/jhonjairoroa87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhonjairoroa87/subscriptions","organizations_url":"https://api.github.com/users/jhonjairoroa87/orgs","repos_url":"https://api.github.com/users/jhonjairoroa87/repos","events_url":"https://api.github.com/users/jhonjairoroa87/events{/privacy}","received_events_url":"https://api.github.com/users/jhonjairoroa87/received_events","type":"User","site_admin":false},"body":"Completely Agree, will fix that","created_at":"2016-06-15T16:56:47Z","updated_at":"2016-06-15T16:56:47Z","html_url":"https://github.com/lendingfront/testing-guidelines/pull/1#discussion_r67201384","pull_request_url":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/comments/67201384"},"html":{"href":"https://github.com/lendingfront/testing-guidelines/pull/1#discussion_r67201384"},"pull_request":{"href":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/1","id":73689880,"html_url":"https://github.com/lendingfront/testing-guidelines/pull/1","diff_url":"https://github.com/lendingfront/testing-guidelines/pull/1.diff","patch_url":"https://github.com/lendingfront/testing-guidelines/pull/1.patch","issue_url":"https://api.github.com/repos/lendingfront/testing-guidelines/issues/1","number":1,"state":"open","locked":false,"title":"First proposal","user":{"login":"jhonjairoroa87","id":619203,"avatar_url":"https://avatars.githubusercontent.com/u/619203?v=3","gravatar_id":"","url":"https://api.github.com/users/jhonjairoroa87","html_url":"https://github.com/jhonjairoroa87","followers_url":"https://api.github.com/users/jhonjairoroa87/followers","following_url":"https://api.github.com/users/jhonjairoroa87/following{/other_user}","gists_url":"https://api.github.com/users/jhonjairoroa87/gists{/gist_id}","starred_url":"https://api.github.com/users/jhonjairoroa87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhonjairoroa87/subscriptions","organizations_url":"https://api.github.com/users/jhonjairoroa87/orgs","repos_url":"https://api.github.com/users/jhonjairoroa87/repos","events_url":"https://api.github.com/users/jhonjairoroa87/events{/privacy}","received_events_url":"https://api.github.com/users/jhonjairoroa87/received_events","type":"User","site_admin":false},"body":"First proposal of Testing guidelines","created_at":"2016-06-14T07:08:11Z","updated_at":"2016-06-15T16:56:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a27c9dc6d368a4aaeb14fa17688b2b3286607f2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/1/commits","review_comments_url":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/1/comments","review_comment_url":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lendingfront/testing-guidelines/issues/1/comments","statuses_url":"https://api.github.com/repos/lendingfront/testing-guidelines/statuses/33610ac5cf41998dae561992b01f7c24625828cf","head":{"label":"lendingfront:first-proposal","ref":"first-proposal","sha":"33610ac5cf41998dae561992b01f7c24625828cf","user":{"login":"lendingfront","id":13339895,"avatar_url":"https://avatars.githubusercontent.com/u/13339895?v=3","gravatar_id":"","url":"https://api.github.com/users/lendingfront","html_url":"https://github.com/lendingfront","followers_url":"https://api.github.com/users/lendingfront/followers","following_url":"https://api.github.com/users/lendingfront/following{/other_user}","gists_url":"https://api.github.com/users/lendingfront/gists{/gist_id}","starred_url":"https://api.github.com/users/lendingfront/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lendingfront/subscriptions","organizations_url":"https://api.github.com/users/lendingfront/orgs","repos_url":"https://api.github.com/users/lendingfront/repos","events_url":"https://api.github.com/users/lendingfront/events{/privacy}","received_events_url":"https://api.github.com/users/lendingfront/received_events","type":"Organization","site_admin":false},"repo":{"id":60427810,"name":"testing-guidelines","full_name":"lendingfront/testing-guidelines","owner":{"login":"lendingfront","id":13339895,"avatar_url":"https://avatars.githubusercontent.com/u/13339895?v=3","gravatar_id":"","url":"https://api.github.com/users/lendingfront","html_url":"https://github.com/lendingfront","followers_url":"https://api.github.com/users/lendingfront/followers","following_url":"https://api.github.com/users/lendingfront/following{/other_user}","gists_url":"https://api.github.com/users/lendingfront/gists{/gist_id}","starred_url":"https://api.github.com/users/lendingfront/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lendingfront/subscriptions","organizations_url":"https://api.github.com/users/lendingfront/orgs","repos_url":"https://api.github.com/users/lendingfront/repos","events_url":"https://api.github.com/users/lendingfront/events{/privacy}","received_events_url":"https://api.github.com/users/lendingfront/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lendingfront/testing-guidelines","description":"This document contains the guidelines when working with tests in LendingFront repositories","fork":false,"url":"https://api.github.com/repos/lendingfront/testing-guidelines","forks_url":"https://api.github.com/repos/lendingfront/testing-guidelines/forks","keys_url":"https://api.github.com/repos/lendingfront/testing-guidelines/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lendingfront/testing-guidelines/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lendingfront/testing-guidelines/teams","hooks_url":"https://api.github.com/repos/lendingfront/testing-guidelines/hooks","issue_events_url":"https://api.github.com/repos/lendingfront/testing-guidelines/issues/events{/number}","events_url":"https://api.github.com/repos/lendingfront/testing-guidelines/events","assignees_url":"https://api.github.com/repos/lendingfront/testing-guidelines/assignees{/user}","branches_url":"https://api.github.com/repos/lendingfront/testing-guidelines/branches{/branch}","tags_url":"https://api.github.com/repos/lendingfront/testing-guidelines/tags","blobs_url":"https://api.github.com/repos/lendingfront/testing-guidelines/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lendingfront/testing-guidelines/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lendingfront/testing-guidelines/git/refs{/sha}","trees_url":"https://api.github.com/repos/lendingfront/testing-guidelines/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lendingfront/testing-guidelines/statuses/{sha}","languages_url":"https://api.github.com/repos/lendingfront/testing-guidelines/languages","stargazers_url":"https://api.github.com/repos/lendingfront/testing-guidelines/stargazers","contributors_url":"https://api.github.com/repos/lendingfront/testing-guidelines/contributors","subscribers_url":"https://api.github.com/repos/lendingfront/testing-guidelines/subscribers","subscription_url":"https://api.github.com/repos/lendingfront/testing-guidelines/subscription","commits_url":"https://api.github.com/repos/lendingfront/testing-guidelines/commits{/sha}","git_commits_url":"https://api.github.com/repos/lendingfront/testing-guidelines/git/commits{/sha}","comments_url":"https://api.github.com/repos/lendingfront/testing-guidelines/comments{/number}","issue_comment_url":"https://api.github.com/repos/lendingfront/testing-guidelines/issues/comments{/number}","contents_url":"https://api.github.com/repos/lendingfront/testing-guidelines/contents/{+path}","compare_url":"https://api.github.com/repos/lendingfront/testing-guidelines/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lendingfront/testing-guidelines/merges","archive_url":"https://api.github.com/repos/lendingfront/testing-guidelines/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lendingfront/testing-guidelines/downloads","issues_url":"https://api.github.com/repos/lendingfront/testing-guidelines/issues{/number}","pulls_url":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls{/number}","milestones_url":"https://api.github.com/repos/lendingfront/testing-guidelines/milestones{/number}","notifications_url":"https://api.github.com/repos/lendingfront/testing-guidelines/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lendingfront/testing-guidelines/labels{/name}","releases_url":"https://api.github.com/repos/lendingfront/testing-guidelines/releases{/id}","deployments_url":"https://api.github.com/repos/lendingfront/testing-guidelines/deployments","created_at":"2016-06-04T19:55:34Z","updated_at":"2016-06-04T22:17:46Z","pushed_at":"2016-06-15T13:23:23Z","git_url":"git://github.com/lendingfront/testing-guidelines.git","ssh_url":"git@github.com:lendingfront/testing-guidelines.git","clone_url":"https://github.com/lendingfront/testing-guidelines.git","svn_url":"https://github.com/lendingfront/testing-guidelines","homepage":null,"size":14,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"lendingfront:master","ref":"master","sha":"22390dacc437ee93875710611fc7e5fedbf3438c","user":{"login":"lendingfront","id":13339895,"avatar_url":"https://avatars.githubusercontent.com/u/13339895?v=3","gravatar_id":"","url":"https://api.github.com/users/lendingfront","html_url":"https://github.com/lendingfront","followers_url":"https://api.github.com/users/lendingfront/followers","following_url":"https://api.github.com/users/lendingfront/following{/other_user}","gists_url":"https://api.github.com/users/lendingfront/gists{/gist_id}","starred_url":"https://api.github.com/users/lendingfront/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lendingfront/subscriptions","organizations_url":"https://api.github.com/users/lendingfront/orgs","repos_url":"https://api.github.com/users/lendingfront/repos","events_url":"https://api.github.com/users/lendingfront/events{/privacy}","received_events_url":"https://api.github.com/users/lendingfront/received_events","type":"Organization","site_admin":false},"repo":{"id":60427810,"name":"testing-guidelines","full_name":"lendingfront/testing-guidelines","owner":{"login":"lendingfront","id":13339895,"avatar_url":"https://avatars.githubusercontent.com/u/13339895?v=3","gravatar_id":"","url":"https://api.github.com/users/lendingfront","html_url":"https://github.com/lendingfront","followers_url":"https://api.github.com/users/lendingfront/followers","following_url":"https://api.github.com/users/lendingfront/following{/other_user}","gists_url":"https://api.github.com/users/lendingfront/gists{/gist_id}","starred_url":"https://api.github.com/users/lendingfront/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lendingfront/subscriptions","organizations_url":"https://api.github.com/users/lendingfront/orgs","repos_url":"https://api.github.com/users/lendingfront/repos","events_url":"https://api.github.com/users/lendingfront/events{/privacy}","received_events_url":"https://api.github.com/users/lendingfront/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lendingfront/testing-guidelines","description":"This document contains the guidelines when working with tests in LendingFront repositories","fork":false,"url":"https://api.github.com/repos/lendingfront/testing-guidelines","forks_url":"https://api.github.com/repos/lendingfront/testing-guidelines/forks","keys_url":"https://api.github.com/repos/lendingfront/testing-guidelines/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lendingfront/testing-guidelines/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lendingfront/testing-guidelines/teams","hooks_url":"https://api.github.com/repos/lendingfront/testing-guidelines/hooks","issue_events_url":"https://api.github.com/repos/lendingfront/testing-guidelines/issues/events{/number}","events_url":"https://api.github.com/repos/lendingfront/testing-guidelines/events","assignees_url":"https://api.github.com/repos/lendingfront/testing-guidelines/assignees{/user}","branches_url":"https://api.github.com/repos/lendingfront/testing-guidelines/branches{/branch}","tags_url":"https://api.github.com/repos/lendingfront/testing-guidelines/tags","blobs_url":"https://api.github.com/repos/lendingfront/testing-guidelines/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lendingfront/testing-guidelines/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lendingfront/testing-guidelines/git/refs{/sha}","trees_url":"https://api.github.com/repos/lendingfront/testing-guidelines/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lendingfront/testing-guidelines/statuses/{sha}","languages_url":"https://api.github.com/repos/lendingfront/testing-guidelines/languages","stargazers_url":"https://api.github.com/repos/lendingfront/testing-guidelines/stargazers","contributors_url":"https://api.github.com/repos/lendingfront/testing-guidelines/contributors","subscribers_url":"https://api.github.com/repos/lendingfront/testing-guidelines/subscribers","subscription_url":"https://api.github.com/repos/lendingfront/testing-guidelines/subscription","commits_url":"https://api.github.com/repos/lendingfront/testing-guidelines/commits{/sha}","git_commits_url":"https://api.github.com/repos/lendingfront/testing-guidelines/git/commits{/sha}","comments_url":"https://api.github.com/repos/lendingfront/testing-guidelines/comments{/number}","issue_comment_url":"https://api.github.com/repos/lendingfront/testing-guidelines/issues/comments{/number}","contents_url":"https://api.github.com/repos/lendingfront/testing-guidelines/contents/{+path}","compare_url":"https://api.github.com/repos/lendingfront/testing-guidelines/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lendingfront/testing-guidelines/merges","archive_url":"https://api.github.com/repos/lendingfront/testing-guidelines/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lendingfront/testing-guidelines/downloads","issues_url":"https://api.github.com/repos/lendingfront/testing-guidelines/issues{/number}","pulls_url":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls{/number}","milestones_url":"https://api.github.com/repos/lendingfront/testing-guidelines/milestones{/number}","notifications_url":"https://api.github.com/repos/lendingfront/testing-guidelines/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lendingfront/testing-guidelines/labels{/name}","releases_url":"https://api.github.com/repos/lendingfront/testing-guidelines/releases{/id}","deployments_url":"https://api.github.com/repos/lendingfront/testing-guidelines/deployments","created_at":"2016-06-04T19:55:34Z","updated_at":"2016-06-04T22:17:46Z","pushed_at":"2016-06-15T13:23:23Z","git_url":"git://github.com/lendingfront/testing-guidelines.git","ssh_url":"git@github.com:lendingfront/testing-guidelines.git","clone_url":"https://github.com/lendingfront/testing-guidelines.git","svn_url":"https://github.com/lendingfront/testing-guidelines","homepage":null,"size":14,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/1"},"html":{"href":"https://github.com/lendingfront/testing-guidelines/pull/1"},"issue":{"href":"https://api.github.com/repos/lendingfront/testing-guidelines/issues/1"},"comments":{"href":"https://api.github.com/repos/lendingfront/testing-guidelines/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lendingfront/testing-guidelines/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/lendingfront/testing-guidelines/statuses/33610ac5cf41998dae561992b01f7c24625828cf"}}}}
{"actor":{"display_login":"jhonjairoroa87"}}