Exemplo n.º 1
0
 def test_create_prefix(self):
     """
     Create a prefix-matching observation.
     """
     obs1 = PrefixUriObservation(u"com.example.uri1")
     self.assertTrue(isinstance(obs1.id, six.integer_types))
     self.assertEqual(obs1.uri, u"com.example.uri1")
     self.assertEqual(obs1.match, u"prefix")
     self.assertEqual(obs1.observers, set())
Exemplo n.º 2
0
 def test_create_prefix(self):
     """
     Create a prefix-matching observation.
     """
     obs1 = PrefixUriObservation("com.example.uri1")
     self.assertTrue(isinstance(obs1.id, (int, )))
     self.assertEqual(obs1.uri, "com.example.uri1")
     self.assertEqual(obs1.match, "prefix")
     self.assertEqual(obs1.observers, set())
Exemplo n.º 3
0
 def test_create_prefix(self):
     """
     Create a prefix-matching observation.
     """
     obs1 = PrefixUriObservation(u"com.example.uri1")
     self.assertEqual(type(obs1.id), int)
     self.assertEqual(obs1.uri, u"com.example.uri1")
     self.assertEqual(obs1.match, u"prefix")
     self.assertEqual(obs1.observers, set())
Exemplo n.º 4
0
    def test_pickle(self):
        """
        Test pickling of observations (__getstate__, __setstate__).
        """
        obsvs = [
            ExactUriObservation(u"com.example.uri1"),
            PrefixUriObservation(u"com.example.uri1"),
            WildcardUriObservation(u"com.example..create"),
        ]

        for sub in obsvs:
            data = StringIO()
            pickle.dump(sub, data)

            read_fd = StringIO(data.getvalue())
            obs2 = pickle.load(read_fd)

            self.assertEqual(sub.id, obs2.id)
            self.assertEqual(sub.uri, obs2.uri)
            self.assertEqual(sub.match, obs2.match)
            self.assertEqual(obs2.observers, set())