grr/server/grr_response_server/db_utils_test.py
def testStatsEntryId_VaryIntDimensions(self):
    """Ensures StatsEntries with different int dimensions get different ids."""
    entry1 = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.INT,
            fields_values=[
                stats_values.StatsStoreFieldValue(
                    field_type=rdf_stats.MetricFieldDefinition.FieldType.INT,
                    int_value=11),
                stats_values.StatsStoreFieldValue(
                    field_type=rdf_stats.MetricFieldDefinition.FieldType.INT,
                    int_value=12)
            ],
            int_value=42),
        timestamp=_one_second_timestamp)

    # Clone entry1 and change a single dimension value.
    entry2 = stats_values.StatsStoreEntry()
    entry2.FromDict(entry1.ToPrimitiveDict())
    entry2.metric_value.fields_values[0].int_value = 13

    self.assertEqual(
        db_utils.GenerateStatsEntryId(entry1),
        b"pl\xc31\x1a\xf8\xd5\xfe\xe1\xc6\x10gR\x10f\x0c\xb8\xd3\x96_\xa3`\x19"
        b"\xf2\x15\xc5\xa0\x8d\xbbu\xf1&")
    self.assertEqual(
        db_utils.GenerateStatsEntryId(entry2),
        b"L \x1d+\xd5<g\\\xa8\xa4\x97\xdd\xe8^\x88\xac\xc7\xbej\xae\xff\xd5S"
        b"\x10\xce\xec\x82a\xe5_\xe1\x1c")
Ensures StatsEntries with different int dimensions get different ids.
Ensures StatsEntries with different int dimensions get different ids.
Ensures StatsEntries with different int dimensions get different ids .
def testStatsEntryId_VaryIntDimensions(self):
    entry1 = stats_values.StatsStoreEntry(
        process_id="test_process",
        metric_name="test_metric",
        metric_value=stats_values.StatsStoreValue(
            value_type=rdf_stats.MetricMetadata.ValueType.INT,
            fields_values=[
                stats_values.StatsStoreFieldValue(
                    field_type=rdf_stats.MetricFieldDefinition.FieldType.INT,
                    int_value=11),
                stats_values.StatsStoreFieldValue(
                    field_type=rdf_stats.MetricFieldDefinition.FieldType.INT,
                    int_value=12)
            ],
            int_value=42),
        timestamp=_one_second_timestamp)
    entry2 = stats_values.StatsStoreEntry()
    entry2.FromDict(entry1.ToPrimitiveDict())
    entry2.metric_value.fields_values[0].int_value = 13
    self.assertEqual(
        db_utils.GenerateStatsEntryId(entry1),
        b"pl\xc31\x1a\xf8\xd5\xfe\xe1\xc6\x10gR\x10f\x0c\xb8\xd3\x96_\xa3`\x19"
        b"\xf2\x15\xc5\xa0\x8d\xbbu\xf1&")
    self.assertEqual(
        db_utils.GenerateStatsEntryId(entry2),
        b"L \x1d+\xd5<g\\\xa8\xa4\x97\xdd\xe8^\x88\xac\xc7\xbej\xae\xff\xd5S"
        b"\x10\xce\xec\x82a\xe5_\xe1\x1c")
def testStatsEntryId_VaryIntDimensions ( self ) : entry1 = stats_values . StatsStoreEntry ( process_id = "test_process" , metric_name = "test_metric" , metric_value = stats_values . StatsStoreValue ( value_type = rdf_stats . MetricMetadata . ValueType . INT , fields_values = [ stats_values . StatsStoreFieldValue ( field_type = rdf_stats . MetricFieldDefinition . FieldType . INT , int_value = 11 ) , stats_values . StatsStoreFieldValue ( field_type = rdf_stats . MetricFieldDefinition . FieldType . INT , int_value = 12 ) ] , int_value = 42 ) , timestamp = _one_second_timestamp ) entry2 = stats_values . StatsStoreEntry ( ) entry2 . FromDict ( entry1 . ToPrimitiveDict ( ) ) entry2 . metric_value . fields_values [ 0 ] . int_value = 13 self . assertEqual ( db_utils . GenerateStatsEntryId ( entry1 ) , b"pl\xc31\x1a\xf8\xd5\xfe\xe1\xc6\x10gR\x10f\x0c\xb8\xd3\x96_\xa3`\x19" b"\xf2\x15\xc5\xa0\x8d\xbbu\xf1&" ) self . assertEqual ( db_utils . GenerateStatsEntryId ( entry2 ) , b"L \x1d+\xd5<g\\\xa8\xa4\x97\xdd\xe8^\x88\xac\xc7\xbej\xae\xff\xd5S" b"\x10\xce\xec\x82a\xe5_\xe1\x1c" )
Ensures StatsEntries with different int dimensions get different ids.
Ensures StatsEntries with different int dimensions get different ids .
"""Ensures StatsEntries with different int dimensions get different ids.""" # Clone entry1 and change a single dimension value.
self