Exemplo n.º 1
0
 def test_should_detect_invalid_repository(self):
     self.assertFalse(github_utils.is_valid_repository(THIS_REPO+'abc'))
Exemplo n.º 2
0
def create_repo():

    repo_name = request.form.get('repo_name', '')
    github_token = current_user.github_token

    if len(repo_name) > 0:
        full_name = '%s/%s' % (current_user.username, repo_name)

    else:
        full_name = '{0}/{0}.github.io'.format(current_user.username)

    created = exists = overwrite = False

    # If repo does not exist, create it.
    if not github_utils.is_valid_repository(full_name):
        if github_utils.create_new_repository(full_name, github_token):
            created = True
            message = messages.CREATE_REPO_SUCCESS
        else:
            message = messages.CREATE_REPO_FAILURE

    elif github_utils.exists(full_name, '.travis.yml', github_token):
        exists = True
        overwrite = True
        message = messages.OVERWRITE_YAML

    else:
        exists = True
        message = messages.REPO_EXISTS

    data = {
        'exists': exists,
        'created': created,
        'overwrite': overwrite,
        'message': message,
        'full_name': full_name,
    }

    if exists or created:

        SAMPLE_CONF = [
            ('BLOG_AUTHOR',  "Your Name"),
            ('BLOG_TITLE', "Demo Site"),
            # ('SITE_URL', "http://getnikola.com/"),
            ('BLOG_EMAIL', "*****@*****.**"),
            ('BLOG_DESCRIPTION', "This is a demo site for Nikola."),
            ('COMMENT_SYSTEM', 'disqus'),
            ('COMMENT_SYSTEM_ID', 'nikolademo'),
            # ('DEFAULT_LANG', "en"),
            # ('THEME', 'bootstrap3'),
        ]

        context = {
            'FILES': get_travis_files_content(full_name, github_token, {}),
            'message': message,
            'SAMPLE_CONF': SAMPLE_CONF
        }

        data['contents'] = render_template('form.html', **context)

    return jsonify(data)
Exemplo n.º 3
0
 def test_should_confirm_repository_exists(self):
     self.assertTrue(github_utils.is_valid_repository(THIS_REPO))