-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_xml.py
58 lines (49 loc) · 1.8 KB
/
test_xml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
import pytest
from iterable.datatypes import XMLIterable
from fixdata import FIXTURES_BOOKS
class TestXML:
def test_id(self):
datatype_id = XMLIterable.id()
assert datatype_id == 'xml'
def test_flatonly(self):
flag = XMLIterable.is_flatonly()
assert flag == False
def test_openclose(self):
iterable = XMLIterable('fixtures/books.xml', tagname='book')
iterable.close()
def test_parsesimple_readone(self):
iterable = XMLIterable('fixtures/books.xml', tagname='book')
row = iterable.read()
assert row == FIXTURES_BOOKS[0]
iterable.close()
def test_parsesimple_reset(self):
iterable = XMLIterable('fixtures/books.xml', tagname='book')
row = iterable.read()
assert row == FIXTURES_BOOKS[0]
iterable.reset()
row_reset = iterable.read()
assert row_reset == FIXTURES_BOOKS[0]
iterable.close()
def test_parsesimple_next(self):
iterable = XMLIterable('fixtures/books.xml', tagname='book')
row = next(iterable)
assert row == FIXTURES_BOOKS[0]
iterable.reset()
row_reset = next(iterable)
assert row_reset == FIXTURES_BOOKS[0]
iterable.close()
def test_parsesimple_count(self):
iterable = XMLIterable('fixtures/books.xml', tagname='book')
n = 0
for row in iterable:
n += 1
assert n == len(FIXTURES_BOOKS)
iterable.close()
def test_parsesimple_iterateall(self):
iterable = XMLIterable('fixtures/books.xml', tagname='book')
n = 0
for row in iterable:
assert row == FIXTURES_BOOKS[n]
n += 1
iterable.close()