Exemple #1
0
    def test_log_str_prop(self):
        """Test the log string property"""
        ar = ActivityRecord(ActivityType.CODE,
                            show=True,
                            message="added some code",
                            importance=50,
                            linked_commit='aaaaaaaa')

        adr = ActivityDetailRecord(ActivityDetailType.CODE)
        adr.add_value("text/plain", "this is some data")
        adr.key = "my_fake_detail_key"
        ar.add_detail_object(adr)

        assert ar.log_str == """_GTM_ACTIVITY_START_**
Exemple #2
0
    def put_detail_record(
            self, detail_obj: ActivityDetailRecord) -> ActivityDetailRecord:
        """Method to write a detail record to the activity detail db

        Args:
            detail_obj(ActivityDetailRecord): The detail record to write

        Returns:
            ActivityDetailRecord: the detail record updated with the key
        """
        # Set compression option based on config and objects size
        compress = False
        if self.compress_details:
            if detail_obj.data_size >= self.compress_min_bytes:
                compress = True

        # Write record and store key
        detail_obj.key = self.detaildb.put(
            self._encode_write_options(compress=compress) +
            detail_obj.to_bytes(compress))

        logger.debug(
            f"Successfully wrote ActivityDetailRecord {detail_obj.key}")
        return detail_obj