Exemple #1
0
 def test_taglist_to_native_accepts_tag_manager(self):
     mock_tag_manager = mock.Mock(all=mock.Mock())
     mock_tags = []
     for tag_name in self.tags:
         tag = mock.Mock()
         tag.name = tag_name
         mock_tags.append(tag)
     mock_tag_manager.all.return_value = mock_tags
     serializer = serializers.TagListSerializer()
     result = serializer.to_native(mock_tag_manager)
     for tag in self.tags:
         self.assertIn(tag, result)
     mock_tag_manager.all.assert_called()
Exemple #2
0
 def test_taglist_from_native_fails_for_non_lists(self):
     serializer = serializers.TagListSerializer()
     with self.assertRaises(ParseError):
         serializer.from_native({'not': 'a list'})
Exemple #3
0
 def test_taglist_to_native_fails_otherwise(self):
     serializer = serializers.TagListSerializer()
     with self.assertRaises(ParseError):
         serializer.to_native("not a list")
Exemple #4
0
 def test_taglist_from_native_accepts_list(self):
     serializer = serializers.TagListSerializer()
     self.assertEqual(self.tags, serializer.from_native(self.tags))
Exemple #5
0
 def test_taglist_to_native_accepts_lists(self):
     serializer = serializers.TagListSerializer()
     tags = "foo bar baz".split()
     self.assertEqual(tags, serializer.to_native(tags))