Пример #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"
Пример #2
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"
Пример #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__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
Пример #6
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'
Пример #7
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"
Пример #8
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
Пример #9
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
Пример #10
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
Пример #11
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
Пример #12
0
 def test_unit__check_value__ok(self):
     mail_parts = BodyMailParts()
     a = BodyMailPart("a", BodyMailPartType.Main)
     mail_parts._check_value(a)
Пример #13
0
 def test_unit__check_value__type_error(self):
     mail_parts = BodyMailParts()
     with pytest.raises(TypeError):
         mail_parts._check_value("a")