Example #1
0
    def test_completion(self):
        # Load plugin commands
        config["pluginpath"] = [os.path.join(_common.RSRC, "beetsplug")]
        config["plugins"] = ["test"]

        test_script = os.path.join(os.path.dirname(__file__), "test_completion.sh")
        bash_completion = os.path.abspath(os.environ.get("BASH_COMPLETION_SCRIPT", "/etc/bash_completion"))

        # Tests run in bash
        cmd = os.environ.get("BEETS_TEST_SHELL", "/bin/bash --norc").split()
        if not has_program(cmd[0]):
            self.skipTest("bash not available")
        tester = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)

        # Load bash_completion
        try:
            with open(bash_completion, "r") as bash_completion:
                tester.stdin.writelines(bash_completion)
        except IOError:
            self.skipTest("bash-completion script not found")

        # Load complection script
        self.io.install()
        ui._raw_main(["completion"])
        completion_script = self.io.getoutput()
        self.io.restore()
        tester.stdin.writelines(completion_script)

        # Load testsuite
        with open(test_script, "r") as test_script:
            tester.stdin.writelines(test_script)
        (out, err) = tester.communicate()
        if tester.returncode != 0 or out != "completion tests passed\n":
            print(out)
            self.fail("test/test_completion.sh did not execute properly")
Example #2
0
    def test_completion(self):
        # Load plugin commands
        config['pluginpath'] = [os.path.join(_common.RSRC, 'beetsplug')]
        config['plugins'] = ['test']

        test_script = os.path.join(
            os.path.dirname(__file__), 'test_completion.sh'
        )
        bash_completion = os.path.abspath(os.environ.get(
            'BASH_COMPLETION_SCRIPT', '/etc/bash_completion'))

        # Tests run in bash
        cmd = os.environ.get('BEETS_TEST_SHELL', '/bin/bash --norc').split()
        if not has_program(cmd[0]):
            self.skipTest('bash not available')
        tester = subprocess.Popen(cmd, stdin=subprocess.PIPE,
                                  stdout=subprocess.PIPE)

        # Load bash_completion
        try:
            with open(bash_completion, 'r') as bash_completion:
                tester.stdin.writelines(bash_completion)
        except IOError:
            self.skipTest('bash-completion script not found')

        # Load complection script
        self.io.install()
        ui._raw_main(['completion'])
        completion_script = self.io.getoutput()
        self.io.restore()
        tester.stdin.writelines(completion_script)

        # Load testsuite
        with open(test_script, 'r') as test_script:
            tester.stdin.writelines(test_script)
        (out, err) = tester.communicate()
        if tester.returncode != 0 or out != "completion tests passed\n":
            print(out)
            self.fail('test/test_completion.sh did not execute properly')
Example #3
0
    def test_completion(self):
        # Load plugin commands
        config['pluginpath'] = [os.path.join(_common.RSRC, 'beetsplug')]
        config['plugins'] = ['test']

        test_script = os.path.join(os.path.dirname(__file__),
                                   'test_completion.sh')
        bash_completion = os.path.abspath(
            os.environ.get('BASH_COMPLETION_SCRIPT', '/etc/bash_completion'))

        # Tests run in bash
        cmd = os.environ.get('BEETS_TEST_SHELL', '/bin/bash --norc').split()
        if not has_program(cmd[0]):
            self.skipTest('bash not available')
        tester = subprocess.Popen(cmd,
                                  stdin=subprocess.PIPE,
                                  stdout=subprocess.PIPE)

        # Load bash_completion
        try:
            with open(bash_completion, 'r') as bash_completion:
                tester.stdin.writelines(bash_completion)
        except IOError:
            self.skipTest('bash-completion script not found')

        # Load complection script
        self.io.install()
        ui._raw_main(['completion'])
        completion_script = self.io.getoutput()
        self.io.restore()
        tester.stdin.writelines(completion_script)

        # Load testsuite
        with open(test_script, 'r') as test_script:
            tester.stdin.writelines(test_script)
        (out, err) = tester.communicate()
        if tester.returncode != 0 or out != "completion tests passed\n":
            print(out)
            self.fail('test/test_completion.sh did not execute properly')
Example #4
0
        return path


class ImportTarTest(ImportZipTest):

    def create_archive(self):
        (handle, path) = mkstemp(dir=self.temp_dir)
        os.close(handle)
        archive = TarFile(path, mode='w')
        archive.add(os.path.join(_common.RSRC, 'full.mp3'),
                    'full.mp3')
        archive.close()
        return path


@unittest.skipIf(not has_program('unrar'), 'unrar program not found')
class ImportRarTest(ImportZipTest):

    def create_archive(self):
        return os.path.join(_common.RSRC, 'archive.rar')


@unittest.skip('Implment me!')
class ImportPasswordRarTest(ImportZipTest):

    def create_archive(self):
        return os.path.join(_common.RSRC, 'password.rar')


class ImportSingletonTest(_common.TestCase, ImportHelper):
    """Test ``APPLY`` and ``ASIS`` choices for an import session with singletons
Example #5
0
# included in all copies or substantial portions of the Software.


from _common import unittest
from helper import TestHelper, has_program

from beets.mediafile import MediaFile

try:
    import gi
    gi.require_version('Gst', '1.0')
    GST_AVAILABLE = True
except ImportError, ValueError:
    GST_AVAILABLE = False

if any(has_program(cmd, ['-v']) for cmd in ['mp3gain', 'aacgain']):
    GAIN_PROG_AVAILABLE = True
else:
    GAIN_PROG_AVAILABLE = False


class ReplayGainCliTestBase(TestHelper):

    def setUp(self):
        self.setup_beets()

        try:
            self.load_plugins('replaygain')
        except:
            self.teardown_beets()
            self.unload_plugins()
Example #6
0
        archive.write(os.path.join(_common.RSRC, "full.mp3"), "full.mp3")
        archive.close()
        return path


class ImportTarTest(ImportZipTest):
    def create_archive(self):
        (handle, path) = mkstemp(dir=self.temp_dir)
        os.close(handle)
        archive = TarFile(path, mode="w")
        archive.add(os.path.join(_common.RSRC, "full.mp3"), "full.mp3")
        archive.close()
        return path


@unittest.skipIf(not has_program("unrar"), "unrar program not found")
class ImportRarTest(ImportZipTest):
    def create_archive(self):
        return os.path.join(_common.RSRC, "archive.rar")


@unittest.skip("Implment me!")
class ImportPasswordRarTest(ImportZipTest):
    def create_archive(self):
        return os.path.join(_common.RSRC, "password.rar")


class ImportSingletonTest(_common.TestCase, ImportHelper):
    """Test ``APPLY`` and ``ASIS`` choices for an import session with singletons
    config set to True.
    """
Example #7
0
        return path


class ImportTarTest(ImportZipTest):

    def create_archive(self):
        (handle, path) = mkstemp(dir=self.temp_dir)
        os.close(handle)
        archive = TarFile(path, mode='w')
        archive.add(os.path.join(_common.RSRC, 'full.mp3'),
                    'full.mp3')
        archive.close()
        return path


@unittest.skipIf(not has_program('unrar'), 'unrar program not found')
class ImportRarTest(ImportZipTest):

    def create_archive(self):
        return os.path.join(_common.RSRC, 'archive.rar')


@unittest.skip('Implment me!')
class ImportPasswordRarTest(ImportZipTest):

    def create_archive(self):
        return os.path.join(_common.RSRC, 'password.rar')


class ImportSingletonTest(_common.TestCase, ImportHelper):
    """Test ``APPLY`` and ``ASIS`` choices for an import session with singletons