Example #1
0
File: tests.py Project: jchmura/PiE
    def test_single_book(self):
        xml = '''<?xml version="1.0"?>
<catalog>
    <book id="book101">
      <author>Chmura, Jakub</author>
      <title>This is a title</title>
      <genre>Adventure</genre>
      <price>3.14</price>
      <publish_date>2015-05-28</publish_date>
      <description>Lorem ipsum dolor sit amet,
      consectetur adipiscing elit</description>
   </book>
</catalog>
'''
        book = parser.Book(
            id='book101',
            author='Chmura, Jakub',
            title='This is a title',
            genre='Adventure',
            price=3.14,
            publish_date=datetime(2015, 5, 28),
            description=
            'Lorem ipsum dolor sit amet, consectetur adipiscing elit')
        root = ElementTree.fromstring(xml)
        books = parser.create_books(root)
        self.assertEqual(1, len(books))
        self.assertEqual(book, books[0])
Example #2
0
File: tests.py Project: jchmura/PiE
    def test_missing_attribute(self):
        xml = '''<?xml version="1.0"?>
<catalog>
    <book id="book101">
      <author>Chmura, Jakub</author>
      <title>This is a title</title>
      <genre>Adventure</genre>
      <publish_date>2015-05-28</publish_date>
      <description>Lorem ipsum dolor sit amet,
      consectetur adipiscing elit</description>
   </book>
</catalog>
'''
        root = ElementTree.fromstring(xml)
        books = parser.create_books(root)
        self.assertEqual(0, len(books))  # the book is not created
Example #3
0
File: tests.py Project: jchmura/PiE
    def test_missing_attribute(self):
        xml = '''<?xml version="1.0"?>
<catalog>
    <book id="book101">
      <author>Chmura, Jakub</author>
      <title>This is a title</title>
      <genre>Adventure</genre>
      <publish_date>2015-05-28</publish_date>
      <description>Lorem ipsum dolor sit amet,
      consectetur adipiscing elit</description>
   </book>
</catalog>
'''
        root = ElementTree.fromstring(xml)
        books = parser.create_books(root)
        self.assertEqual(0, len(books))  # the book is not created
Example #4
0
File: tests.py Project: jchmura/PiE
    def test_single_book(self):
        xml = '''<?xml version="1.0"?>
<catalog>
    <book id="book101">
      <author>Chmura, Jakub</author>
      <title>This is a title</title>
      <genre>Adventure</genre>
      <price>3.14</price>
      <publish_date>2015-05-28</publish_date>
      <description>Lorem ipsum dolor sit amet,
      consectetur adipiscing elit</description>
   </book>
</catalog>
'''
        book = parser.Book(id='book101', author='Chmura, Jakub', title='This is a title', genre='Adventure',
                           price=3.14, publish_date=datetime(2015, 5, 28),
                           description='Lorem ipsum dolor sit amet, consectetur adipiscing elit')
        root = ElementTree.fromstring(xml)
        books = parser.create_books(root)
        self.assertEqual(1, len(books))
        self.assertEqual(book, books[0])