<commit_before>import json
import unittest

class Node:

    ID = 'id'
    LABEL = 'label'
    METADATA = "metadata"

    def __init__(self, id, label=None, metadata=None):
        self.set_id(id)
        self._label = None
        if label != None:
            self.set_label(label)
        self._metadata = None
        if metadata != None:
            self.set_metadata(metadata)

    def _isJsonSerializable(self, dictionay):
        try:
            json.dumps(dictionay)
            return True
        except Exception:
            return False

    def set_id(self, id):
        if id == None:
            raise ValueError('Id of Node can not be None')
        if isinstance(id, str):
            self._id = id
        else:
            try:
                stringId = str(id)
                self._id = stringId
            except Exception as excecption:
                raise TypeError("Type of id in Node needs to be a string (or string castable): " + str(exception))
            
    def set_label(self, label):
        if label == None:
            self._label = None
            return
        if isinstance(label, str):
            self._label = label
        else:
            try:
                stringLabel = str(label)
                self._label = stringLabel
            except Exception as excecption:
                raise TypeError("Type of label in Node object needs to be a string (or string castable): " + str(exception))

    def set_metadata(self, metadata):
        if metadata == None:
            self._metadata = None
        if isinstance(metadata, dict) and self._isJsonSerializable(metadata):
            self._metadata = metadata
        else:
            raise TypeError("metadata in Node object needs to be json serializable")

    def get_id(self):
        return self._id

    def get_label(self):
        return self._label

    def get_metadata(self):
        return self._metadata

    def to_JSON(self):
        json = {Node.ID: self._id}
        if self._label != None:
            json[Node.LABEL] = self._label
        if self._metadata != None:
            json[Node.METADATA] = self._metadata


class TestNodeClass(unittest.TestCase):

    def test_base(self):<commit_msg>added fixes for development errors<commit_after>import json
import unittest

class Node:

    ID = 'id'
    LABEL = 'label'
    METADATA = "metadata"

    def __init__(self, id, label=None, metadata=None):
        self.set_id(id)
        self._label = None
        if label != None:
            self.set_label(label)
        self._metadata = None
        if metadata != None:
            self.set_metadata(metadata)

    def _isJsonSerializable(self, dictionay):
        try:
            json.dumps(dictionay)
            return True
        except Exception:
            return False

    def set_id(self, id):
        if id == None:
            raise ValueError('Id of Node can not be None')
        if isinstance(id, str):
            self._id = id
        else:
            try:
                stringId = str(id)
                self._id = stringId
            except Exception as excecption:
                raise TypeError("Type of id in Node needs to be a string (or string castable): " + str(exception))
            
    def set_label(self, label):
        if label == None:
            self._label = None
        else:
            if isinstance(label, str):
                self._label = label
            else:
                try:
                    stringLabel = str(label)
                    self._label = stringLabel
                except Exception as excecption:
                    raise TypeError("Type of label in Node object needs to be a string (or string castable): " + str(exception))

    def set_metadata(self, metadata):
        if metadata == None:
            self._metadata = None
        else:
            if isinstance(metadata, dict) and self._isJsonSerializable(metadata):
                self._metadata = metadata
            else:
                raise TypeError("metadata in Node object needs to be json serializable")

    def get_id(self):
        return self._id

    def get_label(self):
        return self._label

    def get_metadata(self):
        return self._metadata

    def to_JSON(self):
        json = {Node.ID: self._id}
        if self._label != None:
            json[Node.LABEL] = self._label
        if self._metadata != None:
            json[Node.METADATA] = self._metadata
        return json


class TestNodeClass(unittest.TestCase):

    def test_base(self):
{'fraction_non_alphanumeric': 0.08227012758468984, 'fraction_numerical': 0.0, 'mean_word_length': 1.6841794569067297, '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': '5167693', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1189, 'n_words': 370}