Example #1
0
def rollback(path=getcwd(), freeze_file=FREEZE_FILE, venv=None):
    """rollback site-packages"""
    log(INFO, ICONS["clean"] + 'rollback site-packages')
    code = False
    if exists(join(path, freeze_file)):
        code = code or module(
            'pip',
            "freeze --exclude-editable > %s" % TEMP_REMOVE_FILE,
            path=path,
            venv=venv)
        code = code or module('pip',
                              "uninstall -r %s -y" % TEMP_REMOVE_FILE,
                              path=path,
                              venv=venv)
        del_tree(TEMP_REMOVE_FILE)
        code = code or module('pip',
                              "install --upgrade -r %s" % freeze_file,
                              path=path,
                              venv=venv)
        del_tree(join(path, freeze_file))
    return code
Example #2
0
    def test_unicorn(self):
        name, doc, author = 'unicorn', 'Always be a unicorn.', 'dreamer'
        email, url = '<name>@home', 'https://<author>.home/<name>'
        inputs = name, doc, author, email, url

        self.level = '-v'
        path = os.path.join(self.wdir, name)
        del_tree(path)
        cwd = os.getcwd()
        os.chdir(self.wdir)
        args = ' --name=%s --slogan="%s"' \
               ' --author=%s --email=%s --url=%s' % inputs
        cmd = '%s create %s' % (self.level, args)
        self.assertEqual(None, aux(cmd))
        os.chdir(path)
        self.assertEqual(None, aux('%s update' % self.level))
        self.assertEqual(None, aux('%s test --fail-fast' % self.level))
        self.assertEqual(None, aux('%s doc --fail-fast --api' % self.level))
        self.assertEqual(None, aux('%s build' % self.level))
        os.chdir(cwd)
        del_tree(path)
Example #3
0
    def _test_unicorn(self):
        name, doc, author = 'unicorn', 'Always be a unicorn.', 'dreamer'
        email, url = '<name>@home', 'https://<author>.home/<name>'
        inputs = name, doc, author, email, url

        path = os.path.join(self.wdir, name)
        del_tree(path)

        file_path = os.path.join(self.wdir, name + '_details')
        with open(file_path, "w") as f:
            f.write(os.linesep.join(inputs))
        self.assertEqual(
            0,
            auxilium('%s create < %s' % (self.level, file_path),
                     path=self.wdir))
        self.assertEqual(0, auxilium('%s update' % self.level, path=path))
        self.assertEqual(
            0, auxilium('%s test --fail-fast' % self.level, path=path))
        self.assertEqual(
            0, auxilium('%s doc --fail-fast --api' % self.level, path=path))
        self.assertEqual(0, auxilium('%s build' % self.level, path=path))
        del_tree(path)
Example #4
0
    def test_auxilium_demo(self):
        path = os.path.join(self.wdir, DEMO_PATH)
        del_tree(path)
        self.assertEqual(0, auxilium('%s --demo' % self.level, path=self.wdir))

        self.assertEqual(0, auxilium('%s update' % self.level, path=path))
        self.assertEqual(
            0, auxilium('%s test --fail-fast' % self.level, path=path))

        self.assertEqual(
            0, auxilium('%s doc --api --fail-fast' % self.level, path=path))
        self.assertEqual(0, auxilium('%s build' % self.level, path=path))

        self.assertEqual(
            0, auxilium('%s build --commit --tag' % self.level, path=path))
        self.assertNotEqual(
            0, auxilium('%s build --commit --tag' % self.level, path=path))
        self.assertNotEqual(
            0,
            auxilium('%s test --fail-fast --coverage=99' % self.level,
                     path=path))

        del_tree(path)
Example #5
0
def cleanup(pkg=basename(getcwd())):
    """remove temporary files"""
    log(INFO, ICONS["clean"] + 'cleanup build')
    # remove setuptools release files
    del_tree("build", "dist")
    return 0
Example #6
0
 def tearDown(self):
     try:
         del_tree(self.wdir)
     except PermissionError:
         pass
Example #7
0
    def testDulwich(self):

        # init remote and repo dir

        remote = os.path.join(self.wdir, 'git_remote')
        if os.path.exists(remote):
            del_tree(remote)
        os.mkdir(remote)

        path = os.path.join(self.wdir, 'git_test')
        if os.path.exists(path):
            del_tree(path)
        os.mkdir(path)

        # start at remote

        self.assertReturnsNonZero(status_git, path=remote)

        self.assertReturnsZero(init_git, path=remote)
        first_file = 'first_file'
        first_contents = 'Hello to repo!'
        with open(os.path.join(remote, first_file), 'w') as file:
            file.write(first_contents)
        self.assertIn(first_file, status(remote).untracked)

        self.assertReturnsZero(add_git, path=remote)
        self.assertIn(first_file.encode(), status(remote).staged['add'])
        self.assertReturnsZero(add_and_commit_git,
                               'remote_commit',
                               path=remote)

        self.assertReturnsZero(branch_git, 'other', path=remote)

        if os.name == 'posix':
            self.assertReturnsZero(checkout_git, 'other', path=remote)

        # switch to repo

        self.assertReturnsZero(clone_git, remote, path=path)
        if os.name == 'posix':
            self.assertReturnsZero(checkout_git, 'master', path=path)

        self.assertReturnsZero(pull_git, remote, path=path)
        self.assertReturnsZero(add_and_commit_git, 'empty_commit', path=path)

        with open(os.path.join(path, 'first_file'), 'r') as file:
            read_first_contents = file.read()
        self.assertEqual(first_contents, read_first_contents)

        append_contents = ' And hello to remote!'
        with open(os.path.join(path, first_file), 'a') as file:
            file.write(append_contents)

        second_contents = 'Hello to remote!'
        second_file = 'second_file'
        with open(os.path.join(path, second_file), 'w') as file:
            file.write(second_contents)

        self.assertIn(first_file.encode(), status(path).unstaged)
        self.assertIn(second_file, status(path).untracked)

        self.assertReturnsZero(status_git, path=path)

        self.assertReturnsZero(add_git, path=path)

        self.assertReturnsZero(status_git, path=path)

        self.assertIn(first_file.encode(), status(path).staged['modify'])
        self.assertIn(second_file.encode(), status(path).staged['add'])

        self.assertReturnsZero(add_and_commit_git, 'repo_commit', path=path)

        tag = 'test_tag'
        self.assertReturnsZero(tag_git, tag, path=path)
        self.assertIn(tag.encode(), tag_list(path))

        self.assertReturnsZero(push_git, remote, path=path)

        # switch back to remote

        if os.name == 'posix':
            self.assertReturnsZero(checkout_git, 'master', path=remote)

            with open(os.path.join(remote, first_file), 'r') as file:
                self.assertEqual(file.read(), first_contents + append_contents)
            with open(os.path.join(remote, second_file), 'r') as file:
                self.assertEqual(file.read(), second_contents)