mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Added tests (ab)using the HTML reader a bit
There seems to be no way to test this generically since we need to produce a valid document with meta information to be able to compare, hence I used the lightest reader out there to do the parsing of the samples.
This commit is contained in:
parent
b1b0d0b0ab
commit
db0639d3a7
5 changed files with 104 additions and 0 deletions
15
pelican/tests/content/article_with_metadata_explicit_date_implicit_modified.html
vendored
Normal file
15
pelican/tests/content/article_with_metadata_explicit_date_implicit_modified.html
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>This is a super article !</title>
|
||||
<meta name="tags" content="foo, bar, foobar" />
|
||||
<meta name="date" content="2010-12-02 10:14" />
|
||||
<meta name="category" content="yeah" />
|
||||
<meta name="author" content="Alexis Métaireau" />
|
||||
<meta name="summary" content="Summary and stuff" />
|
||||
<meta name="custom_field" content="http://notmyidea.org" />
|
||||
</head>
|
||||
<body>
|
||||
Multi-line metadata should be supported
|
||||
as well as <strong>inline markup</strong>.
|
||||
</body>
|
||||
</html>
|
||||
16
pelican/tests/content/article_with_metadata_explicit_dates.html
vendored
Normal file
16
pelican/tests/content/article_with_metadata_explicit_dates.html
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>This is a super article !</title>
|
||||
<meta name="tags" content="foo, bar, foobar" />
|
||||
<meta name="date" content="2010-12-02 10:14" />
|
||||
<meta name="modified" content="2010-12-31 23:59" />
|
||||
<meta name="category" content="yeah" />
|
||||
<meta name="author" content="Alexis Métaireau" />
|
||||
<meta name="summary" content="Summary and stuff" />
|
||||
<meta name="custom_field" content="http://notmyidea.org" />
|
||||
</head>
|
||||
<body>
|
||||
Multi-line metadata should be supported
|
||||
as well as <strong>inline markup</strong>.
|
||||
</body>
|
||||
</html>
|
||||
15
pelican/tests/content/article_with_metadata_implicit_date_explicit_modified.html
vendored
Normal file
15
pelican/tests/content/article_with_metadata_implicit_date_explicit_modified.html
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>This is a super article !</title>
|
||||
<meta name="tags" content="foo, bar, foobar" />
|
||||
<meta name="modified" content="2010-12-02 10:14" />
|
||||
<meta name="category" content="yeah" />
|
||||
<meta name="author" content="Alexis Métaireau" />
|
||||
<meta name="summary" content="Summary and stuff" />
|
||||
<meta name="custom_field" content="http://notmyidea.org" />
|
||||
</head>
|
||||
<body>
|
||||
Multi-line metadata should be supported
|
||||
as well as <strong>inline markup</strong>.
|
||||
</body>
|
||||
</html>
|
||||
14
pelican/tests/content/article_with_metadata_implicit_dates.html
vendored
Normal file
14
pelican/tests/content/article_with_metadata_implicit_dates.html
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>This is a super article !</title>
|
||||
<meta name="tags" content="foo, bar, foobar" />
|
||||
<meta name="category" content="yeah" />
|
||||
<meta name="author" content="Alexis Métaireau" />
|
||||
<meta name="summary" content="Summary and stuff" />
|
||||
<meta name="custom_field" content="http://notmyidea.org" />
|
||||
</head>
|
||||
<body>
|
||||
Multi-line metadata should be supported
|
||||
as well as <strong>inline markup</strong>.
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -81,6 +81,50 @@ class DefaultReaderTest(ReaderTest):
|
|||
with self.assertRaises(TypeError):
|
||||
self.read_file(path='article_with_metadata.unknownextension')
|
||||
|
||||
def test_readfile_path_metadata_implicit_dates(self):
|
||||
test_file = 'article_with_metadata_implicit_dates.html'
|
||||
page = self.read_file(path=test_file, DEFAULT_DATE='fs')
|
||||
expected = {
|
||||
'date': SafeDatetime.fromtimestamp(
|
||||
os.stat(_path(test_file)).st_mtime),
|
||||
'modified': SafeDatetime.fromtimestamp(
|
||||
os.stat(_path(test_file)).st_mtime)
|
||||
}
|
||||
|
||||
self.assertDictHasSubset(page.metadata, expected)
|
||||
|
||||
def test_readfile_path_metadata_explicit_dates(self):
|
||||
test_file = 'article_with_metadata_explicit_dates.html'
|
||||
page = self.read_file(path=test_file, DEFAULT_DATE='fs')
|
||||
expected = {
|
||||
'date': SafeDatetime(2010, 12, 2, 10, 14),
|
||||
'modified': SafeDatetime(2010, 12, 31, 23, 59)
|
||||
}
|
||||
|
||||
self.assertDictHasSubset(page.metadata, expected)
|
||||
|
||||
def test_readfile_path_metadata_implicit_date_explicit_modified(self):
|
||||
test_file = 'article_with_metadata_implicit_date_explicit_modified.html'
|
||||
page = self.read_file(path=test_file, DEFAULT_DATE='fs')
|
||||
expected = {
|
||||
'date': SafeDatetime.fromtimestamp(
|
||||
os.stat(_path(test_file)).st_mtime),
|
||||
'modified': SafeDatetime(2010, 12, 2, 10, 14),
|
||||
}
|
||||
|
||||
self.assertDictHasSubset(page.metadata, expected)
|
||||
|
||||
def test_readfile_path_metadata_explicit_date_implicit_modified(self):
|
||||
test_file = 'article_with_metadata_explicit_date_implicit_modified.html'
|
||||
page = self.read_file(path=test_file, DEFAULT_DATE='fs')
|
||||
expected = {
|
||||
'date': SafeDatetime(2010, 12, 2, 10, 14),
|
||||
'modified': SafeDatetime.fromtimestamp(
|
||||
os.stat(_path(test_file)).st_mtime)
|
||||
}
|
||||
|
||||
self.assertDictHasSubset(page.metadata, expected)
|
||||
|
||||
@unittest.skipUnless(patch, 'Needs Mock module')
|
||||
def test_find_empty_alt(self):
|
||||
with patch('pelican.readers.logger') as log_mock:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue