<commit_before>#
# Copyright(c) 2011, <NAME> <<EMAIL>>
# All rights reserved
#

import logging
import random
import time
import unittest

import flockdb.client
import flockdb.test.utils

class Client(flockdb.test.utils.SilentLog):

    def setUp(self):
        self.client = flockdb.client.Client("localhost", 7915, {
                "follow": 1,
                "block": 2,
                })

    def _add(self, *args):
        result = self.client.add(*args)
        # Since flockdb is eventually consistent, there needs to be a little
        # time before moving on to a get.
        time.sleep(0.2)
        return result

    def test_add(self):
        tests = [[random.randint(0, 1000) for x in range(2)] for y in range(2)]

        source, dest = tests[0]
        result = self._add(source, "follow", dest)
        result = self.client.get(source, "follow", dest)
        self.assertEqual(1, len(result),
                         "Should only be one result")
        self.assertEqual(dest, result[0],
                         "Make sure that the links are correct")

        # Test multiple graphs
        source, dest = tests[1]
        self._add(source, "block", dest)
        result = self.client.get(source, "block", dest)
        self.assertEqual(
            1, len(result),
            "This is a different graph, should only be one result")
        self.assertEqual(dest, result[0],
                         "Edge should point correctly")

        # Missing!
        source, dest = tests[0]
        result = self.client.get(source, "block", dest)
        self.assertEqual(0, len(result),
                         "This edge doesn't exist")
        result = self.client.get(dest, "follow", source)
        self.assertEqual(0, len(result),
                         "This edge doesn't exist")

    def test_get(self):
        source = random.randint(0, 1000)
        dest = random.randint(0, 1000)
        result = self.client.add(source, 'follow', dest)
        time.sleep(0.2)
        result = self.client.get(source, "follow", dest)
        logging.info(result)<commit_msg>Adding tests to check for search cases<commit_after>#
# Copyright(c) 2011, <NAME> <<EMAIL>>
# All rights reserved
#

import logging
import random
import time
import unittest

import flockdb.client
import flockdb.test.utils

class Client(flockdb.test.utils.SilentLog):

    def setUp(self):
        self.client = flockdb.client.Client("localhost", 7915, {
                "follow": 1,
                "block": 2,
                })

    def _add(self, *args):
        result = self.client.add(*args)
        # Since flockdb is eventually consistent, there needs to be a little
        # time before moving on to a get.
        time.sleep(0.2)
        return result

    def assert_edge(self, source, graph, dest):
        result = self.client.get(source, graph, dest)
        self.assertTrue(dest in result,
                        "Edge should be in the result set")
        return result

    def test_add(self):
        tests = [[random.randint(0, 1000) for x in range(2)] for y in range(2)]

        source, dest = tests[0]
        result = self._add(source, "follow", dest)
        result = self.assert_edge(source, "follow", dest)
        self.assertEqual(1, len(result),
                         "Should only be one result")

        # Test multiple graphs
        source, dest = tests[1]
        self._add(source, "block", dest)
        result = self.assert_edge(source, "block", dest)
        self.assertEqual(
            1, len(result),
            "This is a different graph, should only be one result")

        # Missing!
        source, dest = tests[0]
        result = self.client.get(source, "block", dest)
        self.assertEqual(0, len(result),
                         "This edge doesn't exist")
        result = self.client.get(dest, "follow", source)
        self.assertEqual(0, len(result),
                         "This edge doesn't exist")

    def test_get(self):
        source = random.randint(0, 1000)
        dest = random.randint(0, 1000)

        # Straight get.
        result = self._add(source, 'follow', dest)
        self.assert_edge(source, "follow", dest)

        # What edges come off a node
        result = self.client.get(source, "follow", None)
        self.assertTrue(dest in result,
                        "Edge should be in result set")

        # Edges incoming to a node
        result = self.client.get(None, "follow", dest)
        self.assertTrue(source in result,
                        "Edge should be in result set")
{'fraction_non_alphanumeric': 0.11193866374589266, 'fraction_numerical': 0.01664841182913472, 'mean_word_length': 1.9901768172888015, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, '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': '4000554', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1260, 'n_words': 389}