{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/127036481","pull_request_review_id":49577317,"id":127036481,"diff_hunk":"@@ -1,56 +1,70 @@\n-from nose.tools import *  # flake8: noqa\n+import pytest\n \n from api.base.settings.defaults import API_BASE\n-from tests.base import ApiTestCase\n from osf_tests.factories import (\n     ProjectFactory,\n     AuthUserFactory,\n     RegistrationFactory\n )\n \n+@pytest.mark.django_db\n+class TestLogEmbeds:\n \n-class TestLogEmbeds(ApiTestCase):\n+    @pytest.fixture()\n+    def user(self):\n+        return AuthUserFactory()\n \n+    @pytest.fixture()\n+    def project(self, user):\n+        return ProjectFactory(is_public=True, creator=user)\n \n-    def setUp(self):\n-        super(TestLogEmbeds, self).setUp()\n+    @pytest.fixture()\n+    def registration(self, user, project):\n+        return RegistrationFactory(project=project, creator=user, is_public=True)\n \n-        self.user = AuthUserFactory()\n-        self.project = ProjectFactory(is_public=True, creator=self.user)\n-        self.registration = RegistrationFactory(project=self.project, creator=self.user, is_public=True)\n+    @pytest.fixture()\n+    def registration_log(self, registration):\n+        return registration.logs.order_by('date').first()\n \n-        self.first_reg_log = self.registration.logs.order_by('date').first()\n+    @pytest.fixture()\n+    def make_url_registration_log(self, registration_log):\n+        def url_registration_log(type_embed):\n+            return '/{}logs/{}/?embed={}'.format(API_BASE, registration_log._id, type_embed)\n+        return url_registration_log\n \n-    def test_embed_original_node(self):\n-        registration_log_url = '/{}logs/{}/?embed=original_node'.format(API_BASE, self.first_reg_log._id)\n \n-        res = self.app.get(registration_log_url, auth=self.user.auth)\n-        assert_equal(res.status_code, 200)\n-        assert_equal(res.json['data']['attributes']['action'], 'project_created')\n+    def test_log_embed_types(self, app, registration_log, make_url_registration_log, user, project, registration):\n+\n+        #test_embed_original_node\n+        url_registration_log = make_url_registration_log(type_embed='original_node')\n+\n+        res = app.get(url_registration_log, auth=user.auth)\n+        assert res.status_code == 200\n+        assert res.json['data']['attributes']['action'] == 'project_created'\n         embeds = res.json['data']['embeds']['original_node']\n-        assert_equal(embeds['data']['id'], self.project._id)\n+        assert embeds['data']['id'] == project._id\n \n-    def test_embed_node(self):\n-        registration_log_url = '/{}logs/{}/?embed=node'.format(API_BASE, self.first_reg_log._id)\n+        #test_embed_node\n+        url_registration_log = make_url_registration_log(type_embed='node')\n \n-        res = self.app.get(registration_log_url, auth=self.user.auth)\n-        assert_equal(res.status_code, 200)\n-        assert_equal(res.json['data']['attributes']['action'], 'project_created')\n+        res = app.get(url_registration_log, auth=user.auth)\n+        assert res.status_code == 200\n+        assert res.json['data']['attributes']['action'] == 'project_created'\n         embeds = res.json['data']['embeds']['node']\n-        assert_equal(embeds['data']['id'], self.registration._id)\n+        assert embeds['data']['id'] == registration._id\n \n-    def test_embed_user(self):\n-        registration_log_url = '/{}logs/{}/?embed=user'.format(API_BASE, self.first_reg_log._id)\n+        #test_embed_user\n+        url_registration_log = make_url_registration_log(type_embed='user')\n \n-        res = self.app.get(registration_log_url, auth=self.user.auth)\n-        assert_equal(res.status_code, 200)\n-        assert_equal(res.json['data']['attributes']['action'], 'project_created')\n+        res = app.get(url_registration_log, auth=user.auth)\n+        assert res.status_code == 200\n+        assert res.json['data']['attributes']['action'] == 'project_created'\n         embeds = res.json['data']['embeds']['user']\n-        assert_equal(embeds['data']['id'], self.user._id)\n+        assert embeds['data']['id'] == user._id\n \n-    def test_embed_attributes_not_relationships(self):\n-        url = '/{}logs/{}/?embed=action'.format(API_BASE, self.first_reg_log._id)\n+        #test_embed_attributes_not_relationships\n+        url_registration_log = make_url_registration_log(type_embed='action')\n \n-        res = self.app.get(url, expect_errors=True)\n-        assert_equal(res.status_code, 400)\n-        assert_equal(res.json['errors'][0]['detail'], \"The following fields are not embeddable: action\")\n+        res = app.get(url_registration_log, expect_errors=True)\n+        assert res.status_code == 400\n+        assert res.json['errors'][0]['detail'] == \"The following fields are not embeddable: action\"","path":"api_tests/logs/views/test_log_embeds.py","position":102,"original_position":102,"commit_id":"7ebd859a2d484e5bfd26fb1d7e6884aaf4ce90ff","original_commit_id":"7ebd859a2d484e5bfd26fb1d7e6884aaf4ce90ff","user":{"login":"Nesiehr","id":7832815,"avatar_url":"https://avatars1.githubusercontent.com/u/7832815?v=3","gravatar_id":"","url":"https://api.github.com/users/Nesiehr","html_url":"https://github.com/Nesiehr","followers_url":"https://api.github.com/users/Nesiehr/followers","following_url":"https://api.github.com/users/Nesiehr/following{/other_user}","gists_url":"https://api.github.com/users/Nesiehr/gists{/gist_id}","starred_url":"https://api.github.com/users/Nesiehr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nesiehr/subscriptions","organizations_url":"https://api.github.com/users/Nesiehr/orgs","repos_url":"https://api.github.com/users/Nesiehr/repos","events_url":"https://api.github.com/users/Nesiehr/events{/privacy}","received_events_url":"https://api.github.com/users/Nesiehr/received_events","type":"User","site_admin":false},"body":"use single quotes","created_at":"2017-07-12T18:35:18Z","updated_at":"2017-07-12T18:39:35Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/7440#discussion_r127036481","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7440","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/127036481"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/7440#discussion_r127036481"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7440"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7440","id":129752586,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/7440","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/7440.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/7440.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7440","number":7440,"state":"open","locked":false,"title":"[Feature] api_tests/logs to pytest [OSF-8239]","user":{"login":"fabmiz","id":4511563,"avatar_url":"https://avatars1.githubusercontent.com/u/4511563?v=3","gravatar_id":"","url":"https://api.github.com/users/fabmiz","html_url":"https://github.com/fabmiz","followers_url":"https://api.github.com/users/fabmiz/followers","following_url":"https://api.github.com/users/fabmiz/following{/other_user}","gists_url":"https://api.github.com/users/fabmiz/gists{/gist_id}","starred_url":"https://api.github.com/users/fabmiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabmiz/subscriptions","organizations_url":"https://api.github.com/users/fabmiz/orgs","repos_url":"https://api.github.com/users/fabmiz/repos","events_url":"https://api.github.com/users/fabmiz/events{/privacy}","received_events_url":"https://api.github.com/users/fabmiz/received_events","type":"User","site_admin":false},"body":"## Purpose\r\n\r\nConvert api_tests/logs from nose to pytest\r\nfor improved performance, readability, maintenance.\r\n\r\n## Changes\r\n\r\nRe-write tests for logs `detail`, `params` and `embeds` api endpoints\r\nwith pytest.\r\n\r\n## Ticket\r\n\r\n[OSF-8239](https://openscience.atlassian.net/browse/OSF-8239)\r\n","created_at":"2017-07-10T19:14:27Z","updated_at":"2017-07-12T18:39:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc440ffd74e8a965572ef5a355cccb61c5e956e3","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7440/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7440/comments","review_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7440/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/7ebd859a2d484e5bfd26fb1d7e6884aaf4ce90ff","head":{"label":"fabmiz:feature/pytests/logs","ref":"feature/pytests/logs","sha":"7ebd859a2d484e5bfd26fb1d7e6884aaf4ce90ff","user":{"login":"fabmiz","id":4511563,"avatar_url":"https://avatars1.githubusercontent.com/u/4511563?v=3","gravatar_id":"","url":"https://api.github.com/users/fabmiz","html_url":"https://github.com/fabmiz","followers_url":"https://api.github.com/users/fabmiz/followers","following_url":"https://api.github.com/users/fabmiz/following{/other_user}","gists_url":"https://api.github.com/users/fabmiz/gists{/gist_id}","starred_url":"https://api.github.com/users/fabmiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabmiz/subscriptions","organizations_url":"https://api.github.com/users/fabmiz/orgs","repos_url":"https://api.github.com/users/fabmiz/repos","events_url":"https://api.github.com/users/fabmiz/events{/privacy}","received_events_url":"https://api.github.com/users/fabmiz/received_events","type":"User","site_admin":false},"repo":{"id":84862157,"name":"osf.io","full_name":"fabmiz/osf.io","owner":{"login":"fabmiz","id":4511563,"avatar_url":"https://avatars1.githubusercontent.com/u/4511563?v=3","gravatar_id":"","url":"https://api.github.com/users/fabmiz","html_url":"https://github.com/fabmiz","followers_url":"https://api.github.com/users/fabmiz/followers","following_url":"https://api.github.com/users/fabmiz/following{/other_user}","gists_url":"https://api.github.com/users/fabmiz/gists{/gist_id}","starred_url":"https://api.github.com/users/fabmiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabmiz/subscriptions","organizations_url":"https://api.github.com/users/fabmiz/orgs","repos_url":"https://api.github.com/users/fabmiz/repos","events_url":"https://api.github.com/users/fabmiz/events{/privacy}","received_events_url":"https://api.github.com/users/fabmiz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fabmiz/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/fabmiz/osf.io","forks_url":"https://api.github.com/repos/fabmiz/osf.io/forks","keys_url":"https://api.github.com/repos/fabmiz/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabmiz/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabmiz/osf.io/teams","hooks_url":"https://api.github.com/repos/fabmiz/osf.io/hooks","issue_events_url":"https://api.github.com/repos/fabmiz/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/fabmiz/osf.io/events","assignees_url":"https://api.github.com/repos/fabmiz/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/fabmiz/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/fabmiz/osf.io/tags","blobs_url":"https://api.github.com/repos/fabmiz/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabmiz/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabmiz/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabmiz/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabmiz/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/fabmiz/osf.io/languages","stargazers_url":"https://api.github.com/repos/fabmiz/osf.io/stargazers","contributors_url":"https://api.github.com/repos/fabmiz/osf.io/contributors","subscribers_url":"https://api.github.com/repos/fabmiz/osf.io/subscribers","subscription_url":"https://api.github.com/repos/fabmiz/osf.io/subscription","commits_url":"https://api.github.com/repos/fabmiz/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabmiz/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabmiz/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabmiz/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/fabmiz/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/fabmiz/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabmiz/osf.io/merges","archive_url":"https://api.github.com/repos/fabmiz/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabmiz/osf.io/downloads","issues_url":"https://api.github.com/repos/fabmiz/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/fabmiz/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/fabmiz/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/fabmiz/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabmiz/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/fabmiz/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/fabmiz/osf.io/deployments","created_at":"2017-03-13T18:42:50Z","updated_at":"2017-03-13T18:43:01Z","pushed_at":"2017-07-12T17:21:59Z","git_url":"git://github.com/fabmiz/osf.io.git","ssh_url":"git@github.com:fabmiz/osf.io.git","clone_url":"https://github.com/fabmiz/osf.io.git","svn_url":"https://github.com/fabmiz/osf.io","homepage":"https://osf.io","size":155820,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"83060e0b0a5a5c9d9f5670505b8ecd6dab3f01d0","user":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars2.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"repo":{"id":10199599,"name":"osf.io","full_name":"CenterForOpenScience/osf.io","owner":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars2.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CenterForOpenScience/osf.io","description":"Facilitating Open Science","fork":false,"url":"https://api.github.com/repos/CenterForOpenScience/osf.io","forks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/forks","keys_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/teams","hooks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/hooks","issue_events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/events","assignees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/tags","blobs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/languages","stargazers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/stargazers","contributors_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contributors","subscribers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscribers","subscription_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscription","commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/merges","archive_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/downloads","issues_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/deployments","created_at":"2013-05-21T15:53:37Z","updated_at":"2017-07-11T00:41:03Z","pushed_at":"2017-07-12T17:24:12Z","git_url":"git://github.com/CenterForOpenScience/osf.io.git","ssh_url":"git@github.com:CenterForOpenScience/osf.io.git","clone_url":"https://github.com/CenterForOpenScience/osf.io.git","svn_url":"https://github.com/CenterForOpenScience/osf.io","homepage":"https://osf.io","size":156157,"stargazers_count":348,"watchers_count":348,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":228,"mirror_url":null,"open_issues_count":232,"forks":228,"open_issues":232,"watchers":348,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7440"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/7440"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7440"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7440/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7440/comments"},"review_comment":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7440/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/7ebd859a2d484e5bfd26fb1d7e6884aaf4ce90ff"}}}}
{"actor":{"display_login":"Nesiehr"}}