import unittest
import slumber
import slumber.serialize


class ResourceTestCase(unittest.TestCase):
    def setUp(self):
        self.data = {
            "foo": "bar",
            "baz": [1, 2, 3]
        }

    def test_json_get_serializer(self):
        s = slumber.serialize.Serializer()

        serializer = None
        for content_type in [
            "application/json",
            "application/x-javascript",
            "text/javascript",
            "text/x-javascript",
            "text/x-json",
        ]:
            serializer = s.get_serializer(content_type=content_type)
            self.assertIsInstance(serializer, slumber.serialize.JsonSerializer,
                                  "content_type %s should produce a JsonSerializer")

        result = serializer.dumps(self.data)
        self.assertEqual(result, '{"foo": "bar", "baz": [1, 2, 3]}')
        self.assertEqual(self.data, serializer.loads(result))

    def test_yaml_get_serializer(self):
        s = slumber.serialize.Serializer()

        serializer = None
        for content_type in [
            "text/yaml",
        ]:
            serializer = s.get_serializer(content_type=content_type)
            self.assertIsInstance(serializer, slumber.serialize.YamlSerializer,
                                  "content_type %s should produce a YamlSerializer")

        result = serializer.dumps(self.data)
        self.assertEqual(result, "baz: [1, 2, 3]\nfoo: bar\n")
        self.assertEqual(self.data, serializer.loads(result))

@@ -167,37 +167,8 @@
 r%22,%0A
-            %22baz%22: %5B1, 2, 3%5D%0A
     
@@ -576,33 +576,33 @@
  self.assert
-IsInstanc
+Equal(typ
 e(serializer
@@ -593,32 +593,33 @@
 (type(serializer
+)
 , slumber.serial
@@ -630,37 +630,32 @@
 JsonSerializer,%0A
-     
                 
@@ -815,26 +815,8 @@
 bar%22
-, %22baz%22: %5B1, 2, 3%5D
 %7D')%0A
@@ -1150,17 +1150,17 @@
 sert
-IsInstanc
+Equal(typ
 e(se
@@ -1167,16 +1167,17 @@
 rializer
+)
 , slumbe
@@ -1196,37 +1196,32 @@
 YamlSerializer,%0A
-     
                 
@@ -1368,32 +1368,17 @@
 t, %22
-baz: %5B1, 2, 3%5D%5Cn
+%7B
 foo: bar
 %5Cn%22)
@@ -1373,16 +1373,17 @@
 foo: bar
+%7D
 %5Cn%22)%0A   

Fix tests