Beispiel #1
0
class TestResultTest(TestCase):
    project = None
    tp = None
    launch = None

    def setUp(self):
        self.project = Project(name='Test Project 1')
        self.project.save()
        self.tp = TestPlan(name='Test Plan 1', project=self.project)
        self.tp.save()
        self.launch = Launch(test_plan=self.tp)
        self.launch.save()

    def tearDown(self):
        Project.objects.all().delete()
        TestPlan.objects.all().delete()
        Launch.objects.all().delete()

    def test_creation(self):
        r = TestResult(launch=self.launch,
                       name='TestCase1',
                       suite='TestSute1',
                       state=FAILED,
                       failure_reason='Very clear message about failure',
                       duration=1)
        r1 = TestResult(launch=self.launch,
                        name='TestCase1',
                        suite='TestSute2',
                        state=PASSED,
                        failure_reason='Very clear message about failure',
                        duration=1)
        r.save()
        r1.save()
        self.assertEqual(len(self.launch.testresult_set.all()), 2)
Beispiel #2
0
 def setUp(self):
     self.project = Project(name='Test Project 1')
     self.project.save()
     self.tp = TestPlan(name='Test Plan 1', project=self.project)
     self.tp.save()
     self.launch = Launch(test_plan=self.tp)
     self.launch.save()
Beispiel #3
0
 def setUp(self):
     self.project = Project(name="Test Project 1")
     self.project.save()
     self.tp = TestPlan(name="Test Plan 1", project=self.project)
     self.tp.save()
     self.launch = Launch(test_plan=self.tp)
     self.launch.save()
Beispiel #4
0
class TestPlanTests(TestCase):
    project = None

    def setUp(self):
        self.project = Project(name="Test Project 1")
        self.project.save()

    def tearDown(self):
        Project.objects.all().delete()
        TestPlan.objects.all().delete()

    def test_creation(self):
        tp = TestPlan(name="TestPlan1", project=self.project)
        tp.save()
        tp1 = TestPlan.objects.get(name="TestPlan1")
        self.assertEqual(tp, tp1)

    def test_duplication(self):
        TestPlan.objects.get_or_create(name="TestPlan1", project=self.project)
        TestPlan.objects.get_or_create(name="TestPlan1", project=self.project)
        self.assertEqual(len(TestPlan.objects.all()), 1)
Beispiel #5
0
class TestPlanTests(TestCase):
    project = None

    def setUp(self):
        self.project = Project(name='Test Project 1')
        self.project.save()

    def tearDown(self):
        Project.objects.all().delete()
        TestPlan.objects.all().delete()

    def test_creation(self):
        tp = TestPlan(name='TestPlan1', project=self.project)
        tp.save()
        tp1 = TestPlan.objects.get(name='TestPlan1')
        self.assertEqual(tp, tp1)

    def test_duplication(self):
        TestPlan.objects.get_or_create(name='TestPlan1', project=self.project)
        TestPlan.objects.get_or_create(name='TestPlan1', project=self.project)
        self.assertEqual(len(TestPlan.objects.all()), 1)
Beispiel #6
0
class TestLaunch(TestCase):
    project = None
    tp = None

    def setUp(self):
        self.project = Project(name="Test Project 1")
        self.project.save()
        self.tp = TestPlan(name="Test Project 1", project=self.project)
        self.tp.save()

    def tearDown(self):
        Project.objects.all().delete()
        TestPlan.objects.all().delete()
        Launch.objects.all().delete()

    def test_creation(self):
        url = "http://2gis.local"
        l = Launch(test_plan=self.tp, started_by=url)
        l.save()
        l1 = self.tp.launch_set.first()
        self.assertEqual(l, l1)
        l1.started_by = url
Beispiel #7
0
class TestLaunch(TestCase):
    project = None
    tp = None

    def setUp(self):
        self.project = Project(name='Test Project 1')
        self.project.save()
        self.tp = TestPlan(name='Test Project 1', project=self.project)
        self.tp.save()

    def tearDown(self):
        Project.objects.all().delete()
        TestPlan.objects.all().delete()
        Launch.objects.all().delete()

    def test_creation(self):
        url = 'http://2gis.local'
        launch = Launch(test_plan=self.tp, started_by=url)
        launch.save()
        l1 = self.tp.launch_set.first()
        self.assertEqual(launch, l1)
        l1.started_by = url
Beispiel #8
0
def addProject():
    uuid = create_uuid()
    name = request.form.get('name')
    region = request.form.get('region')
    version = request.form.get('version')
    add_data = Project(uuid=uuid,
                       project_name=name,
                       project_region=region,
                       project_version=version)
    db.session.add(add_data)
    db.session.commit()
    data = {'static': '1', 'message': 'success'}
    return data
Beispiel #9
0
class TestResultTest(TestCase):
    project = None
    tp = None
    launch = None

    def setUp(self):
        self.project = Project(name="Test Project 1")
        self.project.save()
        self.tp = TestPlan(name="Test Plan 1", project=self.project)
        self.tp.save()
        self.launch = Launch(test_plan=self.tp)
        self.launch.save()

    def tearDown(self):
        Project.objects.all().delete()
        TestPlan.objects.all().delete()
        Launch.objects.all().delete()

    def test_creation(self):
        r = TestResult(
            launch=self.launch,
            name="TestCase1",
            suite="TestSute1",
            state=FAILED,
            failure_reason="Very clear message about failure",
            duration=1,
        )
        r1 = TestResult(
            launch=self.launch,
            name="TestCase1",
            suite="TestSute2",
            state=PASSED,
            failure_reason="Very clear message about failure",
            duration=1,
        )
        r.save()
        r1.save()
        self.assertEqual(len(self.launch.testresult_set.all()), 2)
Beispiel #10
0
 def setUp(self):
     self.project = Project(name="Test Project 1")
     self.project.save()
     self.tp = TestPlan(name="Test Project 1", project=self.project)
     self.tp.save()
Beispiel #11
0
 def setUp(self):
     self.project = Project(name="Test Project 1")
     self.project.save()
Beispiel #12
0
 def test_creation(self):
     p = Project(name="Test Project 1")
     p.save()
     p1 = Project.objects.get(name__exact="Test Project 1")
     self.assertEqual(p, p1)
Beispiel #13
0
 def setUp(self):
     self.project = Project(name='Test Project 1')
     self.project.save()
     self.tp = TestPlan(name='Test Project 1', project=self.project)
     self.tp.save()
Beispiel #14
0
 def setUp(self):
     self.project = Project(name='Test Project 1')
     self.project.save()
Beispiel #15
0
 def test_creation(self):
     p = Project(name='Test Project 1')
     p.save()
     p1 = Project.objects.get(name__exact='Test Project 1')
     self.assertEqual(p, p1)
Beispiel #16
0
def data_post():  # Python 2.7.8 验证可用
    if request.method == 'GET':
        return 'GET'

    post_data = json.loads(request.data)
    # table project
    pro_name = post_data.get('pro_name', 0)
    pro_type = post_data.get('pro_type', 0)
    pro_master = post_data.get('pro_master', 0)
    pro_operations = post_data.get('pro_operations', 0)
    # table instance
    db_usage = post_data.get(
        'db_usage', 0)  # <type 'unicode'> /?/ db_usage.encode("utf-8")
    db_type = post_data.get('db_type', 0)
    # table size
    host = post_data.get('host', 0)
    port = post_data.get('port', 0)
    size = post_data.get('size', 0)
    tactics = post_data.get('tactics', 0)
    time_cost = post_data.get('time_cost', 0)
    agent_date = post_data.get('agent_date', 0)
    agent_datetime = post_data.get('agent_datetime', 0)

    # 把数据保存到 MySQL
    # 判定项目是否存在, 或新增
    pro_obj = db.session.query(Project).filter(
        and_(Project.name == pro_name), Project.type == pro_type).first()
    if not pro_obj:
        pro_obj = Project(name=pro_name,
                          type=pro_type,
                          pm=pro_master,
                          op=pro_operations)
        db.session.add(pro_obj)
        db.session.flush()
    else:
        pro_obj.pm = pro_master
        pro_obj.op = pro_operations
        db.session.commit()

    # 判定实例是否存在, 或新增
    ins_obj = db.session.query(Instance).filter(
        and_(Instance.host == host), and_(Instance.port == port),
        Instance.project_id == pro_obj.id).first()
    if not ins_obj:
        ins_obj = Instance(host=host,
                           port=port,
                           db_usage=db_usage,
                           db_type=db_type,
                           project_id=pro_obj.id)
        db.session.add(ins_obj)
        db.session.flush()
    else:
        ins_obj.db_usage = db_usage
        ins_obj.db_type = db_type
        ins_obj.project_id = pro_obj.id
        db.session.commit()

    # 添加新数据
    new_row_obj = Size(size=str(size),
                       tactics=tactics,
                       time_cost=time_cost,
                       agent_date=agent_date,
                       agent_datetime=agent_datetime,
                       instance_id=ins_obj.id)

    db.session.add(new_row_obj)
    db.session.commit()
    return 'OK'