id
int64 0
843k
| repository_name
stringlengths 7
55
| file_path
stringlengths 9
332
| class_name
stringlengths 3
290
| human_written_code
stringlengths 12
4.36M
| class_skeleton
stringlengths 19
2.2M
| total_program_units
int64 1
9.57k
| total_doc_str
int64 0
4.2k
| AvgCountLine
float64 0
7.89k
| AvgCountLineBlank
float64 0
300
| AvgCountLineCode
float64 0
7.89k
| AvgCountLineComment
float64 0
7.89k
| AvgCyclomatic
float64 0
130
| CommentToCodeRatio
float64 0
176
| CountClassBase
float64 0
48
| CountClassCoupled
float64 0
589
| CountClassCoupledModified
float64 0
581
| CountClassDerived
float64 0
5.37k
| CountDeclInstanceMethod
float64 0
4.2k
| CountDeclInstanceVariable
float64 0
299
| CountDeclMethod
float64 0
4.2k
| CountDeclMethodAll
float64 0
4.2k
| CountLine
float64 1
115k
| CountLineBlank
float64 0
9.01k
| CountLineCode
float64 0
94.4k
| CountLineCodeDecl
float64 0
46.1k
| CountLineCodeExe
float64 0
91.3k
| CountLineComment
float64 0
27k
| CountStmt
float64 1
93.2k
| CountStmtDecl
float64 0
46.1k
| CountStmtExe
float64 0
90.2k
| MaxCyclomatic
float64 0
759
| MaxInheritanceTree
float64 0
16
| MaxNesting
float64 0
34
| SumCyclomatic
float64 0
6k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
145,848 |
Linaro/squad
|
Linaro_squad/squad/api/filters.py
|
squad.api.filters.ComplexFilterBackend
|
class ComplexFilterBackend(RestFrameworkFilterBackend):
complex_filter_param = 'filters'
operators = None
negation = True
def filter_queryset(self, request, queryset, view):
if self.complex_filter_param not in request.query_params:
return super().filter_queryset(request, queryset, view)
# Decode the set of complex operations
encoded_querystring = request.query_params[self.complex_filter_param]
try:
complex_ops = decode_complex_ops(encoded_querystring, self.operators, self.negation)
except ValidationError as exc:
raise ValidationError({self.complex_filter_param: exc.detail})
# Collect the individual filtered querysets
querystrings = [op.querystring for op in complex_ops]
try:
querysets = self.get_filtered_querysets(querystrings, request, queryset, view)
except ValidationError as exc:
raise ValidationError({self.complex_filter_param: exc.detail})
return combine_complex_queryset(querysets, complex_ops)
def get_filtered_querysets(self, querystrings, request, queryset, view):
original_GET = request._request.GET
querysets, errors = [], {}
for qs in querystrings:
request._request.GET = QueryDict(qs)
try:
result = super().filter_queryset(request, queryset, view)
querysets.append(result)
except ValidationError as exc:
errors[qs] = exc.detail
finally:
request._request.GET = original_GET
if errors:
raise ValidationError(errors)
return querysets
|
class ComplexFilterBackend(RestFrameworkFilterBackend):
def filter_queryset(self, request, queryset, view):
pass
def get_filtered_querysets(self, querystrings, request, queryset, view):
pass
| 3 | 0 | 18 | 3 | 15 | 1 | 4 | 0.06 | 1 | 1 | 0 | 0 | 2 | 0 | 2 | 3 | 42 | 7 | 33 | 16 | 30 | 2 | 32 | 14 | 29 | 4 | 2 | 2 | 8 |
145,849 |
Linaro/squad
|
Linaro_squad/squad/api/apps.py
|
squad.api.apps.ApiConfig
|
class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.AutoField'
name = 'squad.api'
|
class ApiConfig(AppConfig):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,850 |
Linaro/squad
|
Linaro_squad/squad/api/__init__.py
|
squad.api.SocialUserRateThrottle
|
class SocialUserRateThrottle(UserRateThrottle):
"""
Limits the rate of API calls that may be made by a given social user.
The user id will be used as a unique cache key if the user is
authenticated. For anonymous requests, the IP address of the request will
be used.
"""
scope = "socialuser"
def is_social_user(self, user):
"""
Social account user might use multiple applications (github, gitlab, google, ...)
to log in. But all of the login applications would likely point to the same
django user, which is what we want to rate limit here.
"""
key = f"socialuser#{user.id}"
from allauth.socialaccount.models import SocialAccount
return cache.get_or_set(key, SocialAccount.objects.filter(user_id=user.id).exists())
def get_cache_key(self, request, view):
if request.user and request.user.is_authenticated:
if not self.is_social_user(request.user):
# do not throttle non-social users
return None
ident = request.user.pk
else:
ident = self.get_ident(request)
return self.cache_format % {
"scope": self.scope,
"ident": ident
}
|
class SocialUserRateThrottle(UserRateThrottle):
'''
Limits the rate of API calls that may be made by a given social user.
The user id will be used as a unique cache key if the user is
authenticated. For anonymous requests, the IP address of the request will
be used.
'''
def is_social_user(self, user):
'''
Social account user might use multiple applications (github, gitlab, google, ...)
to log in. But all of the login applications would likely point to the same
django user, which is what we want to rate limit here.
'''
pass
def get_cache_key(self, request, view):
pass
| 3 | 2 | 12 | 2 | 8 | 4 | 2 | 0.76 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 2 | 36 | 7 | 17 | 7 | 13 | 13 | 13 | 7 | 9 | 3 | 1 | 2 | 4 |
145,851 |
Linaro/squad
|
Linaro_squad/squad/admin.py
|
squad.admin.NoDeleteListingModelAdmin
|
class NoDeleteListingModelAdmin(ModelAdmin):
"""
ModelAdmin without list of objects being deleted
"""
def get_deleted_objects(self, objs, request):
"""
Find all objects related to ``objs`` that should also be deleted. ``objs``
must be a homogeneous iterable of objects (e.g. a QuerySet).
Return a nested list of strings suitable for display in the
template with the ``unordered_list`` filter.
NOTE: this implementation just ignore generating a list of objects to be
deleted. In some objects, there are millions of records related, and this
wouldn't be practical to load a list of objects.
ref: https://github.com/django/django/blob/d6aff369ad33457ae2355b5b210faf1c4890ff35/django/contrib/admin/utils.py#L103
"""
to_delete = [_('List of objects to be deleted is disabled')]
model_count = {}
perms_needed = set()
protected = []
return to_delete, model_count, perms_needed, protected
|
class NoDeleteListingModelAdmin(ModelAdmin):
'''
ModelAdmin without list of objects being deleted
'''
def get_deleted_objects(self, objs, request):
'''
Find all objects related to ``objs`` that should also be deleted. ``objs``
must be a homogeneous iterable of objects (e.g. a QuerySet).
Return a nested list of strings suitable for display in the
template with the ``unordered_list`` filter.
NOTE: this implementation just ignore generating a list of objects to be
deleted. In some objects, there are millions of records related, and this
wouldn't be practical to load a list of objects.
ref: https://github.com/django/django/blob/d6aff369ad33457ae2355b5b210faf1c4890ff35/django/contrib/admin/utils.py#L103
'''
pass
| 2 | 2 | 20 | 4 | 6 | 10 | 1 | 1.86 | 1 | 1 | 0 | 5 | 1 | 0 | 1 | 1 | 24 | 4 | 7 | 6 | 5 | 13 | 7 | 6 | 5 | 1 | 1 | 0 | 1 |
145,852 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0166_build_is_release.py
|
squad.core.migrations.0166_build_is_release.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0165_buildsummary_uniqueness'),
]
operations = [
migrations.AddField(
model_name='build',
name='is_release',
field=models.BooleanField(default=False, help_text='Indication whether the build is considered a release'),
),
migrations.AddField(
model_name='build',
name='release_label',
field=models.CharField(blank=True, help_text='Name or label applied to the release build', max_length=64, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 18 | 2 | 16 | 3 | 15 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,853 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0167_add_project_datetime.py
|
squad.core.migrations.0167_add_project_datetime.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0166_build_is_release'),
]
operations = [
migrations.AddField(
model_name='project',
name='datetime',
field=models.DateTimeField(blank=True, default=timezone.now),
),
migrations.RunPython(
set_project_datetime,
reverse_code=migrations.RunPython.noop
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 17 | 2 | 15 | 3 | 14 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,854 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0168_add_group_settings.py
|
squad.core.migrations.0168_add_group_settings.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0167_add_project_datetime'),
]
operations = [
migrations.AddField(
model_name='group',
name='settings',
field=models.TextField(blank=True, null=True, validators=[squad.core.utils.yaml_validator]),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,855 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0169_userpreferences.py
|
squad.core.migrations.0169_userpreferences.Migration
|
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("core", "0168_add_group_settings"),
]
operations = [
migrations.CreateModel(
name="UserPreferences",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("display_failures_only", models.BooleanField(default=True)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 31 | 2 | 29 | 3 | 28 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,856 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.PluginScratch
|
class PluginScratch(models.Model):
"""
This object is meant to be used by plugins for storing
temporary data that is too big to be sent via message
queue.
"""
build = models.ForeignKey(Build, on_delete=models.CASCADE)
storage = models.TextField(null=True, blank=True)
|
class PluginScratch(models.Model):
'''
This object is meant to be used by plugins for storing
temporary data that is too big to be sent via message
queue.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1.67 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 0 | 3 | 3 | 2 | 5 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,857 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.Project
|
class Project(models.Model, DisplayName):
objects = ProjectManager()
group = models.ForeignKey(Group, related_name='projects', on_delete=models.CASCADE)
slug = models.CharField(max_length=100, validators=[slug_validator], db_index=True, verbose_name=N_('Slug'))
name = models.CharField(max_length=100, null=True, blank=True, verbose_name=N_('Name'))
is_public = models.BooleanField(default=True, verbose_name=N_('Is public'))
html_mail = models.BooleanField(default=True)
moderate_notifications = models.BooleanField(default=False)
custom_email_template = models.ForeignKey(EmailTemplate, null=True, blank=True, on_delete=models.CASCADE)
description = models.TextField(null=True, blank=True, verbose_name=N_('Description'))
important_metadata_keys = models.TextField(null=True, blank=True)
datetime = models.DateTimeField(default=timezone.now, blank=True)
enabled_plugins_list = PluginListField(
null=True,
blank=True,
features=[
Plugin.postprocess_testrun,
Plugin.postprocess_testjob,
],
)
wait_before_notification = models.IntegerField(
help_text=N_('Wait this many seconds before sending notifications'),
null=True,
blank=True,
)
notification_timeout = models.IntegerField(
help_text=N_('Force sending build notifications after this many seconds'),
null=True,
blank=True,
)
data_retention_days = models.IntegerField(
default=0,
help_text=N_("Delete builds older than this number of days. Set to 0 or any negative number to disable."),
)
project_settings = models.TextField(
null=True,
blank=True,
validators=[yaml_validator]
)
is_archived = models.BooleanField(
default=False,
help_text=N_('Makes the project hidden from the group page by default'),
verbose_name=N_('Is archived'),
)
force_finishing_builds_on_timeout = models.BooleanField(
default=False,
help_text=N_('Forces builds to finish when "Notification timeout" is reached'),
)
build_confidence_count = models.IntegerField(
default=20,
help_text=N_('Number of previous builds to compare to'),
)
build_confidence_threshold = models.IntegerField(
default=90,
help_text=N_('Percentage of previous builds that built successfully'),
)
def __init__(self, *args, **kwargs):
super(Project, self).__init__(*args, **kwargs)
self.__status__ = None
@property
def status(self):
if not self.__status__:
try:
self.__status__ = ProjectStatus.objects.filter(
build__project=self
).latest('created_at')
except ProjectStatus.DoesNotExist:
pass
return self.__status__
def accessible_to(self, user):
return self.is_public or self.group.accessible_to(user)
def can_submit_testjobs(self, user):
return self.group.can_submit_testjobs(user)
def can_submit_results(self, user):
return self.group.can_submit_results(user)
def writable_by(self, user):
return self.group.writable_by(user)
def is_subscribed(self, user):
if self.subscriptions.filter(user=user):
return True
return False
@property
def full_name(self):
return str(self.group) + '/' + self.slug
def __str__(self):
return self.full_name
class Meta:
unique_together = ('group', 'slug',)
ordering = ['group', 'slug']
@property
def enabled_plugins(self):
return self.enabled_plugins_list
__settings__ = None
def get_setting(self, key, default=None):
if self.__settings__ is None:
self.__settings__ = yaml.safe_load(self.project_settings or '') or {}
return self.__settings__.get(key, default)
|
class Project(models.Model, DisplayName):
def __init__(self, *args, **kwargs):
pass
@property
def status(self):
pass
def accessible_to(self, user):
pass
def can_submit_testjobs(self, user):
pass
def can_submit_results(self, user):
pass
def writable_by(self, user):
pass
def is_subscribed(self, user):
pass
@property
def full_name(self):
pass
def __str__(self):
pass
class Meta:
@property
def enabled_plugins(self):
pass
def get_setting(self, key, default=None):
pass
| 16 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 2 | 3 | 1 | 0 | 11 | 1 | 11 | 12 | 118 | 21 | 97 | 40 | 81 | 0 | 57 | 37 | 44 | 3 | 2 | 2 | 15 |
145,858 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.ProjectManager
|
class ProjectManager(models.Manager):
def accessible_to(self, user):
if user.is_superuser or user.is_staff:
return self.all()
else:
groups = Group.objects.filter(members__id=user.id).only('id') if user.id else []
return self.filter(Q(group__in=groups) | Q(is_public=True))
|
class ProjectManager(models.Manager):
def accessible_to(self, user):
pass
| 2 | 0 | 6 | 0 | 6 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 8 | 1 | 7 | 3 | 5 | 0 | 6 | 3 | 4 | 3 | 1 | 1 | 3 |
145,859 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.ProjectStatus
|
class ProjectStatus(models.Model, TestSummaryBase):
"""
Represents a "checkpoint" of a project status in time. It is used by the
notification system to know what was the project status at the time of the
last notification.
"""
build = models.OneToOneField('Build', related_name='status', on_delete=models.CASCADE)
baseline = models.ForeignKey('Build', related_name='next_statuses', on_delete=models.SET_NULL, null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(null=True)
finished = models.BooleanField(default=False)
notified = models.BooleanField(default=False)
notified_on_timeout = models.BooleanField(default=None, null=True)
approved = models.BooleanField(default=False)
metrics_summary = models.FloatField(null=True)
has_metrics = models.BooleanField(default=False)
tests_pass = models.IntegerField(default=0)
tests_fail = models.IntegerField(default=0)
tests_xfail = models.IntegerField(default=0)
tests_skip = models.IntegerField(default=0)
test_runs_total = models.IntegerField(default=0)
test_runs_completed = models.IntegerField(default=0)
test_runs_incomplete = models.IntegerField(default=0)
regressions = models.TextField(
null=True,
blank=True,
validators=[yaml_validator]
)
fixes = models.TextField(
null=True,
blank=True,
validators=[yaml_validator]
)
metric_regressions = models.TextField(
null=True,
blank=True,
validators=[yaml_validator]
)
metric_fixes = models.TextField(
null=True,
blank=True,
validators=[yaml_validator]
)
class Meta:
verbose_name_plural = "Project statuses"
@classmethod
def create_or_update(cls, build):
"""
Creates (or updates) a new ProjectStatus for the given build and
returns it.
"""
test_summary = build.test_summary
metrics_summary = MetricsSummary(build)
now = timezone.now()
test_runs_completed = build.test_runs.filter(completed=True).count()
test_runs_incomplete = build.test_runs.filter(completed=False).count()
test_runs_total = test_runs_completed + test_runs_incomplete
regressions = None
fixes = None
metric_regressions = None
metric_fixes = None
previous_build = None
if build.status is not None and build.status.baseline is not None:
previous_build = build.status.baseline
else:
previous_build = Build.objects.filter(
status__finished=True,
datetime__lt=build.datetime,
project=build.project,
).order_by('datetime').last()
# Compute regressions and fixes only after build is finished
finished, _ = build.finished
if previous_build is not None and finished:
comparison = TestComparison(previous_build, build, regressions_and_fixes_only=True)
if comparison.regressions:
regressions = yaml.dump(comparison.regressions)
if comparison.fixes:
fixes = yaml.dump(comparison.fixes)
metric_comparison = MetricComparison(previous_build, build, regressions_and_fixes_only=True)
if metric_comparison.regressions:
metric_regressions = yaml.dump(metric_comparison.regressions)
if metric_comparison.fixes:
metric_fixes = yaml.dump(metric_comparison.fixes)
data = {
'tests_pass': test_summary.tests_pass,
'tests_fail': test_summary.tests_fail,
'tests_xfail': test_summary.tests_xfail,
'tests_skip': test_summary.tests_skip,
'metrics_summary': metrics_summary.value,
'has_metrics': metrics_summary.has_metrics,
'last_updated': now,
'finished': finished,
'test_runs_total': test_runs_total,
'test_runs_completed': test_runs_completed,
'test_runs_incomplete': test_runs_incomplete,
'regressions': regressions,
'fixes': fixes,
'metric_regressions': metric_regressions,
'metric_fixes': metric_fixes,
'baseline': previous_build,
}
status, created = cls.objects.get_or_create(
build=build,
defaults=data)
if not created and test_summary.tests_total >= status.tests_total:
# XXX the test above for the new total number of tests prevents
# results that arrived earlier, but are only being processed now,
# from overwriting a ProjectStatus created by results that arrived
# later but were already processed.
status.tests_pass = test_summary.tests_pass
status.tests_fail = test_summary.tests_fail
status.tests_xfail = test_summary.tests_xfail
status.tests_skip = test_summary.tests_skip
status.metrics_summary = metrics_summary.value
status.has_metrics = metrics_summary.has_metrics
status.last_updated = now
status.finished = finished
status.build = build
status.baseline = previous_build
status.test_runs_total = test_runs_total
status.test_runs_completed = test_runs_completed
status.test_runs_incomplete = test_runs_incomplete
status.regressions = regressions
status.fixes = fixes
status.metric_regressions = metric_regressions
status.metric_fixes = metric_fixes
status.save()
status.build.project.datetime = now
status.build.project.save()
return status
def __str__(self):
return "%s, build %s" % (self.build.project, self.build.version)
def get_previous(self):
if self.baseline is None:
previous_status = ProjectStatus.objects.filter(
finished=True,
build__datetime__lt=self.build.datetime,
build__project=self.build.project,
).order_by('build__datetime').last()
if previous_status is not None:
self.baseline = previous_status.build
self.save()
if hasattr(self.baseline, 'status'):
return self.baseline.status
return None
def __get_yaml_field__(self, field_value):
if field_value is None:
return {}
try:
return yaml.load(field_value, Loader=yaml.Loader)
except yaml.YAMLError:
return {}
def get_regressions(self):
return self.__get_yaml_field__(self.regressions)
def get_fixes(self):
return self.__get_yaml_field__(self.fixes)
def get_metric_regressions(self):
return self.__get_yaml_field__(self.metric_regressions)
def get_metric_fixes(self):
return self.__get_yaml_field__(self.metric_fixes)
def get_exceeded_thresholds(self):
# Return a list of all (threshold, metric) objects for those
# thresholds that were exceeded by corresponding metrics.
if not self.has_metrics:
return []
thresholds_exceeded = []
thresholds = MetricThreshold.objects.filter(project=self.build.project, value__isnull=False).prefetch_related('project')
for threshold in thresholds:
environments = threshold.project.environments.all() if threshold.environment is None else [threshold.environment]
queryset = Metric.objects.annotate(fullname=Concat(F('metadata__suite'), Value('/'), F('metadata__name'))).filter(
fullname__regex=threshold.name_regex,
environment__in=environments,
build=self.build)
queryset = queryset.filter(result__lt=threshold.value) if threshold.is_higher_better else queryset.filter(result__gt=threshold.value)
metrics = queryset.prefetch_related('metadata').distinct()
thresholds_exceeded += [(threshold, m) for m in metrics]
return thresholds_exceeded
|
class ProjectStatus(models.Model, TestSummaryBase):
'''
Represents a "checkpoint" of a project status in time. It is used by the
notification system to know what was the project status at the time of the
last notification.
'''
class Meta:
@classmethod
def create_or_update(cls, build):
'''
Creates (or updates) a new ProjectStatus for the given build and
returns it.
'''
pass
def __str__(self):
pass
def get_previous(self):
pass
def __get_yaml_field__(self, field_value):
pass
def get_regressions(self):
pass
def get_fixes(self):
pass
def get_metric_regressions(self):
pass
def get_metric_fixes(self):
pass
def get_exceeded_thresholds(self):
pass
| 12 | 2 | 16 | 1 | 13 | 1 | 3 | 0.1 | 2 | 6 | 6 | 0 | 8 | 0 | 9 | 15 | 205 | 28 | 161 | 57 | 149 | 16 | 113 | 56 | 102 | 8 | 2 | 2 | 25 |
145,860 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/exceptions.py
|
squad.core.tasks.exceptions.DuplicatedTestJob
|
class DuplicatedTestJob(Exception):
pass
|
class DuplicatedTestJob(Exception):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
145,861 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/exceptions.py
|
squad.core.tasks.exceptions.InvalidMetadata
|
class InvalidMetadata(Exception):
pass
|
class InvalidMetadata(Exception):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
145,862 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/exceptions.py
|
squad.core.tasks.exceptions.InvalidMetadataJSON
|
class InvalidMetadataJSON(Exception):
pass
|
class InvalidMetadataJSON(Exception):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
145,863 |
Linaro/squad
|
Linaro_squad/test/ci/test_models.py
|
test.ci.test_models.BackendTest
|
class BackendTest(TestCase):
def test_basics(self):
models.Backend(
url='http://example.com',
username='foobar',
token='mypassword'
)
def test_implementation(self):
backend = models.Backend()
impl = backend.get_implementation()
self.assertIsInstance(impl, Backend)
|
class BackendTest(TestCase):
def test_basics(self):
pass
def test_implementation(self):
pass
| 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 2 | 0 | 2 | 0 | 2 | 2 | 13 | 2 | 11 | 5 | 8 | 0 | 7 | 5 | 4 | 1 | 1 | 0 | 2 |
145,864 |
Linaro/squad
|
Linaro_squad/test/ci/test_models.py
|
test.ci.test_models.BackendTestBase
|
class BackendTestBase(TestCase):
def setUp(self):
self.group = core_models.Group.objects.create(slug='mygroup')
self.project = self.group.projects.create(slug='myproject')
self.backend = models.Backend.objects.create()
self.build = self.project.builds.create(version='1')
def create_test_job(self, **attrs):
return self.backend.test_jobs.create(target=self.project, target_build=self.build, **attrs)
|
class BackendTestBase(TestCase):
def setUp(self):
pass
def create_test_job(self, **attrs):
pass
| 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 1 | 1 | 3 | 2 | 4 | 2 | 2 | 10 | 2 | 8 | 7 | 5 | 0 | 8 | 7 | 5 | 1 | 1 | 0 | 2 |
145,865 |
Linaro/squad
|
Linaro_squad/test/core/test_attachment.py
|
test.core.test_attachment.TestAttachment
|
class TestAttachment(TestCase):
def setUp(self):
self.group = Group.objects.create(slug="mygroup")
self.project = self.group.projects.create(slug="myproject")
self.build = self.project.builds.create(version="1")
self.env = self.project.environments.create(slug="myenv")
self.test_run = TestRun.objects.create(build=self.build, environment=self.env)
def test_basics(self):
data = 'abc'.encode('utf-8')
filename = 'foo.txt'
attachment = Attachment(
test_run=self.test_run, length=3, filename=filename
)
attachment.save()
attachment.save_file(filename, data)
fromdb = Attachment.objects.get(pk=attachment.pk)
self.assertEqual(b"abc", fromdb.data)
def test_storage_fields(self):
filename = 'foo.txt'
contents = b'attachment file content'
attachment = Attachment.objects.create(test_run=self.test_run, filename=filename, length=len(contents))
self.assertFalse(attachment.storage)
attachment.save_file(filename, contents)
attachment.refresh_from_db()
self.assertEqual(contents, attachment.storage.read())
|
class TestAttachment(TestCase):
def setUp(self):
pass
def test_basics(self):
pass
def test_storage_fields(self):
pass
| 4 | 0 | 10 | 2 | 8 | 0 | 1 | 0 | 1 | 2 | 2 | 0 | 3 | 5 | 3 | 3 | 33 | 8 | 25 | 16 | 21 | 0 | 23 | 16 | 19 | 1 | 1 | 0 | 3 |
145,866 |
Linaro/squad
|
Linaro_squad/test/core/test_build_summary.py
|
test.core.test_build_summary.BuildSummaryTest
|
class BuildSummaryTest(TestCase):
def setUp(self):
self.group = Group.objects.create(slug='mygroup')
self.project = self.group.projects.create(slug='myproject')
self.build1 = self.project.builds.create(version='1')
self.build2 = self.project.builds.create(version='2')
self.env1 = self.project.environments.create(slug='env1')
self.env2 = self.project.environments.create(slug='env2')
self.suite1 = self.project.suites.create(slug='suite1')
self.suite2 = self.project.suites.create(slug='suite2')
foo_metadata, _ = SuiteMetadata.objects.get_or_create(suite=self.suite1.slug, name='foo', kind='metric')
bar_metadata, _ = SuiteMetadata.objects.get_or_create(suite=self.suite1.slug, name='bar', kind='metric')
baz_metadata, _ = SuiteMetadata.objects.get_or_create(suite=self.suite2.slug, name='baz', kind='metric')
qux_metadata, _ = SuiteMetadata.objects.get_or_create(suite=self.suite2.slug, name='qux', kind='metric')
test_run1 = self.build1.test_runs.create(environment=self.env1)
test_run1.metrics.create(metadata=foo_metadata, suite=self.suite1, result=1, build=test_run1.build, environment=test_run1.environment)
test_run1.metrics.create(metadata=bar_metadata, suite=self.suite1, result=2, build=test_run1.build, environment=test_run1.environment)
test_run1.metrics.create(metadata=baz_metadata, suite=self.suite2, result=3, build=test_run1.build, environment=test_run1.environment)
test_run1.metrics.create(metadata=qux_metadata, suite=self.suite2, result=4, build=test_run1.build, environment=test_run1.environment)
test_run2 = self.build1.test_runs.create(environment=self.env2)
test_run2.metrics.create(metadata=foo_metadata, suite=self.suite1, result=2, build=test_run2.build, environment=test_run2.environment)
test_run2.metrics.create(metadata=bar_metadata, suite=self.suite1, result=4, build=test_run2.build, environment=test_run2.environment)
test_run2.metrics.create(metadata=baz_metadata, suite=self.suite2, result=6, build=test_run2.build, environment=test_run2.environment)
test_run2.metrics.create(metadata=qux_metadata, suite=self.suite2, result=8, build=test_run2.build, environment=test_run2.environment)
known_issue = KnownIssue.objects.create(title='dummy_issue', test_name='suite2/qux')
known_issue.environments.add(self.env1)
known_issue.save()
tests_json = """
{
"suite1/foo": "pass",
"suite1/bar": "fail",
"suite2/baz": "none",
"suite2/qux": "fail"
}
"""
self.receive_testrun = ReceiveTestRun(self.project, update_project_status=False)
self.receive_testrun(self.build1.version, self.env1.slug, tests_file=tests_json)
tests_json = """
{
"suite1/foo": "pass",
"suite1/bar": "fail",
"suite2/baz": "none"
}
"""
self.receive_testrun(self.build1.version, self.env2.slug, tests_file=tests_json)
def test_build_with_empty_metrics(self):
summary = BuildSummary.create_or_update(self.build2, self.env1)
self.assertFalse(summary.has_metrics)
def test_basic_build_summary(self):
values1 = [1, 2, 3, 4]
values2 = [2, 4, 6, 8]
summary1 = BuildSummary.create_or_update(self.build1, self.env1)
summary2 = BuildSummary.create_or_update(self.build1, self.env2)
self.assertTrue(summary1.has_metrics)
self.assertTrue(summary2.has_metrics)
self.assertTrue(eq(geomean(values1), summary1.metrics_summary))
self.assertTrue(eq(geomean(values2), summary2.metrics_summary))
self.assertEqual(4, summary1.tests_total)
self.assertEqual(1, summary1.tests_pass)
self.assertEqual(1, summary1.tests_fail)
self.assertEqual(1, summary1.tests_skip)
self.assertEqual(1, summary1.tests_xfail)
self.assertEqual(3, summary2.tests_total)
self.assertEqual(1, summary2.tests_pass)
self.assertEqual(1, summary2.tests_fail)
self.assertEqual(1, summary2.tests_skip)
self.assertEqual(0, summary2.tests_xfail)
def test_update_build_summary(self):
values1 = [1, 2, 3, 4, 5]
values2 = [2, 4, 6, 8]
new_test_run = self.build1.test_runs.create(environment=self.env1)
new_foo_metadata, _ = SuiteMetadata.objects.get_or_create(suite=self.suite1.slug, name='new_foo', kind='metric')
new_test_run.metrics.create(metadata=new_foo_metadata, suite=self.suite1, result=5, build=new_test_run.build, environment=new_test_run.environment)
self.receive_testrun(self.build1.version, self.env1.slug, tests_file='{"suite1/new_foo": "pass"}')
summary1 = BuildSummary.create_or_update(self.build1, self.env1)
summary2 = BuildSummary.create_or_update(self.build1, self.env2)
self.assertTrue(summary1.has_metrics)
self.assertTrue(eq(geomean(values1), summary1.metrics_summary))
self.assertTrue(summary2.has_metrics)
self.assertTrue(eq(geomean(values2), summary2.metrics_summary))
self.assertEqual(5, summary1.tests_total)
self.assertEqual(2, summary1.tests_pass)
self.assertEqual(1, summary1.tests_fail)
self.assertEqual(1, summary1.tests_skip)
self.assertEqual(1, summary1.tests_xfail)
self.assertEqual(3, summary2.tests_total)
self.assertEqual(1, summary2.tests_pass)
self.assertEqual(1, summary2.tests_fail)
self.assertEqual(1, summary2.tests_skip)
self.assertEqual(0, summary2.tests_xfail)
|
class BuildSummaryTest(TestCase):
def setUp(self):
pass
def test_build_with_empty_metrics(self):
pass
def test_basic_build_summary(self):
pass
def test_update_build_summary(self):
pass
| 5 | 0 | 26 | 4 | 22 | 0 | 1 | 0 | 1 | 4 | 4 | 0 | 4 | 9 | 4 | 4 | 108 | 18 | 90 | 33 | 85 | 0 | 77 | 33 | 72 | 1 | 1 | 0 | 4 |
145,867 |
Linaro/squad
|
Linaro_squad/test/core/test_emailtemplate.py
|
test.core.test_emailtemplate.TestEmailTemplateTest
|
class TestEmailTemplateTest(TestCase):
def setUp(self):
self.email_template = models.EmailTemplate()
self.email_template.name = 'fooTemplate'
self.email_template.plain_text = 'text template'
self.email_template.save()
def test_invalid_template_syntax(self):
emailTemplate = models.EmailTemplate.objects.get(name='fooTemplate')
emailTemplate.subject = 'This is a {{ template'
with self.assertRaises(ValidationError):
emailTemplate.full_clean()
def test_valid_template_syntax(self):
emailTemplate = models.EmailTemplate.objects.get(name='fooTemplate')
emailTemplate.subject = 'This is a {{ template }}'
self.assertEqual(emailTemplate.full_clean(), None)
|
class TestEmailTemplateTest(TestCase):
def setUp(self):
pass
def test_invalid_template_syntax(self):
pass
def test_valid_template_syntax(self):
pass
| 4 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 3 | 1 | 3 | 3 | 19 | 4 | 15 | 7 | 11 | 0 | 15 | 7 | 11 | 1 | 1 | 1 | 3 |
145,868 |
Linaro/squad
|
Linaro_squad/test/core/test_failures.py
|
test.core.test_failures.FailuresWithConfidenceTest
|
class FailuresWithConfidenceTest(TestCase):
def setUp(self):
self.group = Group.objects.create(slug='mygroup')
self.project = self.group.projects.create(slug='myproject')
def test_failures_with_confidence(self):
env = self.project.environments.create(slug="env")
suite = self.project.suites.create(slug="suite")
metadata, _ = SuiteMetadata.objects.get_or_create(suite=suite.slug, name="test", kind="test")
b1 = Build.objects.create(project=self.project, version='1.1')
tr1 = b1.test_runs.create(environment=env)
tr1.tests.create(build=tr1.build, environment=tr1.environment, suite=suite, metadata=metadata, result=True)
b2 = Build.objects.create(project=self.project, version='1.2')
tr2 = b2.test_runs.create(environment=env)
tr2.tests.create(build=tr2.build, environment=tr2.environment, suite=suite, metadata=metadata, result=True)
b3 = Build.objects.create(project=self.project, version='1.3')
tr3 = b3.test_runs.create(environment=env)
tr3.tests.create(build=tr3.build, environment=tr3.environment, suite=suite, metadata=metadata, result=False)
f1 = failures_with_confidence(self.project, b1, get_build_failures(b1))
self.assertEqual(len(f1), 0)
f2 = failures_with_confidence(self.project, b2, get_build_failures(b2))
self.assertEqual(len(f2), 0)
f3 = failures_with_confidence(self.project, b3, get_build_failures(b3))
self.assertEqual(len(f3), 1)
test = f3[0]
self.assertIsNotNone(test)
self.assertIsNotNone(test.confidence)
self.assertEqual(test.confidence.passes, 2)
self.assertEqual(test.confidence.count, 2)
self.assertEqual(test.confidence.score, 100)
self.assertEqual(test.confidence.threshold, self.project.build_confidence_threshold)
def test_failures_with_confidence_with_no_history(self):
env = self.project.environments.create(slug="env")
suite = self.project.suites.create(slug="suite")
metadata, _ = SuiteMetadata.objects.get_or_create(suite=suite.slug, name="test", kind="test")
b1 = Build.objects.create(project=self.project, version='1.1')
tr1 = b1.test_runs.create(environment=env)
tr1.tests.create(build=tr1.build, environment=tr1.environment, suite=suite, metadata=metadata, result=False)
f1 = failures_with_confidence(self.project, b1, get_build_failures(b1))
self.assertEqual(len(f1), 1)
test = f1[0]
self.assertIsNotNone(test)
self.assertIsNotNone(test.confidence)
self.assertEqual(test.confidence.passes, 0)
self.assertEqual(test.confidence.count, 0)
self.assertEqual(test.confidence.score, 0)
self.assertEqual(test.confidence.threshold, self.project.build_confidence_threshold)
|
class FailuresWithConfidenceTest(TestCase):
def setUp(self):
pass
def test_failures_with_confidence(self):
pass
def test_failures_with_confidence_with_no_history(self):
pass
| 4 | 0 | 18 | 3 | 15 | 0 | 1 | 0 | 1 | 2 | 2 | 0 | 3 | 2 | 3 | 3 | 59 | 13 | 46 | 26 | 42 | 0 | 46 | 26 | 42 | 1 | 1 | 0 | 3 |
145,869 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/exceptions.py
|
squad.core.tasks.exceptions.InvalidMetricsData
|
class InvalidMetricsData(Exception):
@classmethod
def type(cls, obj):
return cls("%r is not an object ({})" % obj)
@classmethod
def value(cls, value):
return cls("metric value %r is not valid. only numbers or lists of numbers are accepted" % value)
|
class InvalidMetricsData(Exception):
@classmethod
def type(cls, obj):
pass
@classmethod
def value(cls, value):
pass
| 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 12 | 8 | 1 | 7 | 5 | 2 | 0 | 5 | 3 | 2 | 1 | 3 | 0 | 2 |
145,870 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/exceptions.py
|
squad.core.tasks.exceptions.InvalidMetricsDataJSON
|
class InvalidMetricsDataJSON(Exception):
pass
|
class InvalidMetricsDataJSON(Exception):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
145,871 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/exceptions.py
|
squad.core.tasks.exceptions.InvalidTestsData
|
class InvalidTestsData(Exception):
@classmethod
def type(cls, obj):
return cls("%r is not an object ({})" % obj)
@classmethod
def value(cls, value):
return cls("%r is not a valid test result. Only \"pass\" and \"fail\" are accepted" % value)
|
class InvalidTestsData(Exception):
@classmethod
def type(cls, obj):
pass
@classmethod
def value(cls, value):
pass
| 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 2 | 12 | 8 | 1 | 7 | 5 | 2 | 0 | 5 | 3 | 2 | 1 | 3 | 0 | 2 |
145,872 |
Linaro/squad
|
Linaro_squad/squad/frontend/group_settings.py
|
squad.frontend.group_settings.GroupViewMixin
|
class GroupViewMixin(object):
def get_extra_form_kwargs(self):
return {}
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs.update(self.get_extra_form_kwargs())
return kwargs
@property
def group(self):
return self.request.group
def get_object(self):
return self.request.group
def get_extra_context_data(self):
return {}
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['group'] = self.request.group
context.update(self.get_extra_context_data())
return context
|
class GroupViewMixin(object):
def get_extra_form_kwargs(self):
pass
def get_form_kwargs(self):
pass
@property
def group(self):
pass
def get_object(self):
pass
def get_extra_context_data(self):
pass
def get_context_data(self, *args, **kwargs):
pass
| 8 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 4 | 6 | 0 | 6 | 6 | 25 | 6 | 19 | 10 | 11 | 0 | 18 | 9 | 11 | 1 | 1 | 0 | 6 |
145,873 |
Linaro/squad
|
Linaro_squad/squad/frontend/group_settings.py
|
squad.frontend.group_settings.GroupRelationshipForm
|
class GroupRelationshipForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['group'].widget = forms.HiddenInput()
self.fields['group'].disabled = True
|
class GroupRelationshipForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
pass
| 2 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 1 | 0 | 2 | 1 | 0 | 1 | 1 | 6 | 1 | 5 | 2 | 3 | 0 | 5 | 2 | 3 | 1 | 1 | 0 | 1 |
145,874 |
Linaro/squad
|
Linaro_squad/squad/frontend/group_settings.py
|
squad.frontend.group_settings.GroupMembersView
|
class GroupMembersView(GroupViewMixin, FormView):
template_name = 'squad/group_settings/members.jinja2'
form_class = GroupMemberForm
def dispatch(self, *args, **kwargs):
method = self.request.POST.get('_method', '').lower()
if method == 'delete':
return self.delete(*args, **kwargs)
elif method == 'put':
return self.put(*args, **kwargs)
else:
return super().dispatch(*args, **kwargs)
def __get_member__(self):
member_id = int(self.request.POST['member_id'])
return GroupMember.objects.filter(group=self.group).get(pk=member_id)
def put(self, *args, **kwargs):
member = self.__get_member__()
member.access = self.request.POST['access']
member.full_clean()
member.save()
return redirect(self.request.path)
def delete(self, *args, **kwargs):
self.__get_member__().delete()
return redirect(self.request.path)
def form_valid(self, form):
form.save()
return redirect(self.request.path)
def get_initial(self):
return {'group': self.group.id}
def get_extra_context_data(self):
return {
'members': GroupMember.objects.filter(group=self.group).prefetch_related('user').all(),
'access': GroupMember._meta.get_field('access').choices,
}
|
class GroupMembersView(GroupViewMixin, FormView):
def dispatch(self, *args, **kwargs):
pass
def __get_member__(self):
pass
def put(self, *args, **kwargs):
pass
def delete(self, *args, **kwargs):
pass
def form_valid(self, form):
pass
def get_initial(self):
pass
def get_extra_context_data(self):
pass
| 8 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 2 | 3 | 1 | 0 | 7 | 1 | 7 | 13 | 41 | 8 | 33 | 14 | 25 | 0 | 28 | 13 | 20 | 3 | 2 | 1 | 9 |
145,875 |
Linaro/squad
|
Linaro_squad/squad/frontend/group_settings.py
|
squad.frontend.group_settings.GroupMemberForm
|
class GroupMemberForm(GroupRelationshipForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['user'].queryset = self.fields['user'].queryset.order_by('username')
class Meta:
model = GroupMember
fields = ['group', 'user', 'access']
|
class GroupMemberForm(GroupRelationshipForm):
def __init__(self, *args, **kwargs):
pass
class Meta:
| 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 2 | 9 | 2 | 7 | 5 | 4 | 0 | 7 | 5 | 4 | 1 | 2 | 0 | 1 |
145,876 |
Linaro/squad
|
Linaro_squad/squad/frontend/group_settings.py
|
squad.frontend.group_settings.DeleteGroupView
|
class DeleteGroupView(GroupViewMixin, FormView):
template_name = 'squad/group_settings/delete.jinja2'
form_class = DeleteGroupForm
def get_extra_form_kwargs(self):
return {'deletable': self.group}
def form_valid(self, form):
for project in self.group.projects.all():
project.delete()
self.group.delete()
return redirect(reverse('home'))
|
class DeleteGroupView(GroupViewMixin, FormView):
def get_extra_form_kwargs(self):
pass
def form_valid(self, form):
pass
| 3 | 0 | 4 | 0 | 4 | 0 | 2 | 0 | 2 | 0 | 0 | 0 | 2 | 0 | 2 | 8 | 13 | 3 | 10 | 6 | 7 | 0 | 10 | 6 | 7 | 2 | 2 | 1 | 3 |
145,877 |
Linaro/squad
|
Linaro_squad/squad/frontend/group_settings.py
|
squad.frontend.group_settings.DeleteGroupForm
|
class DeleteGroupForm(DeleteConfirmationForm):
label = N_('Type the group slug (the name used in URLs) to confirm')
no_match_message = N_('The confirmation does not match the group slug')
|
class DeleteGroupForm(DeleteConfirmationForm):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 4 | 1 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 2 | 0 | 0 |
145,878 |
Linaro/squad
|
Linaro_squad/squad/frontend/group_settings.py
|
squad.frontend.group_settings.BaseSettingsView
|
class BaseSettingsView(GroupViewMixin, UpdateView):
template_name = 'squad/group_settings/index.jinja2'
form_class = GroupForm
def get_success_url(self):
return self.request.path
|
class BaseSettingsView(GroupViewMixin, UpdateView):
def get_success_url(self):
pass
| 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 2 | 0 | 0 | 0 | 1 | 0 | 1 | 7 | 7 | 2 | 5 | 4 | 3 | 0 | 5 | 4 | 3 | 1 | 2 | 0 | 1 |
145,879 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/exceptions.py
|
squad.core.tasks.exceptions.InvalidTestsDataJSON
|
class InvalidTestsDataJSON(Exception):
pass
|
class InvalidTestsDataJSON(Exception):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
145,880 |
Linaro/squad
|
Linaro_squad/squad/frontend/forms.py
|
squad.frontend.forms.DeleteConfirmationForm
|
class DeleteConfirmationForm(forms.Form):
confirmation = forms.CharField(label=N_('Type the slug (the name used in URLs) to confirm'))
label = None
no_match_message = N_('The confirmation does not match the slug')
def __init__(self, *args, **kwargs):
self.deletable = kwargs.pop('deletable')
super().__init__(*args, **kwargs)
if self.label:
self.fields['confirmation'].label = N_(self.label)
def clean(self):
cleaned_data = super().clean()
if cleaned_data['confirmation'] != self.deletable.slug:
self.add_error('confirmation', N_(self.no_match_message))
return cleaned_data
|
class DeleteConfirmationForm(forms.Form):
def __init__(self, *args, **kwargs):
pass
def clean(self):
pass
| 3 | 0 | 6 | 1 | 5 | 0 | 2 | 0 | 1 | 1 | 0 | 2 | 2 | 1 | 2 | 2 | 18 | 4 | 14 | 8 | 11 | 0 | 14 | 8 | 11 | 2 | 1 | 1 | 4 |
145,881 |
Linaro/squad
|
Linaro_squad/squad/frontend/build_settings.py
|
squad.frontend.build_settings.BuildSettingsView
|
class BuildSettingsView(UpdateView):
template_name = 'squad/build_settings.jinja2'
form_class = BuildSettingsForm
def get_object(self):
return get_build(self.request.project, self.args[2])
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(*args, **kwargs)
context['group'] = self.request.group
context['project'] = self.request.project
return context
def get_success_url(self):
return self.request.path
|
class BuildSettingsView(UpdateView):
def get_object(self):
pass
def get_context_data(self, *args, **kwargs):
pass
def get_success_url(self):
pass
| 4 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 3 | 15 | 3 | 12 | 7 | 8 | 0 | 12 | 7 | 8 | 1 | 1 | 0 | 3 |
145,882 |
Linaro/squad
|
Linaro_squad/test/core/test_group.py
|
test.core.test_group.GroupTest
|
class GroupTest(TestCase):
def setUp(self):
self.member = User.objects.create(username='u1')
self.non_member = User.objects.create(username='u2')
self.admin = User.objects.create(username='admin', is_superuser=True)
self.group = Group.objects.create(slug='mygroup', settings="some_setting: true")
self.group.add_admin(self.member)
def test_accessible_manager_non_member(self):
self.assertEqual(
[],
list(Group.objects.accessible_to(self.non_member))
)
def test_accessible_manager_member(self):
self.assertEqual(
[self.group],
list(Group.objects.accessible_to(self.member))
)
def test_accessible_manager_anonymous_user(self):
self.assertEqual(
[],
list(Group.objects.accessible_to(AnonymousUser()))
)
def test_accessible_manager_admin(self):
self.assertEqual(
[self.group],
list(Group.objects.accessible_to(self.admin))
)
def test_count_accessible_projects(self):
self.group.projects.create(slug='foo')
self.group.projects.create(slug='bar', is_public=False)
admin_groups = list(Group.objects.accessible_to(self.admin))
self.assertEqual(admin_groups[0].project_count, 2)
member_groups = list(Group.objects.accessible_to(self.member))
self.assertEqual(member_groups[0].project_count, 2)
anonymous_user_groups = list(Group.objects.accessible_to(AnonymousUser()))
self.assertEqual(anonymous_user_groups[0].project_count, 1)
def test_writable_by(self):
self.assertTrue(self.group.writable_by(self.member))
self.assertFalse(self.group.writable_by(self.non_member))
def test_settings(self):
self.assertTrue(self.group.get_setting('some_setting'))
|
class GroupTest(TestCase):
def setUp(self):
pass
def test_accessible_manager_non_member(self):
pass
def test_accessible_manager_member(self):
pass
def test_accessible_manager_anonymous_user(self):
pass
def test_accessible_manager_admin(self):
pass
def test_count_accessible_projects(self):
pass
def test_writable_by(self):
pass
def test_settings(self):
pass
| 9 | 0 | 6 | 1 | 5 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 8 | 4 | 8 | 8 | 54 | 13 | 41 | 16 | 32 | 0 | 29 | 16 | 20 | 1 | 1 | 0 | 8 |
145,883 |
Linaro/squad
|
Linaro_squad/test/core/test_group.py
|
test.core.test_group.TestGroupSlug
|
class TestGroupSlug(TestCase):
def test_does_not_accept_user_namespace_slug(self):
with self.assertRaises(ValidationError):
Group(slug='~foo').full_clean()
def test_invalid_slug(self):
group = Group(slug='foo/bar')
with self.assertRaises(ValidationError):
group.full_clean()
group.slug = 'foo-bar'
group.full_clean()
|
class TestGroupSlug(TestCase):
def test_does_not_accept_user_namespace_slug(self):
pass
def test_invalid_slug(self):
pass
| 3 | 0 | 5 | 0 | 5 | 1 | 1 | 0.1 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 2 | 12 | 2 | 10 | 4 | 7 | 1 | 10 | 4 | 7 | 1 | 1 | 1 | 2 |
145,884 |
Linaro/squad
|
Linaro_squad/test/core/test_historical_emailtemplate.py
|
test.core.test_historical_emailtemplate.TestHistoricalEmailTemplateTest
|
class TestHistoricalEmailTemplateTest(TestCase):
def setUp(self):
self.email_template = models.EmailTemplate()
self.email_template.name = 'name'
self.email_template.subject = 'subject'
self.email_template.plain_text = 'plain text'
self.email_template.html = 'html'
self.email_template.save()
self.history = models.EmailTemplate.history
def test_history_creation(self):
self.assertEqual(len(self.history.all()), 1)
def test_new_version(self):
"""
This is the main test, by default, any field that has been changed
will trigger a new version of the object
"""
self.email_template.name = 'other name'
self.email_template.save()
self.assertEqual(len(self.history.all()), 2)
self.email_template.subject = 'other subject'
self.email_template.save()
self.assertEqual(len(self.history.all()), 3)
self.email_template.plain_text = 'other plain text'
self.email_template.save()
self.assertEqual(len(self.history.all()), 4)
self.email_template.html = 'other html'
self.email_template.save()
self.assertEqual(len(self.history.all()), 5)
original = self.history.last().instance
self.assertEqual(original.name, 'name')
self.assertEqual(original.subject, 'subject')
self.assertEqual(original.plain_text, 'plain text')
self.assertEqual(original.html, 'html')
def test_revert_to_previous_version(self):
email_template_id = self.email_template.id
self.email_template.name = 'other name'
self.email_template.subject = 'other subject'
self.email_template.plain_text = 'other plain text'
self.email_template.html = 'other html'
self.email_template.save()
self.email_template = self.history.earliest().instance
self.email_template.save()
self.assertEqual(len(self.history.all()), 3)
# Make sure to get fresh data from database
reverted_email_template = models.EmailTemplate.objects.get(pk=email_template_id)
self.assertEqual(reverted_email_template.name, 'name')
self.assertEqual(reverted_email_template.subject, 'subject')
self.assertEqual(reverted_email_template.plain_text, 'plain text')
self.assertEqual(reverted_email_template.html, 'html')
def test_cascading_deletion(self):
self.email_template.delete()
self.assertEqual(len(self.history.all()), 0)
|
class TestHistoricalEmailTemplateTest(TestCase):
def setUp(self):
pass
def test_history_creation(self):
pass
def test_new_version(self):
'''
This is the main test, by default, any field that has been changed
will trigger a new version of the object
'''
pass
def test_revert_to_previous_version(self):
pass
def test_cascading_deletion(self):
pass
| 6 | 1 | 12 | 2 | 9 | 1 | 1 | 0.11 | 1 | 1 | 1 | 0 | 5 | 2 | 5 | 5 | 66 | 14 | 47 | 11 | 41 | 5 | 47 | 11 | 41 | 1 | 1 | 0 | 5 |
145,885 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/__init__.py
|
squad.core.tasks.ValidateTestRun
|
class ValidateTestRun(object):
def __call__(self, metadata_file=None, metrics_file=None, tests_file=None):
if metadata_file:
self.__validate_metadata__(metadata_file)
if metrics_file:
self.__validate_metrics(metrics_file)
if tests_file:
self.__validate_tests__(tests_file)
def __validate_metadata__(self, metadata_json):
try:
metadata = json.loads(metadata_json)
except json.decoder.JSONDecodeError as e:
raise exceptions.InvalidMetadataJSON("metadata is not valid JSON: " + str(e) + "\n" + metadata_json)
if type(metadata) is not dict:
raise exceptions.InvalidMetadata("metadata is not a object ({})")
if "job_id" in metadata.keys():
if type(metadata['job_id']) not in [int, str]:
raise exceptions.InvalidMetadata('job_id should be an integer or a string')
if type(metadata['job_id']) is str and '/' in metadata['job_id']:
raise exceptions.InvalidMetadata('job_id cannot contain the "/" character')
def __validate_metrics(self, metrics_file):
try:
metrics = json.loads(metrics_file)
except json.decoder.JSONDecodeError as e:
raise exceptions.InvalidMetricsDataJSON("metrics is not valid JSON: " + str(e) + "\n" + metrics_file)
if type(metrics) is not dict:
raise exceptions.InvalidMetricsData.type(metrics)
for metric, value_dict in metrics.items():
if type(value_dict) is dict:
value = value_dict.get('value', None)
else:
value = value_dict
if type(value) is str:
try:
value = float(value)
except ValueError:
raise exceptions.InvalidMetricsData.value(value)
if type(value) not in [int, float, list]:
raise exceptions.InvalidMetricsData.value(value)
if type(value) is list:
for item in value:
if type(item) not in [int, float]:
raise exceptions.InvalidMetricsData.value(value)
def __validate_tests__(self, tests_file):
try:
tests = json.loads(tests_file)
except json.decoder.JSONDecodeError as e:
raise exceptions.InvalidTestsDataJSON("tests is not valid JSON: " + str(e) + "\n" + tests_file)
if type(tests) is not dict:
raise exceptions.InvalidTestsData.type(tests)
|
class ValidateTestRun(object):
def __call__(self, metadata_file=None, metrics_file=None, tests_file=None):
pass
def __validate_metadata__(self, metadata_json):
pass
def __validate_metrics(self, metrics_file):
pass
def __validate_tests__(self, tests_file):
pass
| 5 | 0 | 14 | 2 | 12 | 0 | 6 | 0 | 1 | 13 | 6 | 0 | 4 | 0 | 4 | 4 | 61 | 11 | 50 | 14 | 45 | 0 | 49 | 11 | 44 | 11 | 1 | 4 | 24 |
145,886 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0160_add_project_to_metricthreshold.py
|
squad.core.migrations.0160_add_project_to_metricthreshold.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0159_nullable_metricthreshold_value'),
]
operations = [
migrations.AddField(
model_name='metricthreshold',
name='project',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Project', default=None, null=True),
),
migrations.AlterUniqueTogether(
name='metricthreshold',
unique_together={('project', 'environment', 'name')},
),
migrations.AlterField(
model_name='metricthreshold',
name='environment',
field=models.ForeignKey(blank=True, null=True, default=None, on_delete=django.db.models.deletion.CASCADE, to='core.Environment'),
),
migrations.RunPython(populate_project, reverse_empty_envs),
migrations.AlterField(
model_name='metricthreshold',
name='project',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='thresholds', to='core.Project'),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 28 | 2 | 26 | 3 | 25 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,887 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/__init__.py
|
squad.core.tasks.UpdateProjectStatus
|
class UpdateProjectStatus(object):
@staticmethod
def __call__(testrun):
projectstatus = ProjectStatus.create_or_update(testrun.build)
if projectstatus.finished:
dispatch_callbacks_on_build_finished(testrun.build)
maybe_notify_project_status.delay(projectstatus.id)
|
class UpdateProjectStatus(object):
@staticmethod
def __call__(testrun):
pass
| 3 | 0 | 7 | 2 | 5 | 0 | 2 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 10 | 3 | 7 | 4 | 4 | 0 | 6 | 3 | 4 | 2 | 1 | 1 | 2 |
145,888 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/__init__.py
|
squad.core.tasks.RecordTestRunStatus
|
class RecordTestRunStatus(object):
@staticmethod
def __call__(testrun):
if testrun.status_recorded:
return
status = defaultdict(lambda: Status(test_run=testrun))
# Get number of passing tests per suite
passes = testrun.tests.filter(result=True).values('suite_id').annotate(pass_count=Count('suite_id')).order_by()
xfails = testrun.tests.filter(result=False, has_known_issues=True).values('suite_id').annotate(xfail_count=Count('suite_id')).order_by()
fails = testrun.tests.filter(result=False).exclude(has_known_issues=True).values('suite_id').annotate(fail_count=Count('suite_id')).order_by()
skips = testrun.tests.filter(result__isnull=True).values('suite_id').annotate(skip_count=Count('suite_id')).order_by()
for p in passes:
status[None].tests_pass += p['pass_count']
status[p['suite_id']].tests_pass += p['pass_count']
for x in xfails:
status[None].tests_xfail += x['xfail_count']
status[x['suite_id']].tests_xfail += x['xfail_count']
for f in fails:
status[None].tests_fail += f['fail_count']
status[f['suite_id']].tests_fail += f['fail_count']
for s in skips:
status[None].tests_skip += s['skip_count']
status[s['suite_id']].tests_skip += s['skip_count']
metrics = defaultdict(lambda: [])
for metric in testrun.metrics.all():
sid = metric.suite_id
for v in metric.measurement_list:
metrics[None].append(v)
metrics[sid].append(v)
# One Status has many test suites and each of one of them
# has their own summary (i.e. geomean).
# The status having no test suite (suite=None) represent
# the TestRun's summary
if len(metrics[None]):
status[None].has_metrics = True
for sid, values in metrics.items():
status[sid].metrics_summary = geomean(values)
status[sid].has_metrics = True
for sid, s in status.items():
s.suite_id = sid
s.suite_version = get_suite_version(testrun, s.suite)
s.save()
testrun.status_recorded = True
testrun.save()
|
class RecordTestRunStatus(object):
@staticmethod
def __call__(testrun):
pass
| 3 | 0 | 52 | 10 | 37 | 5 | 11 | 0.13 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 55 | 11 | 39 | 17 | 36 | 5 | 38 | 16 | 36 | 11 | 1 | 2 | 11 |
145,889 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.Status
|
class Status(models.Model, TestSummaryBase):
test_run = models.ForeignKey(TestRun, related_name='status', on_delete=models.CASCADE)
suite = models.ForeignKey(Suite, null=True, on_delete=models.CASCADE)
suite_version = models.ForeignKey(SuiteVersion, null=True, on_delete=models.CASCADE)
tests_pass = models.IntegerField(default=0)
tests_fail = models.IntegerField(default=0)
tests_xfail = models.IntegerField(default=0)
tests_skip = models.IntegerField(default=0)
metrics_summary = models.FloatField(default=0.0)
has_metrics = models.BooleanField(default=False)
objects = StatusManager()
class Meta:
unique_together = ('test_run', 'suite',)
@property
def environment(self):
return self.test_run.environment
@property
def tests(self):
return self.test_run.tests.filter(suite=self.suite)
@property
def metrics(self):
return self.test_run.metrics.filter(suite=self.suite)
def __str__(self):
if self.suite:
name = self.suite.slug + ' on ' + self.environment.slug
else:
name = self.environment.slug
return '%s: %f, %d%% pass' % (name, self.metrics_summary, self.pass_percentage)
|
class Status(models.Model, TestSummaryBase):
class Meta:
@property
def environment(self):
pass
@property
def tests(self):
pass
@property
def metrics(self):
pass
def __str__(self):
pass
| 9 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 2 | 0 | 0 | 0 | 4 | 0 | 4 | 10 | 35 | 7 | 28 | 21 | 19 | 0 | 24 | 18 | 18 | 2 | 2 | 1 | 5 |
145,890 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.StatusManager
|
class StatusManager(models.Manager):
def by_suite(self):
return self.exclude(suite=None)
def overall(self):
return self.filter(suite=None)
|
class StatusManager(models.Manager):
def by_suite(self):
pass
def overall(self):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 2 | 7 | 2 | 5 | 3 | 2 | 0 | 5 | 3 | 2 | 1 | 1 | 0 | 2 |
145,891 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.Subscription
|
class Subscription(models.Model):
project = models.ForeignKey(Project, related_name='subscriptions', on_delete=models.CASCADE)
email = models.CharField(
max_length=1024,
null=True,
blank=True,
validators=[EmailValidator()]
)
user = models.ForeignKey(
User,
null=True,
blank=True,
default=None,
on_delete=models.CASCADE,
)
NOTIFY_ALL_BUILDS = 'all'
NOTIFY_ON_CHANGE = 'change'
NOTIFY_ON_REGRESSION = 'regression'
NOTIFY_ON_ERROR = 'error'
STRATEGY_CHOICES = (
(NOTIFY_ALL_BUILDS, N_("All builds")),
(NOTIFY_ON_CHANGE, N_("Only on change")),
(NOTIFY_ON_REGRESSION, N_("Only on regression")),
(NOTIFY_ON_ERROR, N_("Only on infrastructure error")),
)
notification_strategy = models.CharField(
max_length=32,
choices=STRATEGY_CHOICES,
default='all'
)
class Meta:
unique_together = ('project', 'user',)
def _validate_email(self):
if (not self.email) == (not self.user):
raise ValidationError("Subscription object must have exactly one of 'user' and 'email' fields populated.")
def save(self, *args, **kwargs):
self._validate_email()
super().save(*args, **kwargs)
def clean(self):
self._validate_email()
def get_email(self):
if self.user and self.user.email:
return self.user.email
return self.email
def __str__(self):
return '%s on %s' % (self.get_email(), self.project)
|
class Subscription(models.Model):
class Meta:
def _validate_email(self):
pass
def save(self, *args, **kwargs):
pass
def clean(self):
pass
def get_email(self):
pass
def __str__(self):
pass
| 7 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 5 | 0 | 5 | 5 | 55 | 9 | 46 | 17 | 39 | 0 | 26 | 17 | 19 | 2 | 1 | 1 | 7 |
145,892 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.Suite
|
class Suite(models.Model):
project = models.ForeignKey(Project, related_name='suites', on_delete=models.CASCADE)
slug = models.CharField(max_length=256, validators=[slug_validator], db_index=True)
name = models.CharField(max_length=256, null=True, blank=True)
metadata = models.ForeignKey(
SuiteMetadata,
null=True,
related_name='+',
limit_choices_to={'kind': 'suite'},
on_delete=models.CASCADE,
)
class Meta:
unique_together = ('project', 'slug',)
def __str__(self):
return self.name or self.slug
|
class Suite(models.Model):
class Meta:
def __str__(self):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 17 | 2 | 15 | 8 | 12 | 0 | 9 | 8 | 6 | 1 | 1 | 0 | 1 |
145,893 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.SuiteMetadata
|
class SuiteMetadata(models.Model):
suite = models.CharField(max_length=256, db_index=True)
kind = models.CharField(
max_length=6,
choices=(
('suite', 'Suite'),
('test', 'Test'),
('metric', 'Metric'),
),
db_index=True,
)
name = models.CharField(max_length=256, null=True, db_index=True)
description = models.TextField(null=True, blank=True)
instructions_to_reproduce = models.TextField(null=True, blank=True)
class Meta:
unique_together = ('kind', 'suite', 'name')
verbose_name_plural = 'Suite metadata'
def __str__(self):
if self.name == '-':
return self.suite
else:
return join_name(self.suite, self.name)
|
class SuiteMetadata(models.Model):
class Meta:
def __str__(self):
pass
| 3 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 24 | 2 | 22 | 10 | 19 | 0 | 13 | 10 | 10 | 2 | 1 | 1 | 2 |
145,894 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.SuiteVersion
|
class SuiteVersion(models.Model):
suite = models.ForeignKey(Suite, related_name='versions', on_delete=models.CASCADE)
version = models.CharField(max_length=40, null=True)
first_seen = models.DateTimeField(auto_now_add=True)
class Meta:
unique_together = ('suite', 'version')
def __str__(self):
return '%s %s' % (self.suite.name, self.version)
|
class SuiteVersion(models.Model):
class Meta:
def __str__(self):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 10 | 2 | 8 | 7 | 5 | 0 | 8 | 7 | 5 | 1 | 1 | 0 | 1 |
145,895 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.Test
|
class Test(models.Model):
__test__ = False
build = models.ForeignKey(Build, related_name='tests', on_delete=models.CASCADE, null=True)
environment = models.ForeignKey(Environment, related_name='tests', on_delete=models.CASCADE, null=True)
test_run = models.ForeignKey(TestRun, related_name='tests', on_delete=models.CASCADE)
suite = models.ForeignKey(Suite, on_delete=models.CASCADE)
metadata = models.ForeignKey(
SuiteMetadata,
null=True,
related_name='+',
limit_choices_to={'kind': 'test'},
on_delete=models.CASCADE,
)
result = models.BooleanField(null=True)
log = models.TextField(null=True, blank=True)
known_issues = models.ManyToManyField('KnownIssue')
has_known_issues = models.BooleanField(null=True)
def __str__(self):
return self.name
@property
def name(self):
if self.metadata is None:
return 'missing test name'
return self.metadata.name
@property
def status(self):
if self.result:
return 'pass'
elif self.result is None:
return 'skip'
else:
if self.has_known_issues:
return 'xfail'
else:
return 'fail'
@property
def full_name(self):
suite = ''
if self.metadata is None:
suite = self.suite.slug
else:
suite = self.metadata.suite
return join_name(suite, self.name)
class Confidence(object):
def __init__(self, threshold, tests):
self.threshold = threshold
self.tests = tests
@property
def count(self):
return len(self.tests)
@property
def passes(self):
return sum(1 for t in self.tests if t.result)
@property
def score(self):
if not self.count:
return 0
return 100 * (self.passes / self.count)
__confidence__ = None
def set_confidence(self, threshold, tests):
self.__confidence__ = Test.Confidence(
threshold=threshold,
tests=tests,
)
@property
def confidence(self):
return self.__confidence__
class History(object):
def __init__(self, since, count, last_different):
self.since = since
self.count = count
self.last_different = last_different
__history__ = None
@property
def history(self):
if self.__history__:
return self.__history__
date = self.test_run.build.datetime
previous_tests = Test.objects.filter(
suite=self.suite,
metadata__name=self.name,
test_run__build__datetime__lt=date,
test_run__environment=self.test_run.environment,
).exclude(id=self.id).order_by("-test_run__build__datetime")
since = None
count = 0
last_different = None
for test in list(previous_tests):
if test.result == self.result:
since = test
count += 1
else:
last_different = test
break
self.__history__ = Test.History(since, count, last_different)
return self.__history__
class Meta:
ordering = ['metadata__name']
|
class Test(models.Model):
def __str__(self):
pass
@property
def name(self):
pass
@property
def status(self):
pass
@property
def full_name(self):
pass
class Confidence(object):
def __init__(self, threshold, tests):
pass
@property
def count(self):
pass
@property
def passes(self):
pass
@property
def score(self):
pass
def set_confidence(self, threshold, tests):
pass
@property
def confidence(self):
pass
class History(object):
def __init__(self, threshold, tests):
pass
@property
def history(self):
pass
class Meta:
| 24 | 0 | 6 | 0 | 6 | 0 | 2 | 0 | 1 | 3 | 2 | 0 | 7 | 0 | 7 | 7 | 117 | 19 | 98 | 50 | 74 | 0 | 71 | 41 | 55 | 4 | 1 | 2 | 21 |
145,896 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.TestRun
|
class TestRun(models.Model):
__test__ = False
build = models.ForeignKey(Build, related_name='test_runs', on_delete=models.CASCADE)
environment = models.ForeignKey(Environment, related_name='test_runs', on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True)
metadata_file = models.TextField(null=True)
tests_file_storage = models.FileField(null=True)
metrics_file_storage = models.FileField(null=True)
log_file_storage = models.FileField(null=True)
completed = models.BooleanField(default=True)
# fields that should be provided in a submitted metadata JSON
datetime = models.DateTimeField(null=False)
build_url = models.CharField(null=True, max_length=2048)
job_id = models.CharField(null=True, max_length=128)
job_status = models.CharField(null=True, max_length=128)
job_url = models.CharField(null=True, max_length=2048)
resubmit_url = models.CharField(null=True, max_length=2048)
data_processed = models.BooleanField(default=False)
status_recorded = models.BooleanField(default=False)
class Meta:
unique_together = ('build', 'job_id')
def save(self, *args, **kwargs):
if not self.datetime:
self.datetime = timezone.now()
if self.__metadata__:
self.metadata_file = json.dumps(self.__metadata__)
super(TestRun, self).save(*args, **kwargs)
def save_tests_file(self, tests_file):
storage_save(self, self.tests_file_storage, 'tests_file', tests_file)
self.__tests_file__ = tests_file
def save_metrics_file(self, metrics_file):
storage_save(self, self.metrics_file_storage, 'metrics_file', metrics_file)
self.__metrics_file__ = metrics_file
def save_log_file(self, log_file):
storage_save(self, self.log_file_storage, 'log_file', log_file)
self.__log_file__ = log_file
__tests_file__ = None
@property
def tests_file(self):
if self.__tests_file__ is None:
if self.tests_file_storage:
self.__tests_file__ = self.tests_file_storage.read().decode()
self.tests_file_storage.seek(0)
else:
self.__tests_file__ = ''
return self.__tests_file__
__metrics_file__ = None
@property
def metrics_file(self):
if self.__metrics_file__ is None:
if self.metrics_file_storage:
self.__metrics_file__ = self.metrics_file_storage.read().decode()
self.metrics_file_storage.seek(0)
else:
self.__metrics_file__ = ''
return self.__metrics_file__
__log_file__ = None
@property
def log_file(self):
if self.__log_file__ is None:
if self.log_file_storage:
self.__log_file__ = self.log_file_storage.read().decode()
self.log_file_storage.seek(0)
else:
self.__log_file__ = ''
return self.__log_file__
@property
def project(self):
return self.build.project
__metadata__ = None
@property
def metadata(self):
if self.__metadata__ is None:
if self.metadata_file:
self.__metadata__ = json.loads(self.metadata_file)
else:
self.__metadata__ = {}
return self.__metadata__
def __str__(self):
return self.job_id and ('#%s' % self.job_id) or ('(%s)' % self.id)
|
class TestRun(models.Model):
class Meta:
def save(self, *args, **kwargs):
pass
def save_tests_file(self, tests_file):
pass
def save_metrics_file(self, metrics_file):
pass
def save_log_file(self, log_file):
pass
@property
def tests_file(self):
pass
@property
def metrics_file(self):
pass
@property
def log_file(self):
pass
@property
def project(self):
pass
@property
def metadata(self):
pass
def __str__(self):
pass
| 17 | 0 | 5 | 0 | 5 | 0 | 2 | 0.03 | 1 | 1 | 0 | 0 | 10 | 0 | 10 | 10 | 101 | 21 | 79 | 39 | 62 | 2 | 70 | 34 | 58 | 3 | 1 | 2 | 20 |
145,897 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.TestSummary
|
class TestSummary(TestSummaryBase):
__test__ = False
def __init__(self, build, environment=None):
self.tests_pass = 0
self.tests_fail = 0
self.tests_xfail = 0
self.tests_skip = 0
query_set = Status.objects.filter(suite=None, test_run__build=build)
if environment:
query_set = query_set.filter(test_run__environment=environment)
stats = query_set.values('suite_id').annotate(Sum('tests_pass'), Sum('tests_fail'), Sum('tests_xfail'), Sum('tests_skip'))
for s in stats:
self.tests_pass = s['tests_pass__sum']
self.tests_fail = s['tests_fail__sum']
self.tests_xfail = s['tests_xfail__sum']
self.tests_skip = s['tests_skip__sum']
|
class TestSummary(TestSummaryBase):
def __init__(self, build, environment=None):
pass
| 2 | 0 | 16 | 2 | 14 | 0 | 3 | 0 | 1 | 1 | 1 | 0 | 1 | 4 | 1 | 7 | 20 | 4 | 16 | 10 | 14 | 0 | 16 | 10 | 14 | 3 | 2 | 1 | 3 |
145,898 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.TestSummaryBase
|
class TestSummaryBase(object):
__test__ = False
@property
def tests_total(self):
return self.tests_pass + self.tests_fail + self.tests_xfail + self.tests_skip
def __percent__(self, ntests):
if ntests > 0:
return 100 * (float(ntests) / float(self.tests_total))
else:
return 0
@property
def pass_percentage(self):
return self.__percent__(self.tests_pass)
@property
def fail_percentage(self):
return self.__percent__(self.tests_fail + self.tests_xfail)
@property
def skip_percentage(self):
return self.__percent__(self.tests_skip)
@property
def has_tests(self):
return self.tests_total > 0
|
class TestSummaryBase(object):
@property
def tests_total(self):
pass
def __percent__(self, ntests):
pass
@property
def pass_percentage(self):
pass
@property
def fail_percentage(self):
pass
@property
def skip_percentage(self):
pass
@property
def has_tests(self):
pass
| 12 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 4 | 6 | 0 | 6 | 6 | 29 | 7 | 22 | 13 | 10 | 0 | 16 | 8 | 9 | 2 | 1 | 1 | 7 |
145,899 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.UserNamespaceManager
|
class UserNamespaceManager(models.Manager):
@transaction.atomic
def create_for(self, user):
slug = '~' + user.username.replace('@', '')
ns = self.create(slug=slug)
ns.add_admin(user)
return ns
def get_queryset(self):
return super().get_queryset().filter(slug__startswith='~')
def get_for(self, user):
return self.get(slug='~' + user.username)
def get_or_create_for(self, user):
try:
return self.get_for(user)
except self.model.DoesNotExist:
return self.create_for(user)
|
class UserNamespaceManager(models.Manager):
@transaction.atomic
def create_for(self, user):
pass
def get_queryset(self):
pass
def get_for(self, user):
pass
def get_or_create_for(self, user):
pass
| 6 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 4 | 0 | 4 | 4 | 20 | 4 | 16 | 8 | 10 | 0 | 15 | 7 | 10 | 2 | 1 | 1 | 5 |
145,900 |
Linaro/squad
|
Linaro_squad/squad/core/models.py
|
squad.core.models.UserPreferences
|
class UserPreferences(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
display_failures_only = models.BooleanField(default=True)
|
class UserPreferences(models.Model):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,901 |
Linaro/squad
|
Linaro_squad/squad/core/notification.py
|
squad.core.notification.Notification
|
class Notification(object):
"""
Represents a notification about a project status change, that may or may
not need to be sent.
"""
def __init__(self, status, previous=None):
self.status = status
self.build = status.build
if previous is None:
previous = status.get_previous()
self.previous_build = previous and previous.build or None
__comparison__ = None
@property
def comparison(self):
if self.__comparison__ is None:
self.__comparison__ = TestComparison(
self.previous_build,
self.build,
regressions_and_fixes_only=True,
)
return self.__comparison__
@property
def diff(self):
return self.comparison.diff
@property
def project(self):
return self.build.project
@property
def metadata(self):
if self.build.metadata is not None:
return OrderedDict(sorted(self.build.metadata.items()))
else:
return {}
@property
def important_metadata(self):
return self.build.important_metadata
@property
def summary(self):
summary = self.build.test_summary
summary.failures = self.comparison.failures
return summary
@property
def recipients(self):
emails = []
for subscription in self.project.subscriptions.all():
if subscription.notification_strategy == Subscription.NOTIFY_ON_CHANGE:
if not self.previous_build or not self.diff:
continue
elif subscription.notification_strategy == Subscription.NOTIFY_ON_REGRESSION:
if not self.previous_build or \
len(self.comparison.regressions) == 0:
continue
elif subscription.notification_strategy == Subscription.NOTIFY_ON_ERROR:
if not self.project.project_settings:
logger.warn('CI_LAVA_JOB_ERROR_STATUS not set in project settings. Notification will not be sent for project %s, build %s.' % (self.project.full_name, self.build.version))
continue
settings = yaml.safe_load(self.project.project_settings) or {}
error_status = settings.get('CI_LAVA_JOB_ERROR_STATUS', None)
if not error_status:
logger.warn('CI_LAVA_JOB_ERROR_STATUS not set in project settings. Notification will not be sent for project %s, build %s.' % (self.project.full_name, self.build.version))
continue
if len(self.build.test_jobs.filter(job_status=error_status)) == 0:
continue
email = subscription.get_email()
if email:
emails.append(email)
return emails
@property
def known_issues(self):
return KnownIssue.active_by_project_and_test(self.project)
@property
def thresholds(self):
return self.status.get_exceeded_thresholds()
@property
def metrics(self):
return Metric.objects.filter(build=self.build).all()
@property
def subject(self):
return self.create_subject()
def create_subject(self, custom_email_template=None):
summary = self.summary
subject_data = {
'build': self.build.version,
'important_metadata': self.important_metadata,
'metadata': self.metadata,
'project': self.project,
'regressions': len(self.comparison.regressions),
'tests_fail': summary.tests_fail,
'tests_pass': summary.tests_pass,
'tests_total': summary.tests_total,
'tests_skip': summary.tests_skip,
}
if custom_email_template is None and self.project.custom_email_template is not None:
custom_email_template = self.project.custom_email_template
if custom_email_template and custom_email_template.subject:
template = custom_email_template.subject
else:
template = '{{project}}: {{tests_total}} tests, {{tests_fail}} failed, {{tests_pass}} passed, {{tests_skip}} skipped (build {{build}})'
return jinja2.from_string(template).render(subject_data)
def message(self, do_html=True, custom_email_template=None):
"""
Returns a tuple with (text_message,html_message)
"""
context = {
'build': self.build,
'important_metadata': self.important_metadata,
'metadata': self.metadata,
'notification': self,
'previous_build': self.previous_build,
'regressions_grouped_by_suite': self.comparison.regressions_grouped_by_suite,
'fixes_grouped_by_suite': self.comparison.fixes_grouped_by_suite,
'known_issues': self.known_issues,
'regressions': self.comparison.regressions,
'fixes': self.comparison.fixes,
'thresholds': self.thresholds,
'settings': settings,
'summary': self.summary,
'metrics': self.metrics,
}
html_message = ''
if custom_email_template:
text_template = jinja2.from_string(custom_email_template.plain_text)
text_message = text_template.render(context)
if do_html:
html_template = jinja2.from_string(custom_email_template.html)
html_message = html_template.render(context)
else:
text_message = render_to_string(
'squad/notification/diff.txt.jinja2',
context=context,
)
if do_html:
html_message = render_to_string(
'squad/notification/diff.html.jinja2',
context=context,
)
return (text_message, html_message)
def send(self):
recipients = self.recipients
if not recipients:
# No email is sent, but don't try to send it again
self.mark_as_notified()
return
sender = "%s <%s>" % (settings.SITE_NAME, settings.EMAIL_FROM)
subject = self.subject
txt, html = self.message(self.project.html_mail, self.project.custom_email_template)
if NotificationDelivery.exists(self.status, subject, txt, html):
return
# avoid "SMTP: 5.3.4 Message size exceeds fixed limit"
_1MB = 1024 * 1024
if len(txt) > _1MB or len(html) > _1MB:
logger.error('Notification size is greater than 1MB (%i): project %s, build %s' % (len(txt), self.project.full_name, self.build.version))
txt = 'The email got too big (> 1MB), please visit https://%s/api/builds/%i/email/?keep=7' % (settings.BASE_URL, self.build.id)
html = '<html><body>' + txt + '</body></html>'
message = Message(subject, txt, sender, recipients)
if self.project.html_mail:
message.attach_alternative(html, "text/html")
message.send()
self.mark_as_notified()
def mark_as_notified(self):
self.status.notified = True
self.status.save()
|
class Notification(object):
'''
Represents a notification about a project status change, that may or may
not need to be sent.
'''
def __init__(self, status, previous=None):
pass
@property
def comparison(self):
pass
@property
def diff(self):
pass
@property
def project(self):
pass
@property
def metadata(self):
pass
@property
def important_metadata(self):
pass
@property
def summary(self):
pass
@property
def recipients(self):
pass
@property
def known_issues(self):
pass
@property
def thresholds(self):
pass
@property
def metrics(self):
pass
@property
def subject(self):
pass
def create_subject(self, custom_email_template=None):
pass
def message(self, do_html=True, custom_email_template=None):
'''
Returns a tuple with (text_message,html_message)
'''
pass
def send(self):
pass
def mark_as_notified(self):
pass
| 28 | 2 | 10 | 1 | 9 | 0 | 2 | 0.06 | 1 | 7 | 6 | 1 | 16 | 3 | 16 | 16 | 187 | 25 | 153 | 52 | 125 | 9 | 101 | 41 | 84 | 11 | 1 | 3 | 38 |
145,902 |
Linaro/squad
|
Linaro_squad/squad/core/notification.py
|
squad.core.notification.PreviewNotification
|
class PreviewNotification(Notification):
@property
def recipients(self):
return [r.email for r in self.project.admin_subscriptions.all()]
@property
def subject(self):
return '[PREVIEW] %s' % super(PreviewNotification, self).subject
def message(self, do_html=True, custom_email_template=None):
txt, html = super(PreviewNotification, self).message(do_html, custom_email_template)
txt_banner = render_to_string(
'squad/notification/moderation.txt.jinja2',
{
"settings": settings,
"status": self.status,
}
)
html_banner = render_to_string(
'squad/notification/moderation.html.jinja2',
{
"settings": settings,
"status": self.status,
}
)
txt = txt_banner + txt
html = sub("<body>", "<body>\n" + html_banner, html)
return (txt, html)
|
class PreviewNotification(Notification):
@property
def recipients(self):
pass
@property
def subject(self):
pass
def message(self, do_html=True, custom_email_template=None):
pass
| 6 | 0 | 8 | 0 | 8 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 19 | 29 | 3 | 26 | 9 | 20 | 0 | 12 | 7 | 8 | 1 | 2 | 0 | 3 |
145,903 |
Linaro/squad
|
Linaro_squad/squad/core/plugins.py
|
squad.core.plugins.Plugin
|
class Plugin(object):
"""
This can be used to pass extra arguments to plugins
"""
extra_args = {}
"""
This class must be used as a superclass for all SQUAD plugins. All the
methods declared here have empty implementations (i.e. they do nothing),
and should be overriden in your plugin to provide extra functionality to
the SQUAD core.
"""
def postprocess_testrun(self, testrun):
"""
This method is called after a test run has been received by SQUAD, and
the test run data (tests, metrics, metadata, logs, etc) have been saved
to the database.
You can use this method to parse logs, do any special handling of
metadata, test results, etc.
The ``testrun`` arguments is an instance of
``squad.core.models.TestRun``.
"""
pass
def postprocess_testjob(self, testjob):
"""
This method is called after a test job has been fetched by SQUAD, and
the test run data (tests, metrics, metadata, logs, etc) have been saved
to the database.
You can use this method to do any processing that is specific to a
given CI backend (e.g. LAVA).
The ``testjob`` arguments is an instance of
``squad.ci.models.TestJob``.
"""
pass
def notify_patch_build_created(self, build):
"""
This method is called when a patch build is created. It should notify
the corresponding patch source that the checks are in progress.
The ``build`` argument is an instance of ``squad.core.Build``.
"""
pass
def notify_patch_build_finished(self, build):
"""
This method is called when a patch build is finished. It should notify
the patch source about the status of the tests (success, failure, etc).
The ``build`` argument is an instance of ``squad.core.Build``.
"""
pass
def get_url(self, object_id):
"""
This method might return service specific URL with given object_id
"""
pass
def has_subtasks(self):
"""
This method tells whether or not the plugin will use subtasks to
complete work, meaning that the main function will return but more
results are still working in parallel.
"""
return False
|
class Plugin(object):
'''
This can be used to pass extra arguments to plugins
'''
def postprocess_testrun(self, testrun):
'''
This method is called after a test run has been received by SQUAD, and
the test run data (tests, metrics, metadata, logs, etc) have been saved
to the database.
You can use this method to parse logs, do any special handling of
metadata, test results, etc.
The ``testrun`` arguments is an instance of
``squad.core.models.TestRun``.
'''
pass
def postprocess_testjob(self, testjob):
'''
This method is called after a test job has been fetched by SQUAD, and
the test run data (tests, metrics, metadata, logs, etc) have been saved
to the database.
You can use this method to do any processing that is specific to a
given CI backend (e.g. LAVA).
The ``testjob`` arguments is an instance of
``squad.ci.models.TestJob``.
'''
pass
def notify_patch_build_created(self, build):
'''
This method is called when a patch build is created. It should notify
the corresponding patch source that the checks are in progress.
The ``build`` argument is an instance of ``squad.core.Build``.
'''
pass
def notify_patch_build_finished(self, build):
'''
This method is called when a patch build is finished. It should notify
the patch source about the status of the tests (success, failure, etc).
The ``build`` argument is an instance of ``squad.core.Build``.
'''
pass
def get_url(self, object_id):
'''
This method might return service specific URL with given object_id
'''
pass
def has_subtasks(self):
'''
This method tells whether or not the plugin will use subtasks to
complete work, meaning that the main function will return but more
results are still working in parallel.
'''
pass
| 7 | 7 | 9 | 1 | 2 | 6 | 1 | 3.21 | 1 | 0 | 0 | 3 | 6 | 0 | 6 | 6 | 72 | 13 | 14 | 8 | 7 | 45 | 14 | 8 | 7 | 1 | 1 | 0 | 6 |
145,904 |
Linaro/squad
|
Linaro_squad/squad/core/plugins.py
|
squad.core.plugins.PluginField
|
class PluginField(models.CharField):
def __init__(self, **args):
defaults = {'max_length': 256}
defaults.update(args)
self.features = defaults.pop('features', None)
return super(PluginField, self).__init__(**defaults)
def deconstruct(self):
name, path, args, kwargs = super(PluginField, self).deconstruct()
del kwargs["max_length"]
return name, path, args, kwargs
def formfield(self, **kwargs):
plugins = ((v, v) for v in get_plugins_by_feature(self.features))
return ChoiceField(choices=plugins)
|
class PluginField(models.CharField):
def __init__(self, **args):
pass
def deconstruct(self):
pass
def formfield(self, **kwargs):
pass
| 4 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 3 | 1 | 3 | 3 | 16 | 3 | 13 | 8 | 9 | 0 | 13 | 8 | 9 | 1 | 1 | 0 | 3 |
145,905 |
Linaro/squad
|
Linaro_squad/squad/core/plugins.py
|
squad.core.plugins.PluginListField
|
class PluginListField(models.TextField):
def __init__(self, **args):
self.features = args.pop('features', None)
return super(PluginListField, self).__init__(**args)
def from_db_value(self, value, *args):
if value is None:
return None
return [item.strip() for item in value.split(',')]
def to_python(self, value):
if isinstance(value, list):
return value
if value is None:
return None
return [item.strip() for item in value.split(',')]
def get_prep_value(self, value):
if value is None:
return value
return ', '.join(value)
def formfield(self, **kwargs):
plugins = ((v, v) for v in get_plugins_by_feature(self.features))
required = not self.null
return MultipleChoiceField(
required=required,
choices=plugins,
widget=CheckboxSelectMultiple,
)
|
class PluginListField(models.TextField):
def __init__(self, **args):
pass
def from_db_value(self, value, *args):
pass
def to_python(self, value):
pass
def get_prep_value(self, value):
pass
def formfield(self, **kwargs):
pass
| 6 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 1 | 2 | 0 | 0 | 5 | 1 | 5 | 5 | 31 | 5 | 26 | 9 | 20 | 0 | 22 | 9 | 16 | 3 | 1 | 1 | 9 |
145,906 |
Linaro/squad
|
Linaro_squad/squad/core/plugins.py
|
squad.core.plugins.PluginLoader
|
class PluginLoader(object):
__plugins__ = None
@classmethod
def load_all(cls):
if cls.__plugins__ is not None:
return cls.__plugins__
entry_points = []
# builtin plugins
builtin_plugins_path = os.path.join(squad.__path__[0], 'plugins')
for _, m, _ in iter_modules([builtin_plugins_path]):
e = EntryPoint(m, 'squad.plugins.' + m, attrs=('Plugin',))
entry_points.append(e)
# external plugins
plugins = iter_entry_points('squad_plugins')
entry_points += list(plugins)
cls.__plugins__ = {e.name: e.resolve() for e in entry_points}
return cls.__plugins__
|
class PluginLoader(object):
@classmethod
def load_all(cls):
pass
| 3 | 0 | 18 | 4 | 12 | 2 | 3 | 0.13 | 1 | 2 | 0 | 0 | 0 | 0 | 1 | 1 | 23 | 6 | 15 | 9 | 12 | 2 | 14 | 8 | 12 | 3 | 1 | 1 | 3 |
145,907 |
Linaro/squad
|
Linaro_squad/squad/core/plugins.py
|
squad.core.plugins.PluginNotFound
|
class PluginNotFound(Exception):
pass
|
class PluginNotFound(Exception):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
145,908 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/__init__.py
|
squad.core.tasks.CreateBuild
|
class CreateBuild(object):
def __init__(self, project):
self.project = project
def __call__(self, version, patch_source=None, patch_id=None, patch_baseline=None):
defaults = {
'patch_source': patch_source,
'patch_id': patch_id,
'patch_baseline': patch_baseline,
}
build, created = self.project.builds.get_or_create(
version=version,
defaults=defaults,
)
if created and build.patch_source and build.patch_id:
update_build_patch_url.delay(build.id)
notify_patch_build_created.delay(build.id)
return (build, created)
|
class CreateBuild(object):
def __init__(self, project):
pass
def __call__(self, version, patch_source=None, patch_id=None, patch_baseline=None):
pass
| 3 | 0 | 8 | 0 | 8 | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 2 | 19 | 2 | 17 | 6 | 14 | 0 | 10 | 6 | 7 | 2 | 1 | 1 | 3 |
145,909 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/__init__.py
|
squad.core.tasks.ParseTestRunData
|
class ParseTestRunData(object):
@staticmethod
def __call__(test_run):
if test_run.data_processed:
return
issues = {}
for issue in KnownIssue.active_by_environment(test_run.environment):
issues.setdefault(issue.test_name, [])
issues[issue.test_name].append(issue)
# Issues' test_name should be interpreted as regexes
# so compile them prior to matching against test names
# The * character should be replaced by .*?, which is regex for "everything"
issues_regex = {}
for test_name_regex in issues.keys():
pattern = re.escape(test_name_regex).replace('\\*', '.*?')
regex = re.compile(pattern)
issues_regex[regex] = issues[test_name_regex]
for test in test_parser()(test_run.tests_file):
# TODO: remove check below when test_name size changes in the schema
if len(test['test_name']) > 256:
continue
suite = get_suite(
test_run,
test['group_name']
)
metadata, _ = SuiteMetadata.objects.get_or_create(suite=suite.slug, name=test['test_name'], kind='test')
full_name = join_name(suite.slug, test['test_name'])
test_issues = list(itertools.chain(*[issue for regex, issue in issues_regex.items() if regex.match(full_name)]))
test_obj = Test.objects.create(
test_run=test_run,
suite=suite,
metadata=metadata,
result=test['pass'],
log=test['log'],
has_known_issues=bool(test_issues),
build=test_run.build,
environment=test_run.environment,
)
for issue in test_issues:
test_obj.known_issues.add(issue)
for metric in metric_parser()(test_run.metrics_file):
# TODO: remove check below when test_name size changes in the schema
if len(metric['name']) > 256:
continue
suite = get_suite(
test_run,
metric['group_name']
)
metadata, _ = SuiteMetadata.objects.get_or_create(suite=suite.slug, name=metric['name'], kind='metric')
Metric.objects.create(
test_run=test_run,
suite=suite,
metadata=metadata,
result=metric['result'],
measurements=','.join([str(m) for m in metric['measurements']]),
unit=metric['unit'],
build=test_run.build,
environment=test_run.environment,
)
test_run.data_processed = True
test_run.save()
|
class ParseTestRunData(object):
@staticmethod
def __call__(test_run):
pass
| 3 | 0 | 66 | 7 | 54 | 5 | 9 | 0.09 | 1 | 8 | 4 | 0 | 0 | 0 | 1 | 1 | 69 | 8 | 56 | 16 | 53 | 5 | 31 | 15 | 29 | 9 | 1 | 2 | 9 |
145,910 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/__init__.py
|
squad.core.tasks.PostProcessTestRun
|
class PostProcessTestRun(object):
def __call__(self, testrun):
project = testrun.build.project
for plugin in apply_plugins(project.enabled_plugins):
try:
self.__call_plugin__(plugin, testrun)
except Exception as e:
logger.error("Plugin postprocessing error: " + str(e) + "\n" + traceback.format_exc())
def __call_plugin__(self, plugin, testrun):
plugin.postprocess_testrun(testrun)
|
class PostProcessTestRun(object):
def __call__(self, testrun):
pass
def __call_plugin__(self, plugin, testrun):
pass
| 3 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 1 | 2 | 0 | 0 | 2 | 0 | 2 | 2 | 12 | 2 | 10 | 6 | 7 | 0 | 10 | 5 | 7 | 3 | 1 | 2 | 4 |
145,911 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/__init__.py
|
squad.core.tasks.ProcessAllTestRuns
|
class ProcessAllTestRuns(object):
@staticmethod
def __call__():
for testrun in TestRun.objects.filter(data_processed=False).all():
parser = ParseTestRunData()
parser(testrun)
for testrun in TestRun.objects.filter(status_recorded=False).all():
recorder = RecordTestRunStatus()
recorder(testrun)
|
class ProcessAllTestRuns(object):
@staticmethod
def __call__():
pass
| 3 | 0 | 7 | 0 | 7 | 0 | 3 | 0 | 1 | 3 | 3 | 0 | 0 | 0 | 1 | 1 | 10 | 1 | 9 | 6 | 6 | 0 | 8 | 5 | 6 | 3 | 1 | 1 | 3 |
145,912 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/__init__.py
|
squad.core.tasks.ProcessTestRun
|
class ProcessTestRun(object):
@staticmethod
def __call__(testrun):
with transaction.atomic():
ParseTestRunData()(testrun)
PostProcessTestRun()(testrun)
RecordTestRunStatus()(testrun)
|
class ProcessTestRun(object):
@staticmethod
def __call__(testrun):
pass
| 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 3 | 3 | 0 | 0 | 0 | 1 | 1 | 8 | 1 | 7 | 3 | 4 | 0 | 6 | 2 | 4 | 1 | 1 | 1 | 1 |
145,913 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/__init__.py
|
squad.core.tasks.ReceiveTestRun
|
class ReceiveTestRun(object):
def __init__(self, project, update_project_status=True):
self.project = project
self.update_project_status = update_project_status
SPECIAL_METADATA_FIELDS = (
"build_url",
"datetime",
"job_id",
"job_status",
"job_url",
"resubmit_url",
)
def __call__(self, version, environment_slug, metadata_file=None, metrics_file=None, tests_file=None, log_file=None, attachments={}, completed=True):
build, build_created = self.project.builds.get_or_create(version=version)
environment, _ = self.project.environments.get_or_create(slug=environment_slug)
validate = ValidateTestRun()
validate(metadata_file, metrics_file, tests_file)
if metadata_file:
data = json.loads(metadata_file)
fields = self.SPECIAL_METADATA_FIELDS
metadata_fields = {k: data[k] for k in fields if data.get(k)}
job_id = metadata_fields.get('job_id')
if job_id is None:
metadata_fields['job_id'] = uuid.uuid4()
elif build.test_runs.filter(job_id=job_id).exists():
raise exceptions.DuplicatedTestJob("There is already a test run with job_id %s" % job_id)
else:
metadata_fields = {'job_id': uuid.uuid4()}
if log_file:
log_file = log_file.replace("\x00", "")
testrun = build.test_runs.create(
environment=environment,
metadata_file=metadata_file,
completed=completed,
**metadata_fields
)
if tests_file is not None:
testrun.save_tests_file(tests_file)
if metrics_file is not None:
testrun.save_metrics_file(metrics_file)
if log_file is not None:
testrun.save_log_file(log_file)
for filename, data in attachments.items():
attachment = testrun.attachments.create(filename=filename, length=len(data))
attachment.save_file(filename, data)
testrun.refresh_from_db()
if not build.datetime or testrun.datetime < build.datetime:
build.datetime = testrun.datetime
build.save()
processor = ProcessTestRun()
processor(testrun)
if self.update_project_status:
UpdateProjectStatus()(testrun)
UpdateBuildSummary()(testrun)
if build_created:
return (testrun, build)
return (testrun, None)
|
class ReceiveTestRun(object):
def __init__(self, project, update_project_status=True):
pass
def __call__(self, version, environment_slug, metadata_file=None, metrics_file=None, tests_file=None, log_file=None, attachments={}, completed=True):
pass
| 3 | 0 | 32 | 8 | 24 | 0 | 7 | 0 | 1 | 5 | 5 | 0 | 2 | 2 | 2 | 2 | 75 | 18 | 57 | 17 | 54 | 0 | 43 | 17 | 40 | 12 | 1 | 2 | 13 |
145,914 |
Linaro/squad
|
Linaro_squad/squad/core/tasks/__init__.py
|
squad.core.tasks.UpdateBuildSummary
|
class UpdateBuildSummary(object):
@staticmethod
def __call__(testrun):
BuildSummary.create_or_update(testrun.build, testrun.environment)
|
class UpdateBuildSummary(object):
@staticmethod
def __call__(testrun):
pass
| 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 5 | 1 | 4 | 3 | 1 | 0 | 3 | 2 | 1 | 1 | 1 | 0 | 1 |
145,915 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0159_nullable_metricthreshold_value.py
|
squad.core.migrations.0159_nullable_metricthreshold_value.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0158_add_metric_comparison_to_projectstatus'),
]
operations = [
migrations.AlterField(
model_name='metricthreshold',
name='value',
field=models.FloatField(blank=True, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,916 |
Linaro/squad
|
Linaro_squad/squad/api/rest.py
|
squad.api.rest.AnnotationViewSet
|
class AnnotationViewSet(viewsets.ModelViewSet):
queryset = Annotation.objects.all()
serializer_class = AnnotationSerializer
filterset_fields = ('description', 'build')
filter_fields = filterset_fields # TODO: remove when django-filters 1.x is not supported anymore
ordering_fields = ('id', 'build')
|
class AnnotationViewSet(viewsets.ModelViewSet):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | 1 | 6 | 6 | 5 | 1 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
145,917 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0157_remove_metric_name.py
|
squad.core.migrations.0157_remove_metric_name.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0156_nullable_metric_name'),
]
operations = [
migrations.RemoveField(
model_name='metric',
name='name',
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 2 | 10 | 3 | 9 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,918 |
Linaro/squad
|
Linaro_squad/squad/http.py
|
squad.http.AuthMode
|
class AuthMode(Enum):
READ = 0
WRITE = 1
SUBMIT_RESULTS = 2
PRIVILEGED = 3
|
class AuthMode(Enum):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 5 | 0 | 5 | 5 | 4 | 0 | 5 | 5 | 4 | 0 | 4 | 0 | 0 |
145,919 |
Linaro/squad
|
Linaro_squad/squad/frontend/views.py
|
squad.frontend.views.TestResultTable
|
class TestResultTable(object):
class Cell(object):
def __init__(self):
self.has_failures = False
self.has_known_failures = False
self.statuses = []
@property
def has_data(self):
return len(self.statuses) > 0
def __init__(self):
self.data = OrderedDict()
self.environments = []
self.test_runs = set()
def add_status(self, status):
suite = status.suite
environment = status.environment
if environment not in self.environments:
self.environments.append(environment)
if suite not in self.data:
self.data[suite] = OrderedDict()
if environment not in self.data[suite]:
self.data[suite][environment] = TestResultTable.Cell()
entry = self.data[suite][environment]
if status.tests_fail > 0:
entry.has_failures = True
if status.tests_xfail > 0:
entry.has_known_failures = True
entry.statuses.append(status)
self.test_runs.add(status.test_run)
|
class TestResultTable(object):
class Cell(object):
def __init__(self):
pass
@property
def has_data(self):
pass
def __init__(self):
pass
def add_status(self, status):
pass
| 7 | 0 | 7 | 0 | 7 | 0 | 2 | 0 | 1 | 3 | 1 | 0 | 2 | 3 | 2 | 2 | 35 | 6 | 29 | 16 | 22 | 0 | 28 | 15 | 22 | 6 | 1 | 1 | 9 |
145,920 |
Linaro/squad
|
Linaro_squad/squad/frontend/views.py
|
squad.frontend.views.TestKnownIssues
|
class TestKnownIssues(object):
def __init__(self, project, search, page=1, per_page=50):
tests_issues = OrderedDict()
self.project = project
env_qs = project.environments.all().prefetch_related(Prefetch('knownissue_set', queryset=KnownIssue.objects.filter(test_name__icontains=search))).order_by()
self.environments = [e.slug for e in env_qs]
testnames = set()
for env in env_qs:
issues = env.knownissue_set.all()
for issue in issues:
testnames.add(issue.test_name)
tests_issues.setdefault(issue.test_name, {})
tests_issues[issue.test_name].update({env.slug: json.dumps({"url": issue.url,
"notes": issue.notes,
"intermittent": issue.intermittent,
"active": issue.active})})
self.paginator = Paginator(sorted([t for t in testnames]), per_page)
self.number = page
self.results = {x: tests_issues[x] for x in self.paginator.page(page).object_list}
|
class TestKnownIssues(object):
def __init__(self, project, search, page=1, per_page=50):
pass
| 2 | 0 | 18 | 0 | 18 | 0 | 3 | 0 | 1 | 3 | 1 | 0 | 1 | 5 | 1 | 1 | 20 | 1 | 19 | 13 | 17 | 0 | 16 | 13 | 14 | 3 | 1 | 2 | 3 |
145,921 |
Linaro/squad
|
Linaro_squad/squad/frontend/views.py
|
squad.frontend.views.BuildDeleted
|
class BuildDeleted(Http404):
def __init__(self, date, days):
self.display_message = True
msg = 'This build has been deleted on %s. ' % date
msg += 'Builds in this project are usually deleted after %d days.' % days
super(BuildDeleted, self).__init__(msg)
|
class BuildDeleted(Http404):
def __init__(self, date, days):
pass
| 2 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 7 | 1 | 6 | 4 | 4 | 0 | 6 | 4 | 4 | 1 | 1 | 0 | 1 |
145,922 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0111_remove_group_user_groups.py
|
squad.core.migrations.0111_remove_group_user_groups.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0110_move_users_from_django_groups_to_squad_groups'),
]
operations = [
migrations.RemoveField(
model_name='group',
name='user_groups',
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 2 | 10 | 3 | 9 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,923 |
Linaro/squad
|
Linaro_squad/squad/api/rest.py
|
squad.api.rest.HyperlinkedTestsIdentityField
|
class HyperlinkedTestsIdentityField(serializers.HyperlinkedIdentityField):
def get_url(self, *args):
testrun = args[0]
statuses = testrun.status.all()
if len(statuses) > 0:
tr_status = testrun.status.all()[0]
num_tests = (
tr_status.tests_pass + tr_status.tests_fail + tr_status.tests_skip + tr_status.tests_xfail
)
if num_tests > 0:
return super().get_url(*args)
else:
return None
|
class HyperlinkedTestsIdentityField(serializers.HyperlinkedIdentityField):
def get_url(self, *args):
pass
| 2 | 0 | 12 | 0 | 12 | 0 | 3 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 13 | 0 | 13 | 6 | 11 | 0 | 10 | 6 | 8 | 3 | 1 | 2 | 3 |
145,924 |
Linaro/squad
|
Linaro_squad/squad/api/rest.py
|
squad.api.rest.HyperlinkedProjectStatusField
|
class HyperlinkedProjectStatusField(serializers.HyperlinkedRelatedField):
def get_url(self, obj, view_name, request, format):
try:
project_status = ProjectStatus.objects.get(pk=obj.pk)
return rest_reverse(view_name, kwargs={'pk': project_status.build.pk}, request=request, format=format)
except ProjectStatus.DoesNotExist:
return None
|
class HyperlinkedProjectStatusField(serializers.HyperlinkedRelatedField):
def get_url(self, obj, view_name, request, format):
pass
| 2 | 0 | 6 | 0 | 6 | 0 | 2 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 1 | 7 | 0 | 7 | 3 | 5 | 0 | 7 | 3 | 5 | 2 | 1 | 1 | 2 |
145,925 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0112_user_namespaces.py
|
squad.core.migrations.0112_user_namespaces.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0111_remove_group_user_groups'),
]
operations = [
migrations.CreateModel(
name='UserNamespace',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('core.group',),
),
migrations.AlterField(
model_name='group',
name='slug',
field=models.CharField(db_index=True, max_length=100, unique=True, validators=[django.core.validators.RegexValidator(regex='^~?[a-zA-Z0-9][a-zA-Z0-9_.-]*')]),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 23 | 2 | 21 | 3 | 20 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,926 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0113_group_project_blank_name_and_description.py
|
squad.core.migrations.0113_group_project_blank_name_and_description.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0112_user_namespaces'),
]
operations = [
migrations.AlterField(
model_name='group',
name='description',
field=models.TextField(blank=True, null=True),
),
migrations.AlterField(
model_name='group',
name='name',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='project',
name='name',
field=models.CharField(blank=True, max_length=100, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 23 | 2 | 21 | 3 | 20 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,927 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0114_project_enabled_plugin_list_can_be_blank.py
|
squad.core.migrations.0114_project_enabled_plugin_list_can_be_blank.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0113_group_project_blank_name_and_description'),
]
operations = [
migrations.AlterField(
model_name='project',
name='enabled_plugins_list',
field=squad.core.plugins.PluginListField(blank=True, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,928 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0115_fix_slug_validation.py
|
squad.core.migrations.0115_fix_slug_validation.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0114_project_enabled_plugin_list_can_be_blank'),
]
operations = [
migrations.AlterField(
model_name='environment',
name='slug',
field=models.CharField(db_index=True, max_length=100, validators=[django.core.validators.RegexValidator(regex='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$')]),
),
migrations.AlterField(
model_name='group',
name='slug',
field=models.CharField(db_index=True, max_length=100, unique=True, validators=[django.core.validators.RegexValidator(regex='^~?[a-zA-Z0-9][a-zA-Z0-9_.-]*$')]),
),
migrations.AlterField(
model_name='project',
name='slug',
field=models.CharField(db_index=True, max_length=100, validators=[django.core.validators.RegexValidator(regex='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$')]),
),
migrations.AlterField(
model_name='suite',
name='slug',
field=models.CharField(db_index=True, max_length=256, validators=[django.core.validators.RegexValidator(regex='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$')]),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 28 | 2 | 26 | 3 | 25 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,929 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0116_make_group_membership_unique.py
|
squad.core.migrations.0116_make_group_membership_unique.Migration
|
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('core', '0115_fix_slug_validation'),
]
operations = [
migrations.RunPython(
remove_duplicate_memberships,
reverse_code=migrations.RunPython.noop,
),
migrations.AlterUniqueTogether(
name='groupmember',
unique_together=set([('group', 'user')]),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 17 | 2 | 15 | 3 | 14 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,930 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0117_drop_obsolete_token_model.py
|
squad.core.migrations.0117_drop_obsolete_token_model.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0116_make_group_membership_unique'),
]
operations = [
migrations.RemoveField(
model_name='token',
name='project',
),
migrations.DeleteModel(
name='Token',
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 15 | 2 | 13 | 3 | 12 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,931 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0118_project_is_archived.py
|
squad.core.migrations.0118_project_is_archived.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0117_drop_obsolete_token_model'),
]
operations = [
migrations.AddField(
model_name='project',
name='is_archived',
field=models.BooleanField(default=False, help_text='Makes the project hidden from the group page by default'),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,932 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0158_add_metric_comparison_to_projectstatus.py
|
squad.core.migrations.0158_add_metric_comparison_to_projectstatus.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0157_remove_metric_name'),
]
operations = [
migrations.AddField(
model_name='projectstatus',
name='metric_fixes',
field=models.TextField(blank=True, null=True, validators=[squad.core.utils.yaml_validator]),
),
migrations.AddField(
model_name='projectstatus',
name='metric_regressions',
field=models.TextField(blank=True, null=True, validators=[squad.core.utils.yaml_validator]),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 18 | 2 | 16 | 3 | 15 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,933 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0119_i18n.py
|
squad.core.migrations.0119_i18n.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0118_project_is_archived'),
]
operations = [
migrations.AlterField(
model_name='group',
name='description',
field=models.TextField(blank=True, null=True, verbose_name='Description'),
),
migrations.AlterField(
model_name='group',
name='members',
field=models.ManyToManyField(through='core.GroupMember', to=settings.AUTH_USER_MODEL, verbose_name='Members'),
),
migrations.AlterField(
model_name='group',
name='name',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Name'),
),
migrations.AlterField(
model_name='group',
name='slug',
field=models.CharField(db_index=True, max_length=100, unique=True, validators=[django.core.validators.RegexValidator(regex='^~?[a-zA-Z0-9][a-zA-Z0-9_.-]*$')], verbose_name='Slug'),
),
migrations.AlterField(
model_name='project',
name='description',
field=models.TextField(blank=True, null=True, verbose_name='Description'),
),
migrations.AlterField(
model_name='project',
name='is_archived',
field=models.BooleanField(default=False, help_text='Makes the project hidden from the group page by default', verbose_name='Is archived'),
),
migrations.AlterField(
model_name='project',
name='is_public',
field=models.BooleanField(default=True, verbose_name='Is public'),
),
migrations.AlterField(
model_name='project',
name='name',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Name'),
),
migrations.AlterField(
model_name='project',
name='slug',
field=models.CharField(db_index=True, max_length=100, validators=[django.core.validators.RegexValidator(regex='^[a-zA-Z0-9][a-zA-Z0-9_.-]*$')], verbose_name='Slug'),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 53 | 2 | 51 | 3 | 50 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,934 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0120_buildsummary.py
|
squad.core.migrations.0120_buildsummary.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0119_i18n'),
]
operations = [
migrations.CreateModel(
name='BuildSummary',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('metrics_summary', models.FloatField(null=True)),
('has_metrics', models.BooleanField(default=False)),
('tests_pass', models.IntegerField(default=0)),
('tests_fail', models.IntegerField(default=0)),
('tests_xfail', models.IntegerField(default=0)),
('tests_skip', models.IntegerField(default=0)),
('test_runs_total', models.IntegerField(default=0)),
('test_runs_completed', models.IntegerField(default=0)),
('test_runs_incomplete', models.IntegerField(default=0)),
('build', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='metrics_summary', to='core.Build')),
('environment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Environment')),
],
bases=(models.Model, squad.core.models.TestSummaryBase),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 26 | 2 | 24 | 3 | 23 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,935 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0121_add_password_patchsource.py
|
squad.core.migrations.0121_add_password_patchsource.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0120_buildsummary'),
]
operations = [
migrations.AddField(
model_name='patchsource',
name='_password',
field=models.CharField(blank=True, db_column='password', max_length=128, null=True),
),
migrations.AlterField(
model_name='patchsource',
name='url',
field=models.URLField(help_text="scheme://host, ex: 'http://github.com', 'ssh://gerrit.host, etc'"),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 18 | 2 | 16 | 3 | 15 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,936 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0122_fix_patchsource_url_and_token.py
|
squad.core.migrations.0122_fix_patchsource_url_and_token.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0121_add_password_patchsource'),
]
operations = [
migrations.AlterField(
model_name='patchsource',
name='token',
field=models.CharField(blank=True, max_length=1024),
),
migrations.AlterField(
model_name='patchsource',
name='url',
field=squad.core.models.CustomURLField(help_text="scheme://host, ex: 'http://github.com', 'ssh://gerrit.host, etc'"),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 18 | 2 | 16 | 3 | 15 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,937 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0123_django_upgrade_missing_migrations.py
|
squad.core.migrations.0123_django_upgrade_missing_migrations.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0122_fix_patchsource_url_and_token'),
]
operations = [
migrations.AlterField(
model_name='metric',
name='metadata',
field=models.ForeignKey(limit_choices_to={'kind': 'metric'}, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='core.SuiteMetadata'),
),
migrations.AlterField(
model_name='suite',
name='metadata',
field=models.ForeignKey(limit_choices_to={'kind': 'suite'}, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='core.SuiteMetadata'),
),
migrations.AlterField(
model_name='test',
name='metadata',
field=models.ForeignKey(limit_choices_to={'kind': 'test'}, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='core.SuiteMetadata'),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 23 | 2 | 21 | 3 | 20 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,938 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0124_set_default_expected_test_runs_to_zero.py
|
squad.core.migrations.0124_set_default_expected_test_runs_to_zero.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0123_django_upgrade_missing_migrations'),
]
operations = [
migrations.AlterField(
model_name='environment',
name='expected_test_runs',
field=models.IntegerField(blank=True, default=0, null=True),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,939 |
Linaro/squad
|
Linaro_squad/squad/http.py
|
squad.http.JsonResponseForbidden
|
class JsonResponseForbidden(JsonResponse):
def __init__(self, *args, **kwargs):
kwargs['status'] = 403
return super(JsonResponseForbidden, self).__init__(*args, **kwargs)
|
class JsonResponseForbidden(JsonResponse):
def __init__(self, *args, **kwargs):
pass
| 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 4 | 0 | 4 | 2 | 2 | 0 | 4 | 2 | 2 | 1 | 1 | 0 | 1 |
145,940 |
Linaro/squad
|
Linaro_squad/squad/mail.py
|
squad.mail.Message
|
class Message(EmailMultiAlternatives):
def __init__(self, subject, body, sender, recipients):
super().__init__(subject, body, sender, recipients)
self.extra_headers['Precedence'] = 'bulk'
self.extra_headers['Auto-Submitted'] = 'auto-generated'
self.extra_headers['X-Auto-Response-Suppress'] = 'All'
|
class Message(EmailMultiAlternatives):
def __init__(self, subject, body, sender, recipients):
pass
| 2 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 7 | 1 | 6 | 2 | 4 | 0 | 6 | 2 | 4 | 1 | 1 | 0 | 1 |
145,941 |
Linaro/squad
|
Linaro_squad/squad/plugins/example.py
|
squad.plugins.example.Plugin
|
class Plugin(BasePlugin):
pass
|
class Plugin(BasePlugin):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 6 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 2 | 0 | 0 |
145,942 |
Linaro/squad
|
Linaro_squad/squad/plugins/gerrit.py
|
squad.plugins.gerrit.Plugin
|
class Plugin(BasePlugin):
@staticmethod
def __message__(build, finished=False, extra_message=None):
message = "Build {created_or_finished}: {build_version} ({build_url})"
context = {
'created_or_finished': 'finished' if finished else 'created',
'build_version': build.version,
'build_url': build_url(build),
}
if build.patch_baseline:
message += "\nBaseline: {baseline_version} ({baseline_url})"
context['baseline_version'] = build.patch_baseline.version
context['baseline_url'] = build_url(build.patch_baseline)
if extra_message:
message += "\n" + extra_message
return message.format(**context)
@staticmethod
def __gerrit_post__(build, payload):
patch_source = build.patch_source
parsed_url = urlparse(patch_source.url)
auth = requests.auth.HTTPBasicAuth(patch_source.username, patch_source.password)
change_id, patchset = re.split(r'%s' % PATCH_SET_DIVIDER_REGEX, build.patch_id)
url = '{scheme}://{host}/a/changes/{change_id}/revisions/{patchset}/review'.format(
scheme=parsed_url.scheme,
host=parsed_url.netloc,
change_id=change_id,
patchset=patchset,
)
result = requests.post(url, auth=auth, json=payload)
if result.status_code != 200:
logger.error('Gerrit post failed, %s returned %d' % (parsed_url.netloc, result.status_code))
return False
return True
@staticmethod
def __gerrit_ssh__(build, payload):
patch_source = build.patch_source
parsed_url = urlparse(patch_source.url)
change_id, patchset = re.split(r'%s' % PATCH_SET_DIVIDER_REGEX, build.patch_id)
cmd = 'gerrit review -m "{message}" {change_id},{patchset}'.format(
message=payload['message'],
change_id=change_id,
patchset=patchset,
)
labels = payload.get('labels', {})
for label in labels.keys():
value = labels[label]
cmd += ' --label %s=%s' % (label.lower(), value)
ssh = ['ssh']
ssh += DEFAULT_SSH_OPTIONS
ssh += ['-p', DEFAULT_SSH_PORT, '%s@%s' % (patch_source.username, parsed_url.netloc)]
ssh += [cmd]
try:
result = subprocess.run(ssh, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except subprocess.CalledProcessError as e:
logger.error('Failed do login to %s: %s' % (parsed_url.netloc, str(e)))
return False
if len(result.stdout) > 0 or len(result.stderr) > 0:
logger.error('Failed to submit review through ssh: %s' % (result.stdout + result.stderr))
return False
return True
def __gerrit_request__(self, build, payload):
regex = r'.+%s.+' % PATCH_SET_DIVIDER_REGEX
if re.match(regex, build.patch_id) is None:
logger.warning('patch_id "%s" for build "%s" failed to match "%s"' % (build.patch_id, build.id, regex))
return False
if build.patch_source.url.startswith('ssh'):
return Plugin.__gerrit_ssh__(build, payload)
else:
return Plugin.__gerrit_post__(build, payload)
def __get_labels__(self, build, success):
labels = {}
empty = [None, {}]
if not success:
labels = {'Code-Review': '-1'}
plugins_settings = build.project.get_setting('plugins')
if plugins_settings in empty:
return labels
settings = plugins_settings.get('gerrit')
if settings in empty:
return labels
build_finished = settings.get('build_finished')
if build_finished in empty:
return labels
if success:
labels = build_finished.get('success', {})
else:
labels = build_finished.get('error', labels)
return labels
def notify_patch_build_created(self, build):
data = {
'message': Plugin.__message__(build),
}
return self.__gerrit_request__(build, data)
def notify_patch_build_finished(self, build):
try:
if build.status.tests_fail == 0:
message = "All tests passed"
success = True
else:
message = "Some tests failed (%d)" % build.status.tests_fail
success = False
except ProjectStatus.DoesNotExist:
logger.error('ProjectStatus for build %s/%s does not exist' % (build.project.slug, build.version))
message = "An error occurred"
data = {
'message': Plugin.__message__(build, finished=True, extra_message=message),
'labels': self.__get_labels__(build, success=success)
}
return self.__gerrit_request__(build, data)
def get_url(self, build):
if build.patch_source and build.patch_id:
parsed_url = urlparse(build.patch_source.url)
if parsed_url.scheme.startswith("http"):
change_id, patchset = re.split(r'%s' % PATCH_SET_DIVIDER_REGEX, build.patch_id)
auth = requests.auth.HTTPBasicAuth(build.patch_source.username, build.patch_source.password)
url = '{scheme}://{host}/a/changes/{change_id}/'.format(
scheme=parsed_url.scheme,
host=parsed_url.netloc,
change_id=change_id,
)
result = requests.get(url, auth=auth)
if result.status_code == 200:
# 4 leading characters from response has to be removed
# to get valid JSON
# https://gerrit-review.googlesource.com/Documentation/rest-api.html#output
malformed_json = result.text
valid_json = malformed_json[4:]
details = json.loads(valid_json)
project_name = details.get("project")
return "{scheme}://{host}/c/{project_name}/+/{change_id}/{patchset}".format(
scheme=parsed_url.scheme,
host=parsed_url.netloc,
project_name=project_name,
change_id=change_id,
patchset=patchset
)
return None
|
class Plugin(BasePlugin):
@staticmethod
def __message__(build, finished=False, extra_message=None):
pass
@staticmethod
def __gerrit_post__(build, payload):
pass
@staticmethod
def __gerrit_ssh__(build, payload):
pass
def __gerrit_request__(self, build, payload):
pass
def __get_labels__(self, build, success):
pass
def notify_patch_build_created(self, build):
pass
def notify_patch_build_finished(self, build):
pass
def get_url(self, build):
pass
| 12 | 0 | 19 | 2 | 16 | 0 | 3 | 0.02 | 1 | 3 | 1 | 0 | 5 | 0 | 8 | 14 | 162 | 25 | 134 | 49 | 122 | 3 | 100 | 45 | 91 | 6 | 2 | 3 | 27 |
145,943 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0093_historicalemailtemplate.py
|
squad.core.migrations.0093_historicalemailtemplate.Migration
|
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('core', '0092_annotation'),
]
operations = [
migrations.CreateModel(
name='HistoricalEmailTemplate',
fields=[
('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
('name', models.CharField(db_index=True, max_length=100)),
('subject', models.CharField(blank=True, help_text='Jinja2 template for subject (single line)', max_length=1024, null=True)),
('plain_text', models.TextField(help_text='Jinja2 template for text/plain content')),
('html', models.TextField(blank=True, help_text='Jinja2 template for text/html content', null=True)),
('history_id', models.AutoField(primary_key=True, serialize=False)),
('history_change_reason', models.CharField(max_length=100, null=True)),
('history_date', models.DateTimeField()),
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'historical email template',
'ordering': ('-history_date', '-history_id'),
'get_latest_by': 'history_date',
},
bases=(simple_history.models.HistoricalChanges, models.Model),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 30 | 2 | 28 | 3 | 27 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,944 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0094_populatehistoricalemailtemplate.py
|
squad.core.migrations.0094_populatehistoricalemailtemplate.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0093_historicalemailtemplate'),
]
operations = [
migrations.RunPython(populate_historical_emailtemplate, clean_historical_emailtemplate),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 9 | 2 | 7 | 3 | 6 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,945 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0095_project_data_retention_days.py
|
squad.core.migrations.0095_project_data_retention_days.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0094_populatehistoricalemailtemplate'),
]
operations = [
migrations.AddField(
model_name='project',
name='data_retention_days',
field=models.IntegerField(default=0, help_text='Delete builds older than this number of days. Set to 0 or any negative number to disable.'),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 13 | 2 | 11 | 3 | 10 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,946 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0096_build_keep_data.py
|
squad.core.migrations.0096_build_keep_data.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0095_project_data_retention_days'),
]
operations = [
migrations.AddField(
model_name='build',
name='keep_data',
field=models.BooleanField(
default=False,
help_text='Keep this build data even after the project data retention period has passed',
),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 16 | 2 | 14 | 3 | 13 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
145,947 |
Linaro/squad
|
Linaro_squad/squad/core/migrations/0097_build_placeholder.py
|
squad.core.migrations.0097_build_placeholder.Migration
|
class Migration(migrations.Migration):
dependencies = [
('core', '0096_build_keep_data'),
]
operations = [
migrations.CreateModel(
name='BuildPlaceholder',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('version', models.CharField(max_length=100)),
('build_deleted_at', models.DateTimeField(auto_now_add=True)),
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='build_placeholders', to='core.Project')),
],
),
migrations.AlterUniqueTogether(
name='buildplaceholder',
unique_together=set([('project', 'version')]),
),
]
|
class Migration(migrations.Migration):
pass
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 21 | 2 | 19 | 3 | 18 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.