Esempio 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
Esempio 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
     )
Esempio 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
Esempio 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
     )
Esempio 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
     )
Esempio 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()
Esempio 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()
Esempio 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)
Esempio 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)
Esempio 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)
Esempio n. 11
0
 def test_factory_dict(self):
     """Test Event.factory() with a dict."""
     self.assertEqual(Event.factory(_event_with_meta), _event_with_meta)
Esempio n. 12
0
 def test_factory_dict(self):
     """Test Event.factory() with a dict."""
     self.assertEqual(
         Event.factory(_event_with_meta),
         _event_with_meta
     )