]> code.communitydata.science - rises_declines_wikia_code.git/blob - mediawiki_dump_tools/Mediawiki-Utilities/mw/xml_dump/iteration/tests/test_text.py
Initial commit
[rises_declines_wikia_code.git] / mediawiki_dump_tools / Mediawiki-Utilities / mw / xml_dump / iteration / tests / test_text.py
1 from nose.tools import eq_
2
3 from ..text import Text
4
5
6 def test_immutability():
7     a = Text("foo")
8     b = Text(a)
9     eq_(id(a), id(b))
10
11
12 def test_empty_constructor():
13     t = Text()
14     eq_(t, "")
15     eq_(t.deleted, False)
16     eq_(t.id, None)
17     eq_(t.xml_space, "preserve")
18     eq_(t.bytes, None)
19
20
21 def test_deleted_constructor():
22     t = Text("", deleted=True)
23     eq_(t, "")
24     eq_(t.deleted, True)
25     eq_(t.id, None)
26     eq_(t.xml_space, "preserve")
27     eq_(t.bytes, None)
28
29
30 def test_full_constructor():
31     t = Text("Foobar!", deleted=False, id=10, xml_space="foobar", bytes=1001)
32     eq_(t, "Foobar!")
33     eq_(t.deleted, False)
34     eq_(t.id, 10)
35     eq_(t.xml_space, "foobar")
36     eq_(t.bytes, 1001)
37
38
39 def test_serialize():
40     t = Text("Foobar!", deleted=False, id=10, xml_space="foobar", bytes=1001)
41     t2 = Text.deserialize(t.serialize())
42     eq_(t2.deleted, False)
43     eq_(t2.id, 10)
44     eq_(t2.xml_space, "foobar")
45     eq_(t2.bytes, 1001)

Community Data Science Collective || Want to submit a patch?