CrashFactory   A
last analyzed

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
# coding: utf8
2
3
"""
4
This software is licensed under the Apache 2 license, quoted below.
5
6
Copyright 2014 Crystalnix Limited
7
8
Licensed under the Apache License, Version 2.0 (the "License"); you may not
9
use this file except in compliance with the License. You may obtain a copy of
10
the License at
11
12
    http://www.apache.org/licenses/LICENSE-2.0
13
14
Unless required by applicable law or agreed to in writing, software
15
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17
License for the specific language governing permissions and limitations under
18
the License.
19
"""
20
21
from django.core.files.uploadedfile import SimpleUploadedFile
22
from django.db.models import signals
23
24
import factory
25
26
27
class SymbolsFactory(factory.DjangoModelFactory):
28
    class Meta:
29
        model = 'crash.Symbols'
30
31
    file = SimpleUploadedFile('./fake.sym', b' ' * 123)
32
    debug_id = factory.Sequence(lambda n: 'C1C0FA629EAA4B4D9DD2ADE270A231C%s' % n)
33
    debug_file = factory.Sequence(lambda n: 'BreakpadTestApp_%s.pdb' % n)
34
35
36
class CrashFactory(factory.DjangoModelFactory):
37
    class Meta:
38
        model = 'crash.Crash'
39
40
    appid = factory.Sequence(lambda n: '{D0AB2EBC-931B-4013-9FEB-C9C4C2225%s}' % n)
41
    userid = factory.Sequence(lambda n: '{D0AB2EBC-931B-4013-9FEB-C9C4C2225%s}' % n)
42
    meta = {'lang': 'en'}
43
    signature = factory.Sequence(lambda n: 'signature_%s' % n)
44
45
46
@factory.django.mute_signals(signals.post_save)
47
class CrashFactoryWithFiles(CrashFactory):
48
49
    archive = factory.django.FileField(filename='the_file.dat')
50
    upload_file_minidump = factory.django.FileField(filename='the_file.dat')
51
52
53
class CrashDescriptionFactory(factory.DjangoModelFactory):
54
    class Meta:
55
        model = 'crash.CrashDescription'
56
57
    crash = factory.lazy_attribute(lambda x: CrashFactory())
58
    summary = 'Test Summary'
59
    description = 'Test Description'
60