Commit b6588a13 authored by Tom Pillot's avatar Tom Pillot
Browse files

Fix rainboard tests

parent 615708a2
Pipeline #10371 canceled with stage
in 1 minute and 17 seconds
......@@ -37,6 +37,4 @@ ADD . .
CMD while ! nc -z postgres 5432; do sleep 1; done \
&& ./manage.py migrate \
&& ./manage.py collectstatic --no-input \
&& gunicorn \
--bind 0.0.0.0 \
dashboard.wsgi
# && gunicorn --bind 0.0.0.0 dashboard.wsgi
......@@ -12,7 +12,6 @@ import github
from autoslug.utils import slugify
from django.conf import settings
from django.core.mail import mail_admins
from django.db.models import Q
from django.http import HttpRequest
from django.http.response import (HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseRedirect,
HttpResponseServerError)
......
......@@ -3,8 +3,17 @@
from django.db import migrations, models
class Migration(migrations.Migration):
def update_namespaces(apps, schema_editor):
Namespace = apps.get_model('rainboard', 'Namespace')
for namespace in Namespace.objects.all():
if namespace.slug_gitlab == '':
namespace.slug_gitlab = namespace.slug
if namespace.slug_github == '':
namespace.slug_github = namespace.slug
namespace.save()
class Migration(migrations.Migration):
dependencies = [
('rainboard', '0045_project_accept_pr_to_master'),
]
......@@ -20,4 +29,5 @@ class Migration(migrations.Migration):
name='slug_gitlab',
field=models.CharField(default='', max_length=200),
),
migrations.RunPython(update_namespaces),
]
......@@ -55,9 +55,9 @@ class Namespace(NamedModel):
slug_github = models.CharField(max_length=200, default='')
def save(self, *args, **kwargs):
if self.slug_gitlab is None:
if self.slug_gitlab == '':
self.slug_gitlab = self.slug
if self.slug_github is None:
if self.slug_github == '':
self.slug_github = self.slug
super(Namespace, self).save(*args, **kwargs)
......@@ -222,6 +222,7 @@ class Project(Links, NamedModel, TimeStampedModel):
def github(self):
github_forge = Forge.objects.get(slug='github')
print(github_forge.token)
gh = Github(github_forge.token)
return gh.get_repo(f'{self.main_namespace.slug_github}/{self.slug}')
......
......@@ -19,19 +19,19 @@ class RainboardTests(TestCase):
models.License.objects.create(name='BSD 2-Clause "Simplified" License',
spdx_id='BSD-2-Clause',
url='http://spdx.org/licenses/BSD-2-Clause.json')
models.Project.objects.create(name='Rainboard Tests',
models.Project.objects.create(name='Rainboard Tests 2',
main_namespace=models.Namespace.objects.get(slug='gepetto'),
main_forge=models.Forge.objects.get(source=utils.SOURCES.github),
license=models.License.objects.first())
self.assertEqual(models.License.objects.count(), license_count + 1)
self.assertEqual(models.Project.objects.count(), project_count + 1)
project = models.Project.objects.get(name='rainboard tests')
project = models.Project.objects.get(name='rainboard tests 2')
self.assertEqual(project.slug, 'rainboard-tests')
self.assertEqual(project.slug, 'rainboard-tests-2')
self.assertEqual(project.registry(), 'memmos.laas.fr:5000')
self.assertEqual(project.url_travis(), 'https://travis-ci.org/gepetto/rainboard-tests')
self.assertEqual(project.url_gitlab(), 'https://gitlab.laas.fr/gepetto/rainboard-tests')
self.assertEqual(project.url_travis(), 'https://travis-ci.org/gepetto/rainboard-tests-2')
self.assertEqual(project.url_gitlab(), 'https://gitlab.laas.fr/gepetto/rainboard-tests-2')
badges = project.badges()
for chunk in ['<img src="https://gitlab.laas', 'travis-ci', 'href="https://gepettoweb.laas']:
self.assertIn(chunk, badges)
......@@ -50,7 +50,7 @@ class RainboardTests(TestCase):
content = response.content.decode()
for chunk in [
'<title>Gepetto Packages</title>',
'<h1>rainboard tests</h1>',
'<h1>rainboard tests 2</h1>',
'Main forge</dt> <dd class="col-9"><a href="https://github.com">Github</a></dd>',
'<label class="label label-primary">BSD-2-Clause</label>',
]:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment