Exemplo n.º 1
0
 def event_from_temp_file(self):
     """
     Read the event(s) from the temp_file.
     """
     with open(self.temp_file_path, 'r') as f:
         event = Event.factory(f)
     return event
Exemplo n.º 2
0
 def test_factory_string(self):
     """Test Event.factory() with a JSON string."""
     s = json.dumps(_event_with_meta)
     self.assertEqual(
         Event.factory(s),
         _event_with_meta
     )
Exemplo n.º 3
0
 def event_from_temp_file(self):
     """
     Read the event(s) from the temp_file.
     """
     with open(self.temp_file_path, 'r') as f:
         event = Event.factory(f)
     return event
Exemplo n.º 4
0
 def test_factory_list(self):
     """Test Event.factory() with a list of dicts."""
     l = [_event_with_meta, _event_with_meta]
     self.assertEqual(
         Event.factory(l),
         l
     )
Exemplo n.º 5
0
 def test_factory_string_list(self):
     """Test Event.factory() with a list JSON string."""
     l = [_event_with_meta, _event_with_meta]
     s = json.dumps(l)
     self.assertEqual(
         Event.factory(s),
         l
     )
Exemplo n.º 6
0
    def test_factory_file(self):
        """Test Event.factory() with a file object."""
        l = [_event_with_meta, _event_with_meta]
        s = json.dumps(l)

        file = tempfile.TemporaryFile(prefix='eventlogging-event-test')
        # Write the string to the temp file.
        file.write(s.encode('utf-8'))
        # Seek to the beginning of file so Event.factory() can read it.
        file.seek(0)
        self.assertEqual(Event.factory(file), l)
        file.close()
Exemplo n.º 7
0
    def test_factory_file(self):
        """Test Event.factory() with a file object."""
        l = [_event_with_meta, _event_with_meta]
        s = json.dumps(l)

        file = tempfile.TemporaryFile(prefix='eventlogging-event-test')
        # Write the string to the temp file.
        file.write(s.encode('utf-8'))
        # Seek to the beginning of file so Event.factory() can read it.
        file.seek(0)
        self.assertEqual(
            Event.factory(file),
            l
        )
        file.close()
Exemplo n.º 8
0
 def test_factory_string_list(self):
     """Test Event.factory() with a list JSON string."""
     l = [_event_with_meta, _event_with_meta]
     s = json.dumps(l)
     self.assertEqual(Event.factory(s), l)
Exemplo n.º 9
0
 def test_factory_string(self):
     """Test Event.factory() with a JSON string."""
     s = json.dumps(_event_with_meta)
     self.assertEqual(Event.factory(s), _event_with_meta)
Exemplo n.º 10
0
 def test_factory_list(self):
     """Test Event.factory() with a list of dicts."""
     l = [_event_with_meta, _event_with_meta]
     self.assertEqual(Event.factory(l), l)
Exemplo n.º 11
0
 def test_factory_dict(self):
     """Test Event.factory() with a dict."""
     self.assertEqual(Event.factory(_event_with_meta), _event_with_meta)
Exemplo n.º 12
0
 def test_factory_dict(self):
     """Test Event.factory() with a dict."""
     self.assertEqual(
         Event.factory(_event_with_meta),
         _event_with_meta
     )