{"action":"created","comment":{"url":"https://api.github.com/repos/ikalnitsky/holocron/pulls/comments/23127259","id":23127259,"diff_hunk":"@@ -0,0 +1,348 @@\n+# coding: utf-8\n+\"\"\"\n+    tests.ext.generators.test_blog\n+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+\n+    Tests Blog generator.\n+\n+    :copyright: (c) 2015 by the Holocron Team, see AUTHORS for details.\n+    :license: 3-clause BSD, see LICENSE for details.\n+\"\"\"\n+from unittest import mock\n+from datetime import datetime\n+from xml.dom import minidom\n+\n+from dooku.conf import Conf\n+from holocron.ext.generators import blog\n+from holocron.content import Page, Post, Static\n+from holocron.app import Holocron\n+\n+from tests import HolocronTestCase\n+\n+\n+class TestBlogGenerator(HolocronTestCase):\n+    \"\"\"\n+    Base class for tests where common data, generator instance is created and\n+    some helper methods are provided.\n+    \"\"\"\n+\n+    def setUp(self):\n+        \"\"\"\n+        Creates generator object and number of posts which will be further used\n+        in test sets.\n+        \"\"\"\n+\n+        self.blog = blog.Blog(Holocron(conf=Conf({\n+            'sitename': 'MyTestSite',\n+            'siteurl': 'www.mytest.com',\n+            'author': 'Tester',\n+\n+            'paths': {\n+                'output': 'path/to/output',\n+            },\n+\n+            'theme': {\n+                'navigation': [\n+                    ('feed', '/feed.xml'),\n+                ],\n+            },\n+\n+            'generators': {\n+\n+                'blog': {\n+                    'feed': {\n+                        'save_as': 'myfeed.xml',\n+                        'posts_number': 1,\n+                    },\n+\n+                    'index': {\n+                        'save_as': 'myindex.html',\n+                    },\n+\n+                    'tags': {\n+                        'output': 'mypath/tags/',\n+                        'save_as': 'myindex.html',\n+                    },\n+                },\n+            },\n+        })))\n+\n+        self.open_fn = 'holocron.ext.generators.blog.open'\n+\n+        self.date_early = datetime(2012, 2, 2)\n+        self.date_late = datetime(2014, 6, 12)\n+        self.date_moderate = datetime(2013, 4, 1)\n+\n+        self.date_early_updated = datetime(2012, 4, 4)\n+\n+        self.post_early = mock.Mock(\n+            spec=Post,\n+            created=self.date_early,\n+            created_local=self.date_early,\n+            updated_local=self.date_early_updated,\n+            tags=['testtag1'],\n+            title='MyTestPost',\n+            abs_url='http://www.testPost.com',\n+        )\n+\n+        self.post_moderate = mock.Mock(spec=Post, created=self.date_moderate)\n+        self.post_late = mock.Mock(spec=Post, created=self.date_late)\n+\n+    def _get_content(self, documents, test_function):\n+        \"\"\"\n+        This helper method mocks the open function and return the content\n+        passed as input to write function.\n+        \"\"\"\n+        with mock.patch(self.open_fn, mock.mock_open(), create=True) as mopen:\n+            test_function(documents)\n+\n+            content, = mopen().write.call_args[0]\n+            return content\n+\n+\n+class TestExtractPosts(TestBlogGenerator):\n+    \"\"\"\n+    Test extract posts function.\n+    \"\"\"\n+\n+    def setUp(self):\n+        TestBlogGenerator.setUp(self)\n+\n+        self.page = mock.Mock(spec=Page)\n+        self.static = mock.Mock(spec=Static)\n+\n+    def test_extract_posts_with_empty_list(self):\n+        \"\"\"\n+        Test extract_posts should process correctly empty lists.\n+        \"\"\"\n+        documents = self.blog.extract_posts([])\n+\n+        self.assertEqual(len(documents), 0)\n+\n+    def test_extract_posts_with_all_doc_types(self):\n+        \"\"\"\n+        The extract_posts has to separate posts from all other types\n+        of dicuments passed as input.","path":"tests/ext/generators/test_blog.py","position":125,"original_position":125,"commit_id":"dfead081b60109c1a45d580f4992af3a110686d7","original_commit_id":"dfead081b60109c1a45d580f4992af3a110686d7","user":{"login":"ikalnitsky","id":166626,"avatar_url":"https://avatars.githubusercontent.com/u/166626?v=3","gravatar_id":"","url":"https://api.github.com/users/ikalnitsky","html_url":"https://github.com/ikalnitsky","followers_url":"https://api.github.com/users/ikalnitsky/followers","following_url":"https://api.github.com/users/ikalnitsky/following{/other_user}","gists_url":"https://api.github.com/users/ikalnitsky/gists{/gist_id}","starred_url":"https://api.github.com/users/ikalnitsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikalnitsky/subscriptions","organizations_url":"https://api.github.com/users/ikalnitsky/orgs","repos_url":"https://api.github.com/users/ikalnitsky/repos","events_url":"https://api.github.com/users/ikalnitsky/events{/privacy}","received_events_url":"https://api.github.com/users/ikalnitsky/received_events","type":"User","site_admin":false},"body":"typo: d`i`cuments.","created_at":"2015-01-17T18:19:44Z","updated_at":"2015-01-17T18:19:44Z","html_url":"https://github.com/ikalnitsky/holocron/pull/76#discussion_r23127259","pull_request_url":"https://api.github.com/repos/ikalnitsky/holocron/pulls/76","_links":{"self":{"href":"https://api.github.com/repos/ikalnitsky/holocron/pulls/comments/23127259"},"html":{"href":"https://github.com/ikalnitsky/holocron/pull/76#discussion_r23127259"},"pull_request":{"href":"https://api.github.com/repos/ikalnitsky/holocron/pulls/76"}}},"pull_request":{"url":"https://api.github.com/repos/ikalnitsky/holocron/pulls/76","id":27164422,"html_url":"https://github.com/ikalnitsky/holocron/pull/76","diff_url":"https://github.com/ikalnitsky/holocron/pull/76.diff","patch_url":"https://github.com/ikalnitsky/holocron/pull/76.patch","issue_url":"https://api.github.com/repos/ikalnitsky/holocron/issues/76","number":76,"state":"open","locked":false,"title":"Add test for the blog generator","user":{"login":"PropheticBird","id":921482,"avatar_url":"https://avatars.githubusercontent.com/u/921482?v=3","gravatar_id":"","url":"https://api.github.com/users/PropheticBird","html_url":"https://github.com/PropheticBird","followers_url":"https://api.github.com/users/PropheticBird/followers","following_url":"https://api.github.com/users/PropheticBird/following{/other_user}","gists_url":"https://api.github.com/users/PropheticBird/gists{/gist_id}","starred_url":"https://api.github.com/users/PropheticBird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PropheticBird/subscriptions","organizations_url":"https://api.github.com/users/PropheticBird/orgs","repos_url":"https://api.github.com/users/PropheticBird/repos","events_url":"https://api.github.com/users/PropheticBird/events{/privacy}","received_events_url":"https://api.github.com/users/PropheticBird/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-11T16:01:02Z","updated_at":"2015-01-17T18:19:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d0663228cfb6adb3cf17eca53e101417ef26dc07","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ikalnitsky/holocron/pulls/76/commits","review_comments_url":"https://api.github.com/repos/ikalnitsky/holocron/pulls/76/comments","review_comment_url":"https://api.github.com/repos/ikalnitsky/holocron/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ikalnitsky/holocron/issues/76/comments","statuses_url":"https://api.github.com/repos/ikalnitsky/holocron/statuses/dfead081b60109c1a45d580f4992af3a110686d7","head":{"label":"ikalnitsky:blog_tests","ref":"blog_tests","sha":"dfead081b60109c1a45d580f4992af3a110686d7","user":{"login":"ikalnitsky","id":166626,"avatar_url":"https://avatars.githubusercontent.com/u/166626?v=3","gravatar_id":"","url":"https://api.github.com/users/ikalnitsky","html_url":"https://github.com/ikalnitsky","followers_url":"https://api.github.com/users/ikalnitsky/followers","following_url":"https://api.github.com/users/ikalnitsky/following{/other_user}","gists_url":"https://api.github.com/users/ikalnitsky/gists{/gist_id}","starred_url":"https://api.github.com/users/ikalnitsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikalnitsky/subscriptions","organizations_url":"https://api.github.com/users/ikalnitsky/orgs","repos_url":"https://api.github.com/users/ikalnitsky/repos","events_url":"https://api.github.com/users/ikalnitsky/events{/privacy}","received_events_url":"https://api.github.com/users/ikalnitsky/received_events","type":"User","site_admin":false},"repo":{"id":19894683,"name":"holocron","full_name":"ikalnitsky/holocron","owner":{"login":"ikalnitsky","id":166626,"avatar_url":"https://avatars.githubusercontent.com/u/166626?v=3","gravatar_id":"","url":"https://api.github.com/users/ikalnitsky","html_url":"https://github.com/ikalnitsky","followers_url":"https://api.github.com/users/ikalnitsky/followers","following_url":"https://api.github.com/users/ikalnitsky/following{/other_user}","gists_url":"https://api.github.com/users/ikalnitsky/gists{/gist_id}","starred_url":"https://api.github.com/users/ikalnitsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikalnitsky/subscriptions","organizations_url":"https://api.github.com/users/ikalnitsky/orgs","repos_url":"https://api.github.com/users/ikalnitsky/repos","events_url":"https://api.github.com/users/ikalnitsky/events{/privacy}","received_events_url":"https://api.github.com/users/ikalnitsky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ikalnitsky/holocron","description":"Holocron is an easy and lightweight static blog generator, based on markup text and Jinja2 templates.","fork":false,"url":"https://api.github.com/repos/ikalnitsky/holocron","forks_url":"https://api.github.com/repos/ikalnitsky/holocron/forks","keys_url":"https://api.github.com/repos/ikalnitsky/holocron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ikalnitsky/holocron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ikalnitsky/holocron/teams","hooks_url":"https://api.github.com/repos/ikalnitsky/holocron/hooks","issue_events_url":"https://api.github.com/repos/ikalnitsky/holocron/issues/events{/number}","events_url":"https://api.github.com/repos/ikalnitsky/holocron/events","assignees_url":"https://api.github.com/repos/ikalnitsky/holocron/assignees{/user}","branches_url":"https://api.github.com/repos/ikalnitsky/holocron/branches{/branch}","tags_url":"https://api.github.com/repos/ikalnitsky/holocron/tags","blobs_url":"https://api.github.com/repos/ikalnitsky/holocron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ikalnitsky/holocron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ikalnitsky/holocron/git/refs{/sha}","trees_url":"https://api.github.com/repos/ikalnitsky/holocron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ikalnitsky/holocron/statuses/{sha}","languages_url":"https://api.github.com/repos/ikalnitsky/holocron/languages","stargazers_url":"https://api.github.com/repos/ikalnitsky/holocron/stargazers","contributors_url":"https://api.github.com/repos/ikalnitsky/holocron/contributors","subscribers_url":"https://api.github.com/repos/ikalnitsky/holocron/subscribers","subscription_url":"https://api.github.com/repos/ikalnitsky/holocron/subscription","commits_url":"https://api.github.com/repos/ikalnitsky/holocron/commits{/sha}","git_commits_url":"https://api.github.com/repos/ikalnitsky/holocron/git/commits{/sha}","comments_url":"https://api.github.com/repos/ikalnitsky/holocron/comments{/number}","issue_comment_url":"https://api.github.com/repos/ikalnitsky/holocron/issues/comments/{number}","contents_url":"https://api.github.com/repos/ikalnitsky/holocron/contents/{+path}","compare_url":"https://api.github.com/repos/ikalnitsky/holocron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ikalnitsky/holocron/merges","archive_url":"https://api.github.com/repos/ikalnitsky/holocron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ikalnitsky/holocron/downloads","issues_url":"https://api.github.com/repos/ikalnitsky/holocron/issues{/number}","pulls_url":"https://api.github.com/repos/ikalnitsky/holocron/pulls{/number}","milestones_url":"https://api.github.com/repos/ikalnitsky/holocron/milestones{/number}","notifications_url":"https://api.github.com/repos/ikalnitsky/holocron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ikalnitsky/holocron/labels{/name}","releases_url":"https://api.github.com/repos/ikalnitsky/holocron/releases{/id}","created_at":"2014-05-17T19:40:22Z","updated_at":"2015-01-15T19:06:39Z","pushed_at":"2015-01-16T23:18:46Z","git_url":"git://github.com/ikalnitsky/holocron.git","ssh_url":"git@github.com:ikalnitsky/holocron.git","clone_url":"https://github.com/ikalnitsky/holocron.git","svn_url":"https://github.com/ikalnitsky/holocron","homepage":null,"size":1094,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":12,"forks":1,"open_issues":12,"watchers":2,"default_branch":"master"}},"base":{"label":"ikalnitsky:master","ref":"master","sha":"20be2243935bfaef2d64bcf30c2c125dd40d40b0","user":{"login":"ikalnitsky","id":166626,"avatar_url":"https://avatars.githubusercontent.com/u/166626?v=3","gravatar_id":"","url":"https://api.github.com/users/ikalnitsky","html_url":"https://github.com/ikalnitsky","followers_url":"https://api.github.com/users/ikalnitsky/followers","following_url":"https://api.github.com/users/ikalnitsky/following{/other_user}","gists_url":"https://api.github.com/users/ikalnitsky/gists{/gist_id}","starred_url":"https://api.github.com/users/ikalnitsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikalnitsky/subscriptions","organizations_url":"https://api.github.com/users/ikalnitsky/orgs","repos_url":"https://api.github.com/users/ikalnitsky/repos","events_url":"https://api.github.com/users/ikalnitsky/events{/privacy}","received_events_url":"https://api.github.com/users/ikalnitsky/received_events","type":"User","site_admin":false},"repo":{"id":19894683,"name":"holocron","full_name":"ikalnitsky/holocron","owner":{"login":"ikalnitsky","id":166626,"avatar_url":"https://avatars.githubusercontent.com/u/166626?v=3","gravatar_id":"","url":"https://api.github.com/users/ikalnitsky","html_url":"https://github.com/ikalnitsky","followers_url":"https://api.github.com/users/ikalnitsky/followers","following_url":"https://api.github.com/users/ikalnitsky/following{/other_user}","gists_url":"https://api.github.com/users/ikalnitsky/gists{/gist_id}","starred_url":"https://api.github.com/users/ikalnitsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikalnitsky/subscriptions","organizations_url":"https://api.github.com/users/ikalnitsky/orgs","repos_url":"https://api.github.com/users/ikalnitsky/repos","events_url":"https://api.github.com/users/ikalnitsky/events{/privacy}","received_events_url":"https://api.github.com/users/ikalnitsky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ikalnitsky/holocron","description":"Holocron is an easy and lightweight static blog generator, based on markup text and Jinja2 templates.","fork":false,"url":"https://api.github.com/repos/ikalnitsky/holocron","forks_url":"https://api.github.com/repos/ikalnitsky/holocron/forks","keys_url":"https://api.github.com/repos/ikalnitsky/holocron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ikalnitsky/holocron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ikalnitsky/holocron/teams","hooks_url":"https://api.github.com/repos/ikalnitsky/holocron/hooks","issue_events_url":"https://api.github.com/repos/ikalnitsky/holocron/issues/events{/number}","events_url":"https://api.github.com/repos/ikalnitsky/holocron/events","assignees_url":"https://api.github.com/repos/ikalnitsky/holocron/assignees{/user}","branches_url":"https://api.github.com/repos/ikalnitsky/holocron/branches{/branch}","tags_url":"https://api.github.com/repos/ikalnitsky/holocron/tags","blobs_url":"https://api.github.com/repos/ikalnitsky/holocron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ikalnitsky/holocron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ikalnitsky/holocron/git/refs{/sha}","trees_url":"https://api.github.com/repos/ikalnitsky/holocron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ikalnitsky/holocron/statuses/{sha}","languages_url":"https://api.github.com/repos/ikalnitsky/holocron/languages","stargazers_url":"https://api.github.com/repos/ikalnitsky/holocron/stargazers","contributors_url":"https://api.github.com/repos/ikalnitsky/holocron/contributors","subscribers_url":"https://api.github.com/repos/ikalnitsky/holocron/subscribers","subscription_url":"https://api.github.com/repos/ikalnitsky/holocron/subscription","commits_url":"https://api.github.com/repos/ikalnitsky/holocron/commits{/sha}","git_commits_url":"https://api.github.com/repos/ikalnitsky/holocron/git/commits{/sha}","comments_url":"https://api.github.com/repos/ikalnitsky/holocron/comments{/number}","issue_comment_url":"https://api.github.com/repos/ikalnitsky/holocron/issues/comments/{number}","contents_url":"https://api.github.com/repos/ikalnitsky/holocron/contents/{+path}","compare_url":"https://api.github.com/repos/ikalnitsky/holocron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ikalnitsky/holocron/merges","archive_url":"https://api.github.com/repos/ikalnitsky/holocron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ikalnitsky/holocron/downloads","issues_url":"https://api.github.com/repos/ikalnitsky/holocron/issues{/number}","pulls_url":"https://api.github.com/repos/ikalnitsky/holocron/pulls{/number}","milestones_url":"https://api.github.com/repos/ikalnitsky/holocron/milestones{/number}","notifications_url":"https://api.github.com/repos/ikalnitsky/holocron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ikalnitsky/holocron/labels{/name}","releases_url":"https://api.github.com/repos/ikalnitsky/holocron/releases{/id}","created_at":"2014-05-17T19:40:22Z","updated_at":"2015-01-15T19:06:39Z","pushed_at":"2015-01-16T23:18:46Z","git_url":"git://github.com/ikalnitsky/holocron.git","ssh_url":"git@github.com:ikalnitsky/holocron.git","clone_url":"https://github.com/ikalnitsky/holocron.git","svn_url":"https://github.com/ikalnitsky/holocron","homepage":null,"size":1094,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":12,"forks":1,"open_issues":12,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ikalnitsky/holocron/pulls/76"},"html":{"href":"https://github.com/ikalnitsky/holocron/pull/76"},"issue":{"href":"https://api.github.com/repos/ikalnitsky/holocron/issues/76"},"comments":{"href":"https://api.github.com/repos/ikalnitsky/holocron/issues/76/comments"},"review_comments":{"href":"https://api.github.com/repos/ikalnitsky/holocron/pulls/76/comments"},"review_comment":{"href":"https://api.github.com/repos/ikalnitsky/holocron/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ikalnitsky/holocron/pulls/76/commits"},"statuses":{"href":"https://api.github.com/repos/ikalnitsky/holocron/statuses/dfead081b60109c1a45d580f4992af3a110686d7"}}}}