Exemplo n.º 1
0
 def test_extracts_summary_from_summary_fallback(self, valid_data_partial):
     """Should extract summary from summary as fallback."""
     valid_data_partial.description = "Test description"
     valid_data_partial.summary = "Test summary"
     parser = EntryParser(valid_data_partial)
     data = parser.extract()
     assert data["summary"] == "Test summary"
Exemplo n.º 2
0
 def test_load_replaces_entry_data(self, mocker):
     """Should replace existing entry_data on call to load."""
     mocked_data_foo = mocker.MagicMock()
     mocked_data_bar = mocker.MagicMock()
     parser = EntryParser(mocked_data_foo)
     parser.load(mocked_data_bar)
     assert parser.entry_data == mocked_data_bar
Exemplo n.º 3
0
 def test_extracts_content_from_fallback_description(
         self, valid_data_partial):
     """Should use description if no content available."""
     valid_data_partial.description = "Test description"
     valid_data_partial.summary = "Test summary"
     parser = EntryParser(valid_data_partial)
     data = parser.extract()
     assert data["content"] == "Test description"
Exemplo n.º 4
0
 def test_raises_if_no_summary_field_found(self, valid_data_partial):
     """Should raise if no appropriate summary field is present."""
     valid_data_partial.description = "Test description"
     with pytest.raises(ContentErrorException):
         parser = EntryParser(valid_data_partial)
         parser.extract()
Exemplo n.º 5
0
 def test_extracts_summary_from_summary_detail(self, valid_data):
     """Should extract summary from summary detail if present."""
     parser = EntryParser(valid_data)
     data = parser.extract()
     assert data["summary"] == "Test summary detail"
Exemplo n.º 6
0
 def test_raises_if_no_content_field_found(self, valid_data_partial):
     """Should raise if no appropriate content field is present."""
     with pytest.raises(ContentErrorException):
         parser = EntryParser(valid_data_partial)
         parser.extract()
Exemplo n.º 7
0
 def test_extracts_content_from_content_field(self, valid_data):
     """Should extract content from content field (over description)."""
     parser = EntryParser(valid_data)
     data = parser.extract()
     assert data["content"] == "Test content"
Exemplo n.º 8
0
 def test_extracts_guid(self, valid_data):
     """Should extract the guid from the loaded entry_data."""
     parser = EntryParser(valid_data)
     data = parser.extract()
     assert data["guid"] == "testguid"
Exemplo n.º 9
0
 def test_extracts_link(self, valid_data):
     """Should extract the link from the loaded entry_data."""
     parser = EntryParser(valid_data)
     data = parser.extract()
     assert data["link"] == "https://tightenupthe.tech"
Exemplo n.º 10
0
 def test_extracts_title(self, valid_data):
     """Should extract the title from the loaded entry_data."""
     parser = EntryParser(valid_data)
     data = parser.extract()
     assert data["title"] == "This is only a test"
Exemplo n.º 11
0
 def test_init_loads_entry_data(self, mocker):
     """Should load the supplied entry data into the class on init."""
     mocked_data = mocker.MagicMock()
     parser = EntryParser(mocked_data)
     assert parser.entry_data == mocked_data