<commit_before>import unittest

import synapse.cortex as s_cortex
import synapse.lib.tags as s_tags

from synapse.tests.common import *

class TagTest(SynTest):

    def test_aspect_iter_up(self):
        tags = tuple( s_tags.iterTagUp('foo.bar.baz') )
        self.assertEqual( tags, ('foo.bar.baz','foo.bar','foo') )

    def test_aspect_iter_down(self):
        tags = tuple( s_tags.iterTagDown('foo.bar.baz') )
        self.assertEqual( tags, ('foo','foo.bar','foo.bar.baz') )

    def test_aspect_adddel(self):
        core = s_cortex.openurl('ram:///')
        tufo = core.formTufoByProp('foo','bar')
        tufo = core.addTufoTag(tufo, 'baz.faz.gaz', valu=None)

        tags = s_tags.getTufoTags(tufo)

        self.assertIsNotNone( tags.get('baz') )
        self.assertIsNotNone( tags.get('baz.faz') )
        self.assertIsNotNone( tags.get('baz.faz.gaz') )

        tufos = core.getTufosByTag('foo','baz.faz')
        self.assertEqual( len(tufos), 1 )

        tufo = core.delTufoTag(tufo,'baz.faz')

        tufos = core.getTufosByTag('foo','baz.faz')
        self.assertEqual( len(tufos), 0 )

        tufos = core.getTufosByTag('foo','baz.faz.gaz')
        self.assertEqual( len(tufos), 0 )

    def test_aspect_bytag(self):
        bytag = s_tags.ByTag()

        bytag.put('foo0',('foos.foo0','bar.baz'))
        bytag.put('foo1',('foos.foo1','bar.faz'))

        vals = tuple( sorted( bytag.get('bar') ) )<commit_msg>fixed borked unit test from slight api change for clarity<commit_after>import unittest

import synapse.cortex as s_cortex
import synapse.lib.tags as s_tags

from synapse.tests.common import *

class TagTest(SynTest):

    def test_aspect_iter_up(self):
        tags = tuple( s_tags.iterTagUp('foo.bar.baz') )
        self.assertEqual( tags, ('foo.bar.baz','foo.bar','foo') )

    def test_aspect_iter_down(self):
        tags = tuple( s_tags.iterTagDown('foo.bar.baz') )
        self.assertEqual( tags, ('foo','foo.bar','foo.bar.baz') )

    def test_aspect_adddel(self):
        core = s_cortex.openurl('ram:///')
        tufo = core.formTufoByProp('foo','bar')
        tufo = core.addTufoTag(tufo, 'baz.faz.gaz', asof=None)

        tags = s_tags.getTufoTags(tufo)

        self.assertIsNotNone( tags.get('baz') )
        self.assertIsNotNone( tags.get('baz.faz') )
        self.assertIsNotNone( tags.get('baz.faz.gaz') )

        tufos = core.getTufosByTag('foo','baz.faz')
        self.assertEqual( len(tufos), 1 )

        tufo = core.delTufoTag(tufo,'baz.faz')

        tufos = core.getTufosByTag('foo','baz.faz')
        self.assertEqual( len(tufos), 0 )

        tufos = core.getTufosByTag('foo','baz.faz.gaz')
        self.assertEqual( len(tufos), 0 )

    def test_aspect_bytag(self):
        bytag = s_tags.ByTag()

        bytag.put('foo0',('foos.foo0','bar.baz'))
        bytag.put('foo1',('foos.foo1','bar.faz'))

        vals = tuple( sorted( bytag.get('bar') ) )
{'fraction_non_alphanumeric': 0.16483516483516483, 'fraction_numerical': 0.004807692307692308, 'mean_word_length': 2.9471544715447155, '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': '5739735', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1101, 'n_words': 161}