Beispiel #1
0
def test_clipping_equality_different_values(clipping, document, metadata):
    other_clipping = Clipping(
        document=document,
        metadata=metadata,
        content='Different content',
    )

    assert other_clipping != clipping
Beispiel #2
0
def test_clipping_equality_same_values(clipping, document, metadata, content):
    other_clipping = Clipping(
        document=document,
        metadata=metadata,
        content=content,
    )

    assert other_clipping is not clipping
    assert other_clipping == clipping
Beispiel #3
0
def test_clipping_to_dict():
    document = Mock()
    document.to_dict = Mock(return_value={'doc': 'ument'})
    metadata = Mock()
    metadata.to_dict = Mock(return_value={'meta': 'data'})
    content = 'Some content'
    clipping = Clipping(document, metadata, content)

    expected_dict = {
        'content': 'Some content',
        'document': {
            'doc': 'ument'
        },
        'metadata': {
            'meta': 'data'
        },
    }

    assert clipping.to_dict() == expected_dict
Beispiel #4
0
    def test_clipping_to_dict(self):
        document = mock.MagicMock()
        document.to_dict = mock.MagicMock(return_value={'doc': 'ument'})
        metadata = mock.MagicMock()
        metadata.to_dict = mock.MagicMock(return_value={'meta': 'data'})
        content = 'Some content'

        expected_dict = {
            'content': 'Some content',
            'document': {
                'doc': 'ument'
            },
            'metadata': {
                'meta': 'data'
            },
        }

        clipping = Clipping(document, metadata, content)
        self.assertEqual(expected_dict, clipping.to_dict())
Beispiel #5
0
def test_clipping_to_str():
    document = Mock()
    document.__str__ = Mock(return_value='Title (Author)')
    metadata = Mock()
    metadata.__str__ = Mock(return_value='SO META!')
    content = 'Some content'
    clipping = Clipping(document, metadata, content)

    expected_string = "Title (Author)\nSO META!\nSome content"

    assert str(clipping) == expected_string
Beispiel #6
0
    def test_clipping_to_str(self):
        document = mock.MagicMock()
        document.__str__ = mock.MagicMock(return_value='Title (Author)')
        metadata = mock.MagicMock()
        metadata.__str__ = mock.MagicMock(return_value='SO META!')
        content = 'Some content'

        expected_string = "Title (Author)\nSO META!\nSome content"

        clipping = Clipping(document, metadata, content)
        self.assertEqual(expected_string, str(clipping))
Beispiel #7
0
def fixture_clipping(document, metadata, content):
    return Clipping(
        document=document,
        metadata=metadata,
        content=content,
    )