示例#1
0
 def test_unit__append_dont_follow_when_first(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart('a', BodyMailPartType.Main)
     mail_parts._append(a, follow=True)
     assert len(mail_parts) == 1
     assert mail_parts[0].part_type == BodyMailPartType.Main
     assert mail_parts[0].text == 'a'
 def test_unit__append_dont_follow_when_first(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts._append(a, follow=True)
     assert len(mail_parts) == 1
     assert mail_parts[0].part_type == BodyMailPartType.Main
     assert mail_parts[0].text == "a"
示例#3
0
 def test_unit__append_different_type(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart('a', BodyMailPartType.Main)
     mail_parts.append(a)
     b = BodyMailPart('b', BodyMailPartType.Quote)
     mail_parts._append(b)
     assert len(mail_parts) == 2
     assert mail_parts[0] == a
     assert mail_parts[1] == b
示例#4
0
 def test_unit__append_same_type(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart('a', BodyMailPartType.Main)
     mail_parts._append(a)
     b = BodyMailPart('b', BodyMailPartType.Main)
     mail_parts._append(b)
     assert len(mail_parts) == 1
     assert mail_parts[0].part_type == BodyMailPartType.Main
     assert mail_parts[0].text == 'ab'
示例#5
0
 def test_unit__drop_part_type_consistence(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart('a', BodyMailPartType.Main)
     mail_parts._list.append(a)
     b = BodyMailPart('b', BodyMailPartType.Quote)
     mail_parts._list.append(b)
     c = BodyMailPart('c', BodyMailPartType.Main)
     mail_parts._list.append(c)
     mail_parts.drop_part_type(BodyMailPartType.Quote)
     assert len(mail_parts) == 1
     assert mail_parts[0].text == 'ac'
     assert mail_parts[0].part_type == BodyMailPartType.Main
 def test_unit__drop_part_type_consistence(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts._list.append(a)
     b = BodyMailPart("b", BodyMailPartType.Quote)
     mail_parts._list.append(b)
     c = BodyMailPart("c", BodyMailPartType.Main)
     mail_parts._list.append(c)
     mail_parts.drop_part_type(BodyMailPartType.Quote)
     assert len(mail_parts) == 1
     assert mail_parts[0].text == "ac"
     assert mail_parts[0].part_type == BodyMailPartType.Main
示例#7
0
 def test_unit__drop_part_type(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart('a', BodyMailPartType.Main)
     mail_parts._list.append(a)
     b = BodyMailPart('b', BodyMailPartType.Quote)
     mail_parts._list.append(b)
     c = BodyMailPart('c', BodyMailPartType.Signature)
     mail_parts._list.append(c)
     mail_parts.drop_part_type(BodyMailPartType.Quote)
     assert len(mail_parts) == 2
     assert mail_parts[0].text == 'a'
     assert mail_parts[0].part_type == BodyMailPartType.Main
     assert len(mail_parts) == 2
     assert mail_parts[1].text == 'c'
     assert mail_parts[1].part_type == BodyMailPartType.Signature
示例#8
0
 def test_unit__drop_part_type_verify_no_follow_incidence(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart('a', BodyMailPartType.Main)
     mail_parts._list.append(a)
     b = BodyMailPart('b', BodyMailPartType.Quote)
     mail_parts._list.append(b)
     c = BodyMailPart('c', BodyMailPartType.Signature)
     mail_parts._list.append(c)
     mail_parts.follow = True
     mail_parts.drop_part_type(BodyMailPartType.Quote)
     assert len(mail_parts) == 2
     assert mail_parts[0].text == 'a'
     assert mail_parts[0].part_type == BodyMailPartType.Main
     assert len(mail_parts) == 2
     assert mail_parts[1].text == 'c'
     assert mail_parts[1].part_type == BodyMailPartType.Signature
 def test_unit__drop_part_type_verify_no_follow_incidence(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts._list.append(a)
     b = BodyMailPart("b", BodyMailPartType.Quote)
     mail_parts._list.append(b)
     c = BodyMailPart("c", BodyMailPartType.Signature)
     mail_parts._list.append(c)
     mail_parts.follow = True
     mail_parts.drop_part_type(BodyMailPartType.Quote)
     assert len(mail_parts) == 2
     assert mail_parts[0].text == "a"
     assert mail_parts[0].part_type == BodyMailPartType.Main
     assert len(mail_parts) == 2
     assert mail_parts[1].text == "c"
     assert mail_parts[1].part_type == BodyMailPartType.Signature
 def test_unit__get_nb_part_type(self):
     mail_parts = BodyMailParts()
     assert mail_parts.get_nb_part_type(BodyMailPartType.Main) == 0
     assert mail_parts.get_nb_part_type(BodyMailPartType.Quote) == 0
     assert mail_parts.get_nb_part_type(BodyMailPartType.Signature) == 0
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts._list.append(a)
     assert mail_parts.get_nb_part_type(BodyMailPartType.Main) == 1
     b = BodyMailPart("b", BodyMailPartType.Quote)
     mail_parts._list.append(b)
     assert mail_parts.get_nb_part_type(BodyMailPartType.Quote) == 1
     c = BodyMailPart("c", BodyMailPartType.Signature)
     mail_parts._list.append(c)
     assert mail_parts.get_nb_part_type(BodyMailPartType.Main) == 1
     assert mail_parts.get_nb_part_type(BodyMailPartType.Quote) == 1
     assert mail_parts.get_nb_part_type(BodyMailPartType.Signature) == 1
示例#11
0
 def test_unit__str(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart('a', BodyMailPartType.Main)
     mail_parts._list.append(a)
     b = BodyMailPart('b', BodyMailPartType.Quote)
     mail_parts._list.append(b)
     c = BodyMailPart('c', BodyMailPartType.Signature)
     mail_parts._list.append(c)
     assert str(mail_parts) == 'abc'
 def test_unit__str(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts._list.append(a)
     b = BodyMailPart("b", BodyMailPartType.Quote)
     mail_parts._list.append(b)
     c = BodyMailPart("c", BodyMailPartType.Signature)
     mail_parts._list.append(c)
     assert str(mail_parts) == "abc"
 def test_unit__std_list_methods(self):
     mail_parts = BodyMailParts()
     assert len(mail_parts) == 0
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts._list.append(a)
     assert len(mail_parts) == 1
     assert mail_parts[0] == a
     del mail_parts[0]
     assert len(mail_parts) == 0
示例#14
0
 def test_unit__get_nb_part_type(self):
     mail_parts = BodyMailParts()
     assert mail_parts.get_nb_part_type(BodyMailPartType.Main) == 0
     assert mail_parts.get_nb_part_type(BodyMailPartType.Quote) == 0
     assert mail_parts.get_nb_part_type(BodyMailPartType.Signature) == 0
     a = BodyMailPart('a', BodyMailPartType.Main)
     mail_parts._list.append(a)
     assert mail_parts.get_nb_part_type(BodyMailPartType.Main) == 1
     b = BodyMailPart('b', BodyMailPartType.Quote)
     mail_parts._list.append(b)
     assert mail_parts.get_nb_part_type(BodyMailPartType.Quote) == 1
     c = BodyMailPart('c', BodyMailPartType.Signature)
     mail_parts._list.append(c)
     assert mail_parts.get_nb_part_type(BodyMailPartType.Main) == 1
     assert mail_parts.get_nb_part_type(BodyMailPartType.Quote) == 1
     assert mail_parts.get_nb_part_type(BodyMailPartType.Signature) == 1
 def test_unit__append_follow(self):
     mail_parts = BodyMailParts()
     mail_parts.follow = True
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts._append(a)
     b = BodyMailPart("b", BodyMailPartType.Quote)
     mail_parts._append(b)
     assert len(mail_parts) == 1
     assert mail_parts[0].part_type == BodyMailPartType.Main
     assert mail_parts[0].text == "ab"
 def test_unit__append_different_type(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts.append(a)
     b = BodyMailPart("b", BodyMailPartType.Quote)
     mail_parts._append(b)
     assert len(mail_parts) == 2
     assert mail_parts[0] == a
     assert mail_parts[1] == b
 def test_unit__append_same_type(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts._append(a)
     b = BodyMailPart("b", BodyMailPartType.Main)
     mail_parts._append(b)
     assert len(mail_parts) == 1
     assert mail_parts[0].part_type == BodyMailPartType.Main
     assert mail_parts[0].text == "ab"
示例#18
0
 def test_unit__append_follow(self):
     mail_parts = BodyMailParts()
     mail_parts.follow = True
     a = BodyMailPart('a', BodyMailPartType.Main)
     mail_parts._append(a)
     b = BodyMailPart('b', BodyMailPartType.Quote)
     mail_parts._append(b)
     assert len(mail_parts) == 1
     assert mail_parts[0].part_type == BodyMailPartType.Main
     assert mail_parts[0].text == 'ab'
示例#19
0
 def test_unit__check_value__type_error(self):
     mail_parts = BodyMailParts()
     with pytest.raises(TypeError):
         mail_parts._check_value('a')
示例#20
0
 def test_unit__check_value__ok(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart('a', BodyMailPartType.Main)
     mail_parts._check_value(a)
 def test_unit__check_value__ok(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts._check_value(a)
 def test_unit__check_value__type_error(self):
     mail_parts = BodyMailParts()
     with pytest.raises(TypeError):
         mail_parts._check_value("a")