Пример #1
0
 def test_json_store(self):
     message = Analytics(Trail(), Analytics.FORMAT_JSON, 'TestFormat',
                         'TestFriendlyID', True,
                         222).set_timestamp(TIMESTAMP)
     message.add_variable_param('data: {"key": "value"}')
     self.assertEqual(message.serialize(), MSG_JSON_STORE)
     self.assertEqual(message.get_format_type(), "JSON")
Пример #2
0
 def test_xml_store(self):
     message = Analytics(Trail(), Analytics.FORMAT_XML, 'TestFormat',
                         'TestFriendlyID', True,
                         222).set_timestamp(TIMESTAMP)
     message.add_variable_param('<data>Analytics data</data>')
     self.assertEqual(message.serialize(), MSG_XML_STORE)
     self.assertEqual(message.get_format_type(), "XML")
Пример #3
0
 def test_ordering(self):
     trail = Trail()
     marker_static_first = Marker(trail, 222).set_timestamp(TIMESTAMP)
     marker_static_first.add_static_params([333, 444])
     marker_static_first.add_variable_params(["test parameter", "other test parameter"])
     marker_static_first.set_instance_id(555)
     marker_variable_first = Marker(trail, 222).set_timestamp(TIMESTAMP)
     marker_variable_first.add_variable_params(["test parameter", "other test parameter"])
     marker_variable_first.set_instance_id(555)
     marker_variable_first.add_static_params([333, 444]).set_timestamp(TIMESTAMP)
     self.assertEqual(marker_static_first.serialize(), marker_variable_first.serialize())
     self.assertEqual(marker_static_first.serialize(), MARKER_STRING_ALL)
Пример #4
0
 def test_string_format(self):
     message = Analytics(Trail(), Analytics.FORMAT_JSON, 'TestFormat',
                         'TestFriendlyID', True,
                         222).set_timestamp(TIMESTAMP)
     message.add_variable_param('data: {"string_test": "test_value"}')
     expected_string = ('SAS Message: Analytics (2015-12-15 11:58:12)\n'
                        '   Static parameters: \n'
                        '   Variable parameters: 1 parameters\n'
                        '   Trail: 111\n'
                        '   Event ID: 0x0000de\n'
                        '   Instance ID: 0\n'
                        '   Format Type: JSON\n'
                        '   Store Msg  : True\n'
                        '   Source Type: TestFormat\n'
                        '   Friendly ID: TestFriendlyID\n')
     self.assertEqual(str(message), expected_string)
Пример #5
0
 def test_ordering(self):
     trail = Trail()
     event_static_first = Event(trail, 222).set_timestamp(TIMESTAMP)
     event_static_first.add_static_params([333, 444])
     event_static_first.add_variable_params(
         ["test parameter", "other test parameter"])
     event_static_first.set_instance_id(555)
     event_variable_first = Event(trail, 222).set_timestamp(TIMESTAMP)
     event_variable_first.add_variable_params(
         ["test parameter", "other test parameter"])
     event_variable_first.set_instance_id(555)
     event_variable_first.add_static_params([333,
                                             444]).set_timestamp(TIMESTAMP)
     self.assertEqual(event_static_first.serialize(),
                      event_variable_first.serialize())
     self.assertEqual(event_static_first.serialize(), EVENT_STRING_ALL)
Пример #6
0
 def test_interfaces(self):
     trail = Trail()
     event_constructor = Event(trail, 222, 555, [333, 444],
                               ["test parameter", "other test parameter"
                                ]).set_timestamp(TIMESTAMP)
     event_plurals = Event(trail, 222).set_timestamp(TIMESTAMP)
     event_plurals.set_instance_id(555)
     event_plurals.add_static_params([333, 444])
     event_plurals.add_variable_params(
         ["test parameter", "other test parameter"])
     event_singles = Event(trail, 222).set_timestamp(TIMESTAMP)
     event_singles.set_instance_id(555)
     event_singles.add_static_param(333).add_static_param(444)
     event_singles.add_variable_param("test parameter")\
         .add_variable_param("other test parameter")
     self.assertEqual(event_constructor.serialize(),
                      event_plurals.serialize())
     self.assertEqual(event_constructor.serialize(),
                      event_singles.serialize())
     self.assertEqual(event_constructor.serialize(), EVENT_STRING_ALL)
Пример #7
0
 def test_interfaces(self):
     trail = Trail()
     marker_constructor = Marker(
         trail,
         222,
         555,
         False,
         SCOPE_NONE,
         [333, 444],
         ["test parameter", "other test parameter"]).set_timestamp(TIMESTAMP)
     marker_plurals = Marker(trail, 222).set_timestamp(TIMESTAMP)
     marker_plurals.set_instance_id(555)
     marker_plurals.add_static_params([333, 444])
     marker_plurals.add_variable_params(["test parameter", "other test parameter"])
     marker_singles = Marker(trail, 222).set_timestamp(TIMESTAMP)
     marker_singles.set_instance_id(555)
     marker_singles.add_static_param(333).add_static_param(444)
     marker_singles.add_variable_param("test parameter")\
         .add_variable_param("other test parameter")
     self.assertEqual(marker_constructor.serialize(), marker_plurals.serialize())
     self.assertEqual(marker_constructor.serialize(), marker_singles.serialize())
     self.assertEqual(marker_constructor.serialize(), MARKER_STRING_ALL)
Пример #8
0
 def test_two_static_params(self):
     marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)
     marker.add_static_params([333, 444])
     self.assertEqual(marker.serialize(), MARKER_STRING_TWO_STATIC)
Пример #9
0
 def test_one_static_param(self):
     marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)
     marker.add_static_param(333)
     self.assertEqual(marker.serialize(), MARKER_STRING_ONE_STATIC)
Пример #10
0
 def test_empty(self):
     marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)
     self.assertEqual(marker.serialize(), MARKER_STRING_EMPTY)
Пример #11
0
 def test_reactivate_scope_none(self):
     marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)
     marker.set_reactivate(False)
     self.assertEqual(marker.serialize(), MARKER_STRING_EMPTY)
     pass
Пример #12
0
 def test_compressed_variable_param(self):
     event = Event(Trail(), 222).set_timestamp(TIMESTAMP)
     event.add_variable_param("test parameter", compress=COMPRESS_ZLIB)
     self.assertEqual(event.serialize(), EVENT_STRING_COMPRESSED_VAR)
Пример #13
0
 def test_params_no_list(self):
     marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)
     with self.assertRaises(TypeError):
         marker.add_static_params(333)
     with self.assertRaises(TypeError):
         marker.add_variable_params("test parameter")
 def test_scope_trace(self):
     assoc = TrailAssoc(Trail(), Trail(),
                        SCOPE_TRACE).set_timestamp(TIMESTAMP)
     self.assertEqual(assoc.serialize(), ASSOC_STRING_SCOPE_TRACE)
     # Now just check that __str__ doesn't throw
     self.assertGreater(len(str(assoc)), 0)
 def test_scope_branch(self):
     assoc = TrailAssoc(Trail(), Trail(),
                        SCOPE_BRANCH).set_timestamp(TIMESTAMP)
     self.assertEqual(assoc.serialize(), ASSOC_STRING_SCOPE_BRANCH)
 def test_scope_none(self):
     assoc = TrailAssoc(Trail(), Trail(),
                        SCOPE_NONE).set_timestamp(TIMESTAMP)
     self.assertEqual(assoc.serialize(), ASSOC_STRING_SCOPE_NONE)
Пример #17
0
 def test_unknown_compression(self):
     event = Event(Trail(), 222).set_timestamp(TIMESTAMP)
     with self.assertRaises(ValueError):
         event.add_variable_param("test parameter",
                                  compress='bogus_compression')
Пример #18
0
 def test_one_variable_param(self):
     marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)
     marker.add_variable_param("test parameter")
     self.assertEqual(marker.serialize(), MARKER_STRING_ONE_VAR)
Пример #19
0
 def test_one_variable_param(self):
     event = Event(Trail(), 222).set_timestamp(TIMESTAMP)
     event.add_variable_param("test parameter")
     self.assertEqual(event.serialize(), EVENT_STRING_ONE_VAR)
Пример #20
0
 def test_two_variable_params(self):
     marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)
     marker.add_variable_params(["test parameter", "other test parameter"])
     self.assertEqual(marker.serialize(), MARKER_STRING_TWO_VAR)
     # Now just check that __str__ doesn't throw
     self.assertGreater(len(str(marker)), 0)
Пример #21
0
 def test_one_static_param(self):
     event = Event(Trail(), 222).set_timestamp(TIMESTAMP)
     event.add_static_param(333)
     self.assertEqual(event.serialize(), EVENT_STRING_ONE_STATIC)
Пример #22
0
 def test_two_static_params(self):
     event = Event(Trail(), 222).set_timestamp(TIMESTAMP)
     event.add_static_params([333, 444])
     self.assertEqual(event.serialize(), EVENT_STRING_TWO_STATIC)
Пример #23
0
 def test_reactivate(self):
     marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)
     marker.set_association_scope(SCOPE_BRANCH).set_reactivate(False)
     self.assertEqual(marker.serialize(), MARKER_STRING_REACTIVATE)
     pass
Пример #24
0
 def test_scope_branch(self):
     marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)
     marker.set_association_scope(SCOPE_BRANCH)
     self.assertEqual(marker.serialize(), MARKER_STRING_BRANCH)
     pass
Пример #25
0
 def test_two_variable_params(self):
     event = Event(Trail(), 222).set_timestamp(TIMESTAMP)
     event.add_variable_params(["test parameter", "other test parameter"])
     self.assertEqual(event.serialize(), EVENT_STRING_TWO_VAR)
     # Now just check that __str__ doesn't throw
     self.assertGreater(len(str(event)), 0)
Пример #26
0
 def test_scope_trace(self):
     marker = Marker(Trail(), 222).set_timestamp(TIMESTAMP)
     marker.set_association_scope(SCOPE_TRACE)
     self.assertEqual(marker.serialize(), MARKER_STRING_TRACE)
     pass
Пример #27
0
 def test_empty(self):
     event = Event(Trail(), 222).set_timestamp(TIMESTAMP)
     self.assertEqual(event.serialize(), EVENT_STRING_EMPTY)