def test_should_commit_new_file(self): # Given full_name = 'punchagan/experiri' content = path = self._get_random_string() author = { 'name': 'Tests on Travis', 'email': '*****@*****.**', } info = { 'author': author, 'committer': author, } # When committed = github_utils.commit( path, content, full_name, GH_TOKEN, extra_payload=info ) # Then self.assertTrue(committed) self.assertTrue(github_utils.exists(full_name, path, GH_TOKEN))
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)
def test_should_return_false_if_non_existent(self): self.assertFalse(github_utils.exists(THIS_REPO, 'README.xx', GH_TOKEN))
def test_should_return_true_if_exists(self): self.assertTrue( github_utils.exists(THIS_REPO, 'README.md', GH_TOKEN) )