from libgen.publication import Publication


def test_pub_initialization():
    attrs = {'id': 5, 'author': 'Fernando Pessoa'}
    p = Publication(attrs)
    assert p.id == 5
    assert p.author == 'Fernando Pessoa'
    assert p.title is None


def test_pub_attributes():
    attrs = {'id': 5, 'author': 'Fernando Pessoa'}
    p = Publication(attrs)
    assert p.attributes == attrs.keys()


def test_pub_values():
    attrs = {'id': 5, 'author': 'Fernando Pessoa'}
    p = Publication(attrs)
    assert list(p.values()) == list(attrs.values())


def test_pub_repr():
    attrs = {'id': 5, 'author': 'Fernando Pessoa'}
    p = Publication(attrs)
    assert repr(p) == 'Publication(\'id\': 5, \'author\': Fernando Pessoa)'

@@ -90,32 +90,33 @@
 'id': 5, 'author
+s
 ': 'Fernando Pes
@@ -188,16 +188,17 @@
 p.author
+s
  == 'Fer
@@ -288,32 +288,33 @@
 'id': 5, 'author
+s
 ': 'Fernando Pes
@@ -432,32 +432,33 @@
 'id': 5, 'author
+s
 ': 'Fernando Pes
@@ -594,16 +594,17 @@
  'author
+s
 ': 'Fern
@@ -698,16 +698,17 @@
 %5C'author
+s
 %5C': Fern
@@ -721,8 +721,1249 @@
 essoa)'%0A
+%0A%0Adef test_pub_len():%0A    attrs = %7B'id': 5, 'authors': 'Fernando Pessoa'%7D%0A    p = Publication(attrs)%0A    assert len(p) == len(attrs)%0A%0A%0Adef test_pub_filename_no_extension():%0A    p = Publication(%7B'id': 5, 'authors': 'Fernando Pessoa'%7D)%0A    assert p.filename() is None%0A%0A%0Adef test_pub_filename_extension_only():%0A    p = Publication(%7B'id': 5,%0A                     'authors': 'Fernando Pessoa',%0A                     'extension': 'pdf'%7D)%0A    assert p.filename().endswith('.pdf')%0A%0A%0Adef test_pub_filename_extension_and_title():%0A    p = Publication(%7B'id': 5,%0A                     'title': 'Island',%0A                     'extension': 'pdf'%7D)%0A    assert p.filename() == 'Island.pdf'%0A%0A%0Adef test_pub_filename_extension_title_and_year():%0A    p = Publication(%7B'id': 5,%0A                     'title': 'Island',%0A                     'year': 1962,%0A                     'extension': 'epub'%7D)%0A    assert p.filename() == 'Island (1962).epub'%0A%0A%0Adef test_pub_filename_extension_title_authorss_and_year():%0A    p = Publication(%7B'id': 5,%0A                     'title': 'Island',%0A                     'authors': 'Aldous Huxley',%0A                     'year': 1962,%0A                     'extension': 'djvu'%7D)%0A    assert p.filename() == 'Island (1962) - Aldous Huxley.djvu'%0A

Add tests for '__len__' and 'attributes' methods