Ejemplo n.º 1
0
    def test_create_suite_obj(self):
        responses.add(
            responses.GET,
            self.base_url + "/api/v1/" +
            "product/",  # + "?name=Firefox+OS&format=json",
            body=
            '{ "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 1 }, "objects": [ { "description": "", "id": 115540, "name": "Firefox OS", "productversions": [ { "codename": "", "id": 142229, "product": "/api/v1/product/115540/", "resource_uri": "/api/v1/productversion/142229/", "version": "v2.2" } ], "resource_uri": "/api/v1/product/115540/" } ] }',
            status=200,
            content_type="application/json")
        responses.add(
            responses.POST,
            self.base_url + "/api/v1/" + "suite/",
            body=
            '{ "description": "This is an awesome suite", "id": 888, "name": "Test Suite", "product": "/api/v1/product/115540/", "resource_uri": "/api/v1/suite/888/", "status": "active" }',
            status=201,
            content_type="application/json")
        suite = [
            'Test Suite', 'Firefox OS', 'v2.2', 'active',
            'This is an awesome suite'
        ]
        test_suite_obj = mtapi.MozTrapTestSuite(*suite)
        #if test_case_obj.existing_in_moztrap():
        #    test_case_obj.update(new_case_version_info={"name": case['id'], "status": case['state'], "tags":[]}, suites=[suite['name']])
        #else:
        test_suite_obj.create()

        expecteds = [
            ("GET", "product"),
            ("POST", "suite"),
        ]
        self._verify_call_order(expecteds, responses.calls)
        self.assertEqual(test_suite_obj.suite_uri, "/api/v1/suite/888/")
Ejemplo n.º 2
0
    def test_suite_init_delete(self):
        # verify the suite is deleted
        # Should we also delete related suitecase?
        #raise NotImplementedError
        responses.add(
            responses.GET,
            self.base_url + "/api/v1/" +
            "product/",  # + "?name=Firefox+OS&format=json",
            body=
            '{ "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 1 }, "objects": [ \
                      { "description": "", "id": 115540, "name": "Firefox OS", "productversions": [ { "codename": "", "id": 142229, "product": "/api/v1/product/115540/", "resource_uri": "/api/v1/productversion/142229/", "version": "v2.2" } ], "resource_uri": "/api/v1/product/115540/" } ] }',
            status=200,
            content_type="application/json")
        responses.add(
            responses.GET,
            self.base_url + "/api/v1/" +
            "suite/",  # + "?format=json&name=Test+Suite&product__name=Firefox+OS",
            body=
            '{ "meta": { "limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 1 }, "objects": [{\
                              "created_by": null,\
                              "description": "This is an awesome suite",\
                              "id": 888,\
                              "modified_by": null,\
                              "modified_on": "2012-03-01T19:38:14",\
                              "name": "Test Suite",\
                              "product": "/api/v1/product/115540/",\
                              "resource_uri": "/api/v1/suite/888/",\
                              "status": "active"\
                      }]}',
            status=200,
            content_type="application/json")
        responses.add(responses.DELETE,
                      self.base_url + "/api/v1/" + "suite/888",
                      body='',
                      status=200,
                      content_type="application/json")
        suite = [
            'Test Suite', 'Firefox OS', 'v2.2', 'active',
            'This is an awesome suite'
        ]
        test_suite_obj = mtapi.MozTrapTestSuite(*suite)

        self.assertTrue(test_suite_obj.existing_in_moztrap())
        self.assertEqual(test_suite_obj.suite_uri, "/api/v1/suite/888/")

        fields = [
            'name',
            'product_name',
            'product_uri',
            'product_version',
            'product_version_uri',
            'description',
            'status',
            'suite_id',
            'suite_uri',
            'suite_objs',
        ]

        for field in fields:
            self.assertNotEqual(getattr(test_suite_obj, field), None,
                                field + " should not be None")

        test_suite_obj.delete()

        #if test_case_obj.existing_in_moztrap():
        #    test_case_obj.update(new_case_version_info={"name": case['id'], "status": case['state'], "tags":[]}, suites=[suite['name']])
        #else:

        expecteds = [
            ("GET", "product"),
            ("GET", "suite"),
            ("DELETE", "suite"),
        ]
        self._verify_call_order(expecteds, responses.calls)