Beispiel #1
0
    def setUp(self):
        fone = Field(name='Test Field One', data_type='INTEGER')
        fone.save()
        ftwo = Field(name='Test Field Two', data_type='INTEGER')
        ftwo.save()

        s = Status(name='Blah')
        s.save()

        wone = Workflow(name='Test Flow One', create_status=s)
        wone.save()
        wtwo = Workflow(name='Test Flow Two', create_status=s)
        wtwo.save()

        u = User.objects.create_user('fakelead', '*****@*****.**', 'fake')
        u.save()

        self.project = Project(key='SCHEME',
                               name='Test Scheme Project',
                               lead=u)
        self.project.save()

        self.ttypeone = TicketType(name='Test Type One')
        self.ttypeone.save()
        self.ttypetwo = TicketType(name='Test Type One')
        self.ttypetwo.save()

        self.default_wkflow_scheme = WorkflowScheme(workflow=wone,
                                                    project=self.project)
        self.default_wkflow_scheme.save()

        self.ttypeone_wkflow_scheme = WorkflowScheme(workflow=wtwo,
                                                     project=self.project,
                                                     ticket_type=self.ttypeone)
        self.ttypeone_wkflow_scheme.save()

        self.default_field_scheme = FieldScheme(name='Default Field Scheme',
                                                project=self.project)
        self.default_field_scheme.save()

        FieldSchemeField(field=fone, scheme=self.default_field_scheme).save()

        self.ttypeone_field_scheme = FieldScheme(name='Ttypeone Field Scheme',
                                                 project=self.project,
                                                 ticket_type=self.ttypeone)
        self.ttypeone_field_scheme.save()

        FieldSchemeField(field=fone, scheme=self.ttypeone_field_scheme).save()
        FieldSchemeField(field=ftwo, scheme=self.ttypeone_field_scheme).save()
    def import_workflows(self, galaxy_url):
        if galaxy_url:
            galaxy_server, created = Server.objects.get_or_create(
                url=galaxy_url)
        else:
            try:
                galaxy_server = Server.objects.get(current=True)
            except Server.DoesNotExist:
                raise CommandError(
                    'Server Galaxy does not exist, please use --galaxyurl')

        galaxy_key = GalaxyUser.objects.filter(
            galaxy_server__url=galaxy_url,
            anonymous=True)
        print(galaxy_key)
        workflows_url = '%s/%s/%s/?key=%s' % (
            galaxy_server.url,
            'api',
            'workflows',
            galaxy_key.first().api_key)

        # fetch list of tools
        connection = requests.get(workflows_url)
        print(workflows_url)
        print(connection.status_code)
        if connection.status_code == 200:
            wf_list = connection.json() or []
            for wf in wf_list:
                wfname = wf.get('name')
                wfid = wf.get('id')
                self.stdout.write(
                    self.style.SUCCESS(
                        "importing workflow %s" % (wfname)
                    )
                )
                if(re.search('oneclick', wfname, re.IGNORECASE) or
                   wfname in self.wfnames):
                    w = Workflow(
                        galaxy_server=galaxy_server,
                        id_galaxy=wfid,
                        name=wfname,
                        category='base',
                        description=wfname,
                        slug=slugify(wfname))
                    w.save()
        else:
            self.stdout.write("Problem while querying galaxy server")
    def import_workflows(self, galaxy_url):
        if galaxy_url:
            galaxy_server, created = Server.objects.get_or_create(
                url=galaxy_url)
        else:
            try:
                galaxy_server = Server.objects.get(current=True)
            except Server.DoesNotExist:
                raise CommandError(
                    'Server Galaxy does not exist, please use --galaxyurl')

        galaxy_key = GalaxyUser.objects.filter(galaxy_server__url=galaxy_url,
                                               anonymous=True)
        print(galaxy_key)
        workflows_url = '%s/%s/%s/?key=%s' % (
            galaxy_server.url, 'api', 'workflows', galaxy_key.first().api_key)

        # fetch list of tools
        connection = requests.get(workflows_url)
        print(workflows_url)
        print(connection.status_code)
        if connection.status_code == 200:
            wf_list = connection.json() or []
            for wf in wf_list:
                wfname = wf.get('name')
                wfid = wf.get('id')
                self.stdout.write(
                    self.style.SUCCESS("importing workflow %s" % (wfname)))
                if (re.search('oneclick', wfname, re.IGNORECASE)
                        or wfname in self.wfnames):
                    try:
                        w = Workflow.objects.get(id_galaxy=wfid)
                        self.stdout.write("Workflow %s already present" %
                                          wfname)
                    except Workflow.DoesNotExist:
                        w = Workflow(galaxy_server=galaxy_server,
                                     id_galaxy=wfid,
                                     name=wfname,
                                     category='base',
                                     description=wfname,
                                     slug=slugify(wfname))
                        w.save()
        else:
            self.stdout.write("Problem while querying galaxy server")
Beispiel #4
0
    def handle(self, *args, **kwargs):
        try:
            admin = User.objects.create_superuser('testadmin',
                                                  '*****@*****.**',
                                                  'test',
                                                  first_name='Test',
                                                  last_name='Testerson II')
            user = User.objects.create_user('testuser',
                                            '*****@*****.**',
                                            'test',
                                            first_name='Test',
                                            last_name='Testerson')

            admin.save()
            user.save()

            users = [admin, user]

            p = Project(name='Dummy Project', lead=admin, key='TEST')

            p.save()

            high = FieldOption(name='High')
            medium = FieldOption(name='Medium')
            low = FieldOption(name='Low')

            high.save()
            medium.save()
            low.save()

            priorities = [high, medium, low]

            story_points = Field(name='Story Points', data_type='INTEGER')
            priority = Field(name='Priority', data_type='OPTION')
            priority.save()
            priority.options.set(priorities)

            story_points.save()
            priority.save()

            backlog = Status(name='Backlog', state='TODO')
            in_progress = Status(name='In Progress', state='IN_PROGRESS')
            done = Status(name='Done', state='DONE')

            backlog.save()
            in_progress.save()
            done.save()

            w = Workflow(name='Default Workflow', create_status=backlog)

            w.save()

            create = Transition(name='Backlog', to_status=backlog, workflow=w)
            to_prog = Transition(name='In Progress',
                                 to_status=in_progress,
                                 workflow=w)
            to_done = Transition(name='Done', to_status=done, workflow=w)

            to_done.save()
            to_prog.save()
            create.save()

            bug = TicketType(name='Bug')
            epic = TicketType(name='Epic')
            feature = TicketType(name='Feature')

            bug.save()
            epic.save()
            feature.save()

            ticket_types = [bug, feature, epic]
            p.ticket_types.add(bug)
            p.ticket_types.add(feature)
            p.ticket_types.add(epic)
            p.save()

            fs = FieldScheme(name='Bug Field Scheme',
                             project=p,
                             ticket_type=bug)
            fs.save()

            FieldSchemeField(field=priority, scheme=fs).save()

            fs = FieldScheme(name='Epic Field Scheme',
                             project=p,
                             ticket_type=epic)
            fs.save()

            FieldSchemeField(field=priority, scheme=fs).save()

            fs = FieldScheme(name='Feature Field Scheme',
                             project=p,
                             ticket_type=feature)
            fs.save()

            FieldSchemeField(field=priority, scheme=fs).save()
            FieldSchemeField(field=story_points, scheme=fs).save()

            ws = WorkflowScheme(project=p, ticket_type=None, workflow=w)
            ws.save()

            for i in range(100):
                t = Ticket(key=p.key + '-' + str(i + 1),
                           summary='This is ticket #' + str(i + 1),
                           reporter=users[randint(0, 1)],
                           assignee=users[randint(0, 1)],
                           ticket_type=ticket_types[randint(0, 2)],
                           project=p,
                           status=backlog,
                           workflow=w,
                           description="""
# Utque erant et edentem suoque nox fertur

## Tegi aurum inridet flumine auras natas vulnus

Lorem markdownum misit sudor, sine eodem libratum munus aristis tutos, hac.
Longe mens vultus iurgia Iovem difficilis suus; ut erat mollis robore terga ei
perque! Quae quos sacrorum custodit quaecumque harena fallis et modo hinc
[recessu](http://venerat.com/), superorum Peleus, temptamenta. **Pudore** Sparte
lentisciferumque nataque inpulsos et ille novat haec sollicitare Plura, levis
vellet valuit, summo dum lutea viso. Solebat lintea ingentibus capillis dicta
Paridis seque quoquam [poposcit in](http://per.net/) Tempe vivacem.

1. Nate nulli
2. Coniunx hausi nunc Quirini Othrys
3. Caede nascuntur ubera congreditur vincula ubi regis
4. Spatium pectore amplexus ferunt ille instat cultores

Illo dolores voluit Achaemenias unde theatris paventem secum ineamus minacia
retro. Duplicataque siste suo recessit; opes albus moribunda referentem animam
nulloque domini et laborent hac?

## Senecta finita

Iovi nec aperire mihi mira respondit, qui exit vulnere aeterno dixerunt dat
corpus? Erit terrae, avidas; sola plenum, cauda edax et referre. Quater posuere:
facit mihi primaque remanet parte, eundo.
            """)
                t.save()

                fvs = [
                    FieldValue(field=story_points,
                               int_value=randint(1, 20),
                               content_object=t),
                    FieldValue(field=priority,
                               str_value=priorities[randint(0, 2)].name,
                               content_object=t)
                ]

                for fv in fvs:
                    fv.save()

            t = Ticket.objects.get(key='TEST-1')

            for i in range(25):
                body = """This is the %d th comment

# Yo Dawg

**I** *heard* you

> like markdown

so I put markdown in your comment""" % i
                c = Comment(body=body, author=users[randint(0, 1)], ticket=t)
                c.save()
        except IntegrityError as e:
            print(
                "Database already seeded, run cleandb first to force seeding..."
            )
            print(e)
            pass