Workfow da kullanacağımız bazı özel işaretler olacaktır.Bunların tanımlarını şu şekilde yazdım.
Ancak her birisi nasıl gösterilir ve daha detaylı bilgi için bu siteye bakabiliriz : https://www.lucidchart.com/pages/bpmn/gateways
SERVICE TASK : bir işlemin gerçekleşebilmesi için bir uygulama ya da bir web servisi kullanır.Kullanıcının bir işlem yapmasını beklemez.
SEND TASK : diğer bir işleme ya da alana mesaj gönderir.Mesaj gönderilince task tamamlanmış olur.
USER TASK : gercekleşmesi için kullanıcının bir işlem yapmasını gerektirir.
SCRIPT TASK TYPE : when a process execution arrives at the script task, the corresponding script executed.
RECEIVE TASK : Dısarıdan gelecek bir mesaja göre çalışır.
EXCLUSIVE GATEWAY(XOR) : Bir işlem kosullara farklı path lere ayrıldıgı zaman kullanılır. Sonuc hangi path e uygunsa ordaki işlem gerçekleştirilir.
PARALEL GATEWAY : Bir işlemin sonucuna göre işlem yapmazlar.Aynı anda iki işlemi de gerçekleştirirler.
INCLUSIVE GATEWAY : paralel ve exclusive gatewaylerin kombinasyonudur. Exclusive gibi kosulların oldugu durumlar vardır.Ana fark inclusive gateway paralel gateway gibi birden fazla sequence flow içerebilir.
SWIMLANE : Swimlane pool ve lane den olusur. pool swimlane nin temel parcasıdır. pool lar lane lerden olusur.
PROCESS DIAGRAMS : Represents regular flow between tasks, events and decision points to complete a process in the company.
COLLABORATION DIAGRAMS :represents message flows or commnication routes between process or entities like customers or partners.
CONVERSATION DIAGRAMS : represents group of informations.Communications between process and participants.
MANUAL TASK : manuel olarak bir sey girilmesini bekler.
Genel olarak kullanacaklarımız bunlar. Örnek bir programa bakalım:
Bu arada burada kodlarımızı Python kullanarak yazacagız.O yüzden uygun bir IDE(Integrated Development Environment) indirelim.PyCharm kullanacagız.https://www.jetbrains.com/pycharm/download/ . Bu linki kullanarak ögrenci hesabımızla indirip kullanabiliriz.
Workflow un source kısmını da ekliyorum:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://activiti.org/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_qyVjYLNPEeSf4I-xcGOQ0Q" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://activiti.org/bpmn">
<bpmn2:process id="simple_login" isExecutable="false">
<bpmn2:startEvent id="StartEvent_1">
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:userTask id="show_login_form" camunda:class="views.show_login" camunda:assignee="views.show_login" name="show login">
<bpmn2:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="activities">
<camunda:list>
<camunda:value>views.show_login</camunda:value>
</camunda:list>
</camunda:inputParameter>
</camunda:inputOutput>
<camunda:properties>
<camunda:property/>
</camunda:properties>
</bpmn2:extensionElements>
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_7</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="show_login_form"/>
<bpmn2:sequenceFlow id="SequenceFlow_7" name="" sourceRef="show_login_form" targetRef="Task_3"/>
<bpmn2:serviceTask id="Task_3" camunda:class="views.do_login" name="authenticate">
<bpmn2:incoming>SequenceFlow_7</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_8</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:sequenceFlow id="SequenceFlow_8" name="" sourceRef="Task_3" targetRef="ExclusiveGateway_1"/>
<bpmn2:exclusiveGateway id="ExclusiveGateway_1">
<bpmn2:incoming>SequenceFlow_8</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
<bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing>
</bpmn2:exclusiveGateway>
<bpmn2:sequenceFlow id="SequenceFlow_3" name="login failed" sourceRef="ExclusiveGateway_1" targetRef="show_login_form">
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">is_login_successful</bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="SequenceFlow_6" name="login successful" sourceRef="ExclusiveGateway_1" targetRef="UserTask_1">
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">is_login_successful</bpmn2:conditionExpression>
</bpmn2:sequenceFlow>
<bpmn2:dataObject id="DataObject_1" name="d1"/>
<bpmn2:dataObject id="DataObject_2" name="d2"/>
<bpmn2:endEvent id="EndEvent_1">
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:userTask id="UserTask_1" camunda:assignee="views.show_dashboard" name="show_dashboard">
<bpmn2:incoming>SequenceFlow_6</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="UserTask_1" targetRef="EndEvent_1"/>
</bpmn2:process>
<bpmn2:dataStore id="DataStore_1"/>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="56.0" y="208.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="show_login_form">
<dc:Bounds height="80.0" width="100.0" x="142.0" y="186.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_2" targetElement="_BPMNShape_Task_2">
<di:waypoint xsi:type="dc:Point" x="92.0" y="226.0"/>
<di:waypoint xsi:type="dc:Point" x="142.0" y="226.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_5" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true">
<dc:Bounds height="50.0" width="50.0" x="504.0" y="200.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="529.0" y="255.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ExclusiveGateway_5" targetElement="_BPMNShape_Task_2">
<di:waypoint xsi:type="dc:Point" x="529.0" y="250.0"/>
<di:waypoint xsi:type="dc:Point" x="529.0" y="312.0"/>
<di:waypoint xsi:type="dc:Point" x="266.0" y="312.0"/>
<di:waypoint xsi:type="dc:Point" x="266.0" y="276.0"/>
<di:waypoint xsi:type="dc:Point" x="242.0" y="260.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="17.0" width="56.0" x="501.0" y="275.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_3" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="720.0" y="208.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="738.0" y="249.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_ExclusiveGateway_5" targetElement="_BPMNShape_UserTask_2">
<di:waypoint xsi:type="dc:Point" x="554.0" y="225.0"/>
<di:waypoint xsi:type="dc:Point" x="587.0" y="226.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="17.0" width="79.0" x="532.0" y="226.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_Task_6" bpmnElement="Task_3">
<dc:Bounds height="58.0" width="100.0" x="341.0" y="197.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_7" bpmnElement="SequenceFlow_7" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_Task_6">
<di:waypoint xsi:type="dc:Point" x="242.0" y="226.0"/>
<di:waypoint xsi:type="dc:Point" x="341.0" y="226.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="274.0" y="226.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_8" bpmnElement="SequenceFlow_8" sourceElement="_BPMNShape_Task_6" targetElement="_BPMNShape_ExclusiveGateway_5">
<di:waypoint xsi:type="dc:Point" x="441.0" y="226.0"/>
<di:waypoint xsi:type="dc:Point" x="466.0" y="226.0"/>
<di:waypoint xsi:type="dc:Point" x="466.0" y="225.0"/>
<di:waypoint xsi:type="dc:Point" x="504.0" y="225.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="470.0" y="225.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_UserTask_2" bpmnElement="UserTask_1">
<dc:Bounds height="58.0" width="100.0" x="587.0" y="197.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_UserTask_2" targetElement="_BPMNShape_EndEvent_3">
<di:waypoint xsi:type="dc:Point" x="687.0" y="226.0"/>
<di:waypoint xsi:type="dc:Point" x="720.0" y="226.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
Bu workflow un test ve view dosyalarını da ekleyelim:
views.py:
# -*- coding: utf-8 -*-"""zengine test views all test views should use current.jsonin and current.jsonout for data input output purposes. """ # Copyright (C) 2015 ZetaOps Inc.## This file is licensed under the GNU General Public License v3# (GPLv3). See LICENSE.txt for details. TEST_USER = {'username': 'user', 'password': 'pass', 'id': 1} def do_login(current): login_data = current.jsonin['login_data'] logged_in = login_data['username'] == TEST_USER['username'] and login_data['password'] == TEST_USER['password'] current['task'].data['is_login_successful'] = logged_in current['jsonout'] = {'success': logged_in} def show_login(current): current['jsonout'] = {'form': 'login_form'} def show_dashboard(current): current['jsonout'] = {'screen': 'dashboard'}
test_simple.py:
# -*- coding: utf-8 -*-""""""# -# Copyright (C) 2015 ZetaOps Inc.## This file is licensed under the GNU General Public License v3# (GPLv3). See LICENSE.txt for details. from tests.testengine import TestEngine def test_show_login(): engine = TestEngine() engine.set_current(workflow_name='simple_login') engine.load_or_create_workflow() engine.run() assert {'form': 'login_form'} == engine.current.jsonout def test_login_successful(): engine = TestEngine() engine.set_current(workflow_name='simple_login') engine.load_or_create_workflow() engine.run() engine.set_current(jsonin={'login_data': {'username': 'user', 'password': 'pass'}}) engine.run() assert {'screen': 'dashboard'} == engine.current.jsonout def test_login_failed(): engine = TestEngine() engine.set_current(workflow_name='simple_login') engine.load_or_create_workflow() engine.run() engine.set_current(jsonin={'login_data': {'username': 'user', 'password': 'WRONG_PASS'}}) engine.run() assert {'form': 'login_form'} == engine.current.jsonout def test_login_fail_retry_success(): engine = TestEngine() engine.set_current(workflow_name='simple_login') engine.load_or_create_workflow() engine.run() engine.set_current(jsonin={'login_data': {'username': 'user', 'password': 'WRONG_PASS'}}) engine.run() engine.set_current(jsonin={'login_data': {'username': 'user', 'password': 'pass'}}) engine.run() assert {'screen': 'dashboard'} == engine.current.jsonout
Bu simple_login adlı workflow u kendime örnek olarak almıstım.Simdi kendi ugrastıgım workflow u ekliyorum. Bunun adı ise personel_duzenle
bu workflow un source kısmını da ekliyorum:
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://activiti.org/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_ULp1QB_KEeWBgv8ICzr-mg" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://activiti.org/bpmn">
<bpmn2:collaboration id="_Collaboration_2">
<bpmn2:participant id="_Participant_2" name="Personel Duzenle" processRef="personel_duzenle"/>
</bpmn2:collaboration>
<bpmn2:process id="personel_duzenle" isExecutable="false">
<bpmn2:laneSet id="LaneSet_1" name="Lane Set 1">
<bpmn2:lane id="Lane_1" name="Personel Isleri Memuru">
<bpmn2:flowNodeRef>StartEvent_1</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Personel_Listele</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Personel_Goruntule</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Personel_Duzenle</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>EndEvent_2</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Personel_Kaydet</bpmn2:flowNodeRef>
<bpmn2:flowNodeRef>Degisiklikleri_Onizle</bpmn2:flowNodeRef>
</bpmn2:lane>
</bpmn2:laneSet>
<bpmn2:startEvent id="StartEvent_1" name="Dasboard
Personel 
Duzenle
Butonu">
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="Personel_Listele"/>
<bpmn2:userTask id="Personel_Listele" camunda:assignee="views_personel.personel_listele" name="Personel
Listele">
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="Personel_Listele" targetRef="Personel_Goruntule"/>
<bpmn2:userTask id="Personel_Goruntule" camunda:assignee="views_personel.personel_goruntule" name="Personel
Görüntüle">
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="Personel_Goruntule" targetRef="Personel_Duzenle"/>
<bpmn2:userTask id="Personel_Duzenle" camunda:assignee="views_personel.personel_duzenle" name="Personel 
Düzenle">
<bpmn2:incoming>SequenceFlow_3</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="Personel_Duzenle" targetRef="Degisiklikleri_Onizle"/>
<bpmn2:endEvent id="EndEvent_2">
<bpmn2:incoming>SequenceFlow_9</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:userTask id="Personel_Kaydet" camunda:assignee="views_personel.personel_kaydet" name="Personel
Kaydet">
<bpmn2:incoming>SequenceFlow_6</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="Personel_Kaydet" targetRef="EndEvent_2"/>
<bpmn2:userTask id="Degisiklikleri_Onizle" camunda:assignee="views_personel.degisiklikleri_onizle" name="Deişiklikleri
Önizle">
<bpmn2:incoming>SequenceFlow_4</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_6</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:sequenceFlow id="SequenceFlow_6" name="" sourceRef="Degisiklikleri_Onizle" targetRef="Personel_Kaydet"/>
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="_Collaboration_2">
<bpmndi:BPMNShape id="_BPMNShape_Participant_2" bpmnElement="_Participant_2" isHorizontal="true">
<dc:Bounds height="430.0" width="1201.0" x="360.0" y="110.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_Lane_2" bpmnElement="Lane_1" isHorizontal="true">
<dc:Bounds height="430.0" width="1171.0" x="390.0" y="110.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_3" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="451.0" y="329.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="70.0" width="62.0" x="438.0" y="370.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_UserTask_3" bpmnElement="Personel_Listele">
<dc:Bounds height="80.0" width="100.0" x="588.0" y="307.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_3" targetElement="_BPMNShape_UserTask_3">
<di:waypoint xsi:type="dc:Point" x="487.0" y="347.0"/>
<di:waypoint xsi:type="dc:Point" x="588.0" y="347.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="501.0" y="347.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_UserTask_4" bpmnElement="Personel_Goruntule">
<dc:Bounds height="80.0" width="100.0" x="738.0" y="307.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_UserTask_3" targetElement="_BPMNShape_UserTask_4">
<di:waypoint xsi:type="dc:Point" x="688.0" y="347.0"/>
<di:waypoint xsi:type="dc:Point" x="738.0" y="347.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="710.0" y="347.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_UserTask_5" bpmnElement="Personel_Duzenle">
<dc:Bounds height="80.0" width="100.0" x="888.0" y="307.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_UserTask_4" targetElement="_BPMNShape_UserTask_5">
<di:waypoint xsi:type="dc:Point" x="838.0" y="347.0"/>
<di:waypoint xsi:type="dc:Point" x="888.0" y="347.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="860.0" y="347.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_UserTask_6" bpmnElement="Degisiklikleri_Onizle">
<dc:Bounds height="80.0" width="100.0" x="1056.0" y="308.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_UserTask_5" targetElement="_BPMNShape_UserTask_6">
<di:waypoint xsi:type="dc:Point" x="988.0" y="347.0"/>
<di:waypoint xsi:type="dc:Point" x="1056.0" y="348.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="1010.0" y="347.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_ServiceTask_2" bpmnElement="Personel_Kaydet">
<dc:Bounds height="80.0" width="100.0" x="1320.0" y="308.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_5" bpmnElement="EndEvent_2">
<dc:Bounds height="36.0" width="36.0" x="1500.0" y="329.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="0.0" width="0.0" x="1518.0" y="370.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_9" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_ServiceTask_2" targetElement="_BPMNShape_EndEvent_5">
<di:waypoint xsi:type="dc:Point" x="1420.0" y="348.0"/>
<di:waypoint xsi:type="dc:Point" x="1500.0" y="347.0"/>
<bpmndi:BPMNLabel>
<dc:Bounds height="6.0" width="6.0" x="1421.0" y="348.0"/>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_6" sourceElement="_BPMNShape_UserTask_6" targetElement="_BPMNShape_ServiceTask_2">
<di:waypoint xsi:type="dc:Point" x="1156.0" y="348.0"/>
<di:waypoint xsi:type="dc:Point" x="1320.0" y="348.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
Şimdi ise view ve test dosyalarını ekleyelim:
views_personel.py
TEST_PERSONEL = { 'personel_id': '10', 'personel_name': 'gamze', 'personel_lastname': 'sen', 'personel_list': ['10', '11', '12'], 'devam_et':'evet'} def personel_listele(current): current['jsonout'] = {'personel_list': ['10', '11', '12']} def personel_goruntule(current): current['jsonout'] = {'personel_id': '10', 'personel_name': 'gamze', 'personel_lastname': 'sen'} def personel_duzenle(current): personel_data = current.jsonin['personel_data'] if personel_data['personel_lastname'] == 'sensen': current['jsonout'] = {'sonuc': 'degisiklikleri onizle'} else: current['jsonout'] = {'sonuc': 'degisiklik yapilmadi'} def degisiklikleri_onizle(current): current['jsonout'] = {'personel_id': '10', 'personel_name': 'gamze', 'personel_lastname': 'sensen'} def personel_kaydet(current): current['jsonout'] = {'sonuc': 'personel kaydedildi'}
personel_test_simple.py:
from tests.testengine import TestEngine def test_personel_listele(): wf = TestEngine() wf.set_current(workflow_name='personel_duzenle') wf.load_or_create_workflow() wf.run() assert {'personel_list': ['10', '11', '12']} == wf.current.jsonout def test_personel_goruntule(): wf = TestEngine() wf.set_current(workflow_name='personel_duzenle') wf.load_or_create_workflow() wf.run() wf.set_current(workflow_name='personel_duzenle') wf.load_or_create_workflow() wf.run() assert {'personel_id': '10', 'personel_name': 'gamze', 'personel_lastname': 'sen'} == wf.current.jsonout def test_personel_duzenle_degisiklik_yap(): wf = TestEngine() wf.set_current(workflow_name='personel_duzenle') wf.load_or_create_workflow() wf.run() wf.set_current(workflow_name='personel_duzenle') wf.load_or_create_workflow() wf.run() wf.set_current( jsonin={'personel_data': {'personel_id': '10', 'personel_name': 'gamze', 'personel_lastname': 'sensen'}}) wf.run() assert {'sonuc': 'degisiklikleri onizle'} == wf.current.jsonout def test_personel_duzenle_degisiklik_yapma(): wf = TestEngine() wf.set_current(workflow_name='personel_duzenle') wf.load_or_create_workflow() wf.run() wf.set_current(workflow_name='personel_duzenle') wf.load_or_create_workflow() wf.run() wf.set_current( jsonin={'personel_data': {'personel_id': '10', 'personel_name': 'gamze', 'personel_lastname': 'sen'}}) wf.run() assert {'sonuc': 'degisiklik yapilmadi'} == wf.current.jsonout def test_degisiklikleri_onizle(): wf = TestEngine() wf.set_current(workflow_name='personel_duzenle') wf.load_or_create_workflow() # step 1 - Personel Listele wf.run() # step 2 - Personel Goruntule wf.run() # Step 3 - Personel Duzenle # Workflow'a verinin yeni halini veriyoruz wf.set_current( jsonin={'personel_data': {'personel_id': '10', 'personel_name': 'gamze', 'personel_lastname': 'sensen'}}) wf.run() # Veri degistigi icin degisiklik onizle bekliyoruz assert {'sonuc': 'degisiklikleri onizle'} == wf.current.jsonout def test_personel_kaydet(): wf = TestEngine() wf.set_current(workflow_name='personel_duzenle') wf.load_or_create_workflow() # step 1 - Personel Listele wf.run() # step 2 - Personel Goruntule wf.run() # Step 3 - Personel Duzenle # Workflow'a verinin yeni halini veriyoruz wf.set_current( jsonin={'personel_data': {'personel_id': '10', 'personel_name': 'gamze', 'personel_lastname': 'sensen'}}) wf.run() wf.run() wf.run() wf.run() assert {'sonuc': 'personel kaydedildi'} == wf.current.jsonout
Şeklindedir.
Hiç yorum yok:
Yorum Gönder