<commit_before>import unittest
from mock import patch
from cli.pipe.copy import Copy
from cli.pipe.build import Build
from cli.pipe.rename import Rename


class TestBakery(unittest.TestCase):

    def test_copy_process(self):
        pipedata = {'process_files': ['1.in/fontname-bold.ttx'],
                    'builddir': 'build',
                    'project_root': ''}

        b = Copy('', 'build')
        with patch.object(b, 'copy_to_builddir') as mock_copy2builddir:
            mock_copy2builddir.return_value = 'sources'

            pipedata = b.execute(pipedata)

            mock_copy2builddir.assert_called_once_with(['1.in/fontname-bold.ttx'])
            self.assertEqual(pipedata['process_files'], ['sources/fontname-bold.ttx'])

    def test_copy_with_splitted_ttx(self):
        pipedata = {'process_files': ['1.in/fontname-bold.ttx'],
                    'builddir': 'build',
                    'project_root': ''}

        b = Copy('', 'build')
        with patch.object(b, 'copy_to_builddir') as copy2builddir:
            with patch.object(b, 'lookup_splitted_ttx') as splitted_ttx:
                splitted_ttx.return_value = ['1.in/fontname-bold._g_p_o_s.ttx']
                copy2builddir.return_value = 'sources'

                pipedata = b.execute(pipedata)

                copy2builddir.assert_called_once_with(['1.in/fontname-bold.ttx',
                                                       '1.in/fontname-bold._g_p_o_s.ttx'])
                self.assertEqual(pipedata['process_files'], ['sources/fontname-bold.ttx'])

    def test_convert(self):
        pipedata = {'process_files': ['sources/fontname-bold.ttx',
                                      'sources/fontname-regular.ttx'],
                    'project_root': '',
                    'builddir': 'build'}
        b = Build('', 'build')
        with patch.object(b, "execute_ttx") as ttx_call:
            with patch.object(b, "movebin_to_builddir") as move:
                move.return_value = ['fontname-bold.ttf',
                                     'fontname-regular.ttf']
                pipedata = b.execute(pipedata)

                ttx_call.assert_called_once_with('', 'build',
                                                 ['sources/fontname-bold.ttx',
                                                  'sources/fontname-regular.ttx'])
                self.assertEqual(pipedata['bin_files'],
                                 ['fontname-bold.ttf', 'fontname-regular.ttf'])
                move.assert_called_once_with('', 'build', ['sources/fontname-bold.ttx',
                                                           'sources/fontname-regular.ttx'])

    def test_rename(self):
        pipedata = {'bin_files': ['sources/fontname-bold.ttf']}
        b = Rename('', '')

        with patch.object(b, 'get_psname') as getpsname:
            with patch('cli.system.shutil.move') as move:
                with patch('fontTools.ttLib.TTFont') as TTFont:
                    TTFont.return_value = ''
                    getpsname.return_value = 'fontname-regular.ttf'
                    b.execute(pipedata)
                    move.assert_called_once_with('sources/fontname-bold.ttf',
                                                 'sources/fontname-regular.ttf')
        self.assertEqual(pipedata['bin_files'], ['sources/fontname-regular.ttf'])

<commit_msg>fixes test with updated bakery api<commit_after>import unittest
from mock import patch
from cli.pipe.copy import Copy
from cli.pipe.build import Build
from cli.pipe.rename import Rename


class TestBakery(unittest.TestCase):

    def test_copy_process(self):
        pipedata = {'process_files': ['1.in/fontname-bold.ttx'],
                    'builddir': 'build',
                    'project_root': ''}

        b = Copy('', 'build')
        with patch.object(b, 'copy_to_builddir') as mock_copy2builddir:
            mock_copy2builddir.return_value = 'sources'

            pipedata = b.execute(pipedata)

            mock_copy2builddir.assert_called_once_with(['1.in/fontname-bold.ttx'])
            self.assertEqual(pipedata['process_files'], ['sources/fontname-bold.ttx'])

    def test_copy_with_splitted_ttx(self):
        pipedata = {'process_files': ['1.in/fontname-bold.ttx'],
                    'builddir': 'build',
                    'project_root': ''}

        b = Copy('', 'build')
        with patch.object(b, 'copy_to_builddir') as copy2builddir:
            with patch.object(b, 'lookup_splitted_ttx') as splitted_ttx:
                splitted_ttx.return_value = ['1.in/fontname-bold._g_p_o_s.ttx']
                copy2builddir.return_value = 'sources'

                pipedata = b.execute(pipedata)

                copy2builddir.assert_called_once_with(['1.in/fontname-bold.ttx',
                                                       '1.in/fontname-bold._g_p_o_s.ttx'])
                self.assertEqual(pipedata['process_files'], ['sources/fontname-bold.ttx'])

    def test_convert(self):
        pipedata = {'process_files': ['sources/fontname-bold.ttx',
                                      'sources/fontname-regular.ttx'],
                    'project_root': '',
                    'builddir': 'build'}
        b = Build('', 'build')
        with patch.object(b, "execute_ttx") as ttx_call:
            with patch.object(b, "movebin_to_builddir") as move:
                move.return_value = ['fontname-bold.ttf',
                                     'fontname-regular.ttf']
                pipedata = b.execute(pipedata)

                ttx_call.assert_called_once_with('', 'build',
                                                 ['sources/fontname-bold.ttx',
                                                  'sources/fontname-regular.ttx'])
                self.assertEqual(pipedata['bin_files'],
                                 ['fontname-bold.ttf', 'fontname-regular.ttf'])
                move.assert_called_once_with('build', ['sources/fontname-bold.ttx',
                                                       'sources/fontname-regular.ttx'])

    def test_rename(self):
        pipedata = {'bin_files': ['sources/fontname-bold.ttf']}
        b = Rename('', '')

        with patch.object(b, 'get_psname') as getpsname:
            with patch('cli.system.shutil.move') as move:
                with patch('fontTools.ttLib.TTFont') as TTFont:
                    TTFont.return_value = ''
                    getpsname.return_value = 'fontname-regular.ttf'
                    b.execute(pipedata)
                    move.assert_called_once_with('sources/fontname-bold.ttf',
                                                 'sources/fontname-regular.ttf')
        self.assertEqual(pipedata['bin_files'], ['sources/fontname-regular.ttf'])


{'fraction_non_alphanumeric': 0.12372203289376203, 'fraction_numerical': 0.0035560823825751963, 'mean_word_length': 1.7294783663566518, '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': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3787079', 'n_tokens_mistral': 2007, 'n_tokens_neox': 1907, 'n_words': 284}