<commit_before>#!/usr/bin/env python2
from common import *
from testdc import *

CREATE_DOID_OFFSET = 1 + (CHANNEL_SIZE_BYTES * 2) + 2 + 4
VERIFY_DELETE_OBJECT = 0x21656944
VERIFY_DELETE_QUERY = 0x6c6c694b

class DatabaseBaseTests(object):
    def createTypeGetId(self, sender, context, type):
        # Create object of type
        dg = Datagram.create([75757], sender, DBSERVER_CREATE_OBJECT)
        dg.add_uint32(context)
        dg.add_uint16(type)
        dg.add_uint16(0) # Field count
        self.conn.send(dg)

        dg = self.conn.recv_maybe()
        self.assertTrue(dg is not None, "Did not receive CreateObjectResp.")
        dgi = DatagramIterator(dg)
        dgi.seek(CREATE_DOID_OFFSET)
        return dgi.read_doid()

    def createGenericGetId(self, sender, context):
        return self.createTypeGetId(sender, context, DistributedTestObject1)

    def deleteObject(self, sender, doid, check=False):
        dg = Datagram.create([75757], sender, DBSERVER_OBJECT_DELETE)
        dg.add_doid(doid)
        self.conn.send(dg)

        if check:
            dg = Datagram.create([doid], sender, DBSERVER_OBJECT_DELETE)
            dg.add_uint32(doid)
            self.assertTrue(*self.objects.expect(dg))
        else:
            self.objects.flush()

    def test_create_getall(self):
        self.objects.flush()
        self.conn.flush()
        self.conn.send(Datagram.create_add_channel(20))<commit_msg>tests: use add_doid while checking for DBSERVER_OBJECT_DELETE broadcast.<commit_after>#!/usr/bin/env python2
from common import *
from testdc import *

CREATE_DOID_OFFSET = 1 + (CHANNEL_SIZE_BYTES * 2) + 2 + 4
VERIFY_DELETE_OBJECT = 0x21656944
VERIFY_DELETE_QUERY = 0x6c6c694b

class DatabaseBaseTests(object):
    def createTypeGetId(self, sender, context, type):
        # Create object of type
        dg = Datagram.create([75757], sender, DBSERVER_CREATE_OBJECT)
        dg.add_uint32(context)
        dg.add_uint16(type)
        dg.add_uint16(0) # Field count
        self.conn.send(dg)

        dg = self.conn.recv_maybe()
        self.assertTrue(dg is not None, "Did not receive CreateObjectResp.")
        dgi = DatagramIterator(dg)
        dgi.seek(CREATE_DOID_OFFSET)
        return dgi.read_doid()

    def createGenericGetId(self, sender, context):
        return self.createTypeGetId(sender, context, DistributedTestObject1)

    def deleteObject(self, sender, doid, check=False):
        dg = Datagram.create([75757], sender, DBSERVER_OBJECT_DELETE)
        dg.add_doid(doid)
        self.conn.send(dg)

        if check:
            dg = Datagram.create([doid], sender, DBSERVER_OBJECT_DELETE)
            dg.add_doid(doid)
            self.assertTrue(*self.objects.expect(dg))
        else:
            self.objects.flush()

    def test_create_getall(self):
        self.objects.flush()
        self.conn.flush()
        self.conn.send(Datagram.create_add_channel(20))
{'fraction_non_alphanumeric': 0.10161345691726742, 'fraction_numerical': 0.02814967387572949, 'mean_word_length': 2.911409395973154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3476039', 'n_tokens_mistral': 1028, 'n_tokens_neox': 942, 'n_words': 182}