def upload(self, filepath):
		"""

		Uploads given file as an attachment for specified bug.

		Keyword arguments:
		self     BugAttachmentsHandler -- Self instance
		filepath str                   -- an absolute path of the file to be uploaded
										example: /home/path/to/file.txt (Linux), C:\\Users\\Documents\\file.txt (Windows)

		Exceptions:
		SDKInvalidArgException if filepath is not a string

		Returns:
		BugAttachment -- the newly uploaded attachment

		"""

		if not isinstance(filepath, str):
			raise SDKInvalidArgException('`filepath` must be of type string')

		req = APIRequest(
			self._origin,
			'/v1/bugs/' + str(self._bugID) + '/attachments',
			'POST',
			{
				'form_data': True,
				'file_path': filepath
			}
		)

		return BugAttachment(self._origin, req.exec_())
	def update(self, id_, fields):
		super().update(id_, fields)

		supports = {
			'title'              : False,
			'status_id'          : False,
			'severity_id'        : False,
			'priority_id'        : False,
			'project_version_id' : False,
			'project_section_id' : False,
			'type_id'            : False,
			'assigned_user_id'   : False,
			'description'        : False,
			'expected_results'   : False,
			'steps'              : False,
			'platform'           : False
			# 'device_model'       : False,
			# 'device_model_id'    : False,
			# 'os'                 : False,
			# 'os_version'         : False,
			# 'os_version_id'      : False,
			# 'browser_version_id' : False
		}

		if self.enforce(fields, supports):
			initFields = {'include': 'steps,platform'}
			initFields.update(fields)
			fields = initFields

			req = APIRequest(self._origin, '/v1/bugs/' + str(id_), 'PUT', {'params': fields})
			return Bug(self._origin, req.exec_())
Exemplo n.º 3
0
	def create(self, fields):
		super().create(fields)

		supports = {
			'url'                         : True,
			'bug_create'                  : False,
			'bug_create_severity_critical': False,
			'bug_create_severity_major'   : False,
			'bug_create_priority_critical': False,
			'bug_create_priority_high'    : False,
			'bug_edit'                    : False,
			'bug_assign'                  : False,
			'bug_assign_target'           : False,
			'bug_status_change'           : False,
			'bug_resolved'                : False,
			'bug_move'                    : False,
			'bug_delete'                  : False,
			'comment_create'              : False,
			'comment_edit'                : False,
			'message_create'              : False,
			'message_edit'                : False,
			'attachment_create'           : False,
			'run_start'                   : False,
			'run_finish'                  : False
		}

		if self.enforce(fields, supports):
			req = APIRequest(
				self._origin,
				'/v1/projects/' + str(self._projectID) + '/integrations/webhooks',
				'POST',
				{'params': fields}
			)

			return ProjectWebhook(self._origin, req.exec_())
Exemplo n.º 4
0
    def update(self, id_, fields):
        super().update(id_, fields)

        supports = {
            'title': False,
            'status_id': False,
            'severity_id': False,
            'priority_id': False,
            'project_version_id': False,
            'project_section_id': False,
            'type_id': False,
            'assigned_user_id': False,
            'description': False,
            'expected_results': False,
            'steps': False,
            'platform': False
            # 'device_model'       : False,
            # 'device_model_id'    : False,
            # 'os'                 : False,
            # 'os_version'         : False,
            # 'os_version_id'      : False,
            # 'browser_version_id' : False
        }

        if self.enforce(fields, supports):
            initFields = {'include': 'steps,platform'}
            initFields.update(fields)
            fields = initFields

            req = APIRequest(self._origin, '/v1/bugs/' + str(id_), 'PUT',
                             {'params': fields})
            return Bug(self._origin, req.exec_())
Exemplo n.º 5
0
    def upload(self, filepath):
        """

		Uploads given file as an attachment for specified bug.

		Keyword arguments:
		self     BugAttachmentsHandler -- Self instance
		filepath str                   -- an absolute path of the file to be uploaded
										example: /home/path/to/file.txt (Linux), C:\\Users\\Documents\\file.txt (Windows)

		Exceptions:
		SDKInvalidArgException if filepath is not a string

		Returns:
		BugAttachment -- the newly uploaded attachment

		"""

        if not isinstance(filepath, str):
            raise SDKInvalidArgException('`filepath` must be of type string')

        req = APIRequest(self._origin,
                         '/v1/bugs/' + str(self._bugID) + '/attachments',
                         'POST', {
                             'form_data': True,
                             'file_path': filepath
                         })

        return BugAttachment(self._origin, req.exec_())
Exemplo n.º 6
0
    def delete(self, id_):
        super().delete(id_)

        req = APIRequest(
            self._origin,
            '/v1/projects/' + str(self._projectID) + '/users/' + str(id_),
            'DELETE')
        return req.exec_()
Exemplo n.º 7
0
    def find(self, id_):
        super().find(id_)

        req = APIRequest(
            self._origin,
            '/v1/projects/' + str(self._projectID) + '/test-cases/' + str(id_),
            'GET')
        return ProjectTestCase(self._origin, req.exec_())
    def find(self, id_):
        super().find(id_)

        req = APIRequest(self._origin, '/v1/platform/browsers/' + str(id_),
                         'GET', {'params': {
                             'include': 'versions'
                         }})
        return PlatformBrowser(self._origin, req.exec_())
Exemplo n.º 9
0
    def find(self, id_):
        super().find(id_)

        req = APIRequest(self._origin, '/v1/bugs/' + str(id_), 'GET', {
            'params': {
                'include': 'steps,platform,attachments,comments,tags'
            }
        })
        return Bug(self._origin, req.exec_())
Exemplo n.º 10
0
	def find(self, id_):
		super().find(id_)

		req = APIRequest(
			self._origin,
			'/v1/projects/' + str(self._projectID) + '/integrations/webhooks/' + str(id_),
			'GET'
		)
		return ProjectWebhook(self._origin, req.exec_())
Exemplo n.º 11
0
	def delete(self, id_):
		super().delete(id_)

		req = APIRequest(
			self._origin,
			'/v1/projects/' + str(self._projectID) + '/integrations/webhooks/' + str(id_),
			'DELETE'
		)
		return req.exec_()
Exemplo n.º 12
0
    def testEntityListBadRespMissingCollection(self):
        req = APIRequest(Client(), '/any/method', 'GET')
        req.call = MagicMock(return_value={
            'data': '{"meta": {"pagination": {}}}',
            'status': 200
        })

        self.assertRaisesRegex(SDKUnexpectedResponseException, 'collection',
                               EntityList, Client(), req, 'X')
    def find(self, id_, params=None):
        super().find(id_)

        if params is None:
            params = {}

        req = APIRequest(self._origin, '/v1/bugs/' + str(id_), 'GET',
                         {'params': params})
        return Bug(self._origin, req.exec_())
Exemplo n.º 14
0
	def exchangeAuthCode(self, clientID, clientSecret, grantType, code, redirectURI):
		"""

		Generates an access token string from the provided authorization code

		Keyword arguments:
		self         OAuth2Handler -- Self instance
		clientID     str           -- client ID given at application registration
		clientSecret str           -- client secret given at application registration
		grantType    str           -- oauth specific grant_type value (i.e.: authorization_code)
		code         str           -- authorization code obtained from the generated auth link
		redirectURI  str           -- URL to be redirected to after authorization

		Exceptions:
		SDKInvalidArgException if provided clientID param is not a string
		SDKInvalidArgException if provided clientSecret param is not a string
		SDKInvalidArgException if provided grantType param is not a string
		SDKInvalidArgException if provided code param is not a string
		SDKInvalidArgException if provided redirectURI param is not a string

		Returns:
		str - returns obtained access token string

		"""

		if not isinstance(clientID, str):
			raise SDKInvalidArgException('`clientID` must be a string')
		elif not isinstance(clientSecret, str):
			raise SDKInvalidArgException('`clientSecret` must be a string')
		elif not isinstance(grantType, str):
			raise SDKInvalidArgException('`grantType` must be a string')
		elif not isinstance(code, str):
			raise SDKInvalidArgException('`code` must be a string')
		elif not isinstance(redirectURI, str):
			raise SDKInvalidArgException('`redirectURI` must be a string')

		params = {
			'grant_type'	: grantType,
			'client_id'		: clientID,
			'client_secret'	: clientSecret,
			'redirect_uri'	: redirectURI,
			'code'			: code
		}

		req = APIRequest(
			self._origin,
			'/login/oauth/access_token',
			'POST',
			{
				'base_uri'	: 'https://leantesting.com',
				'params'	: params
			}
		)

		resp = req.exec_()
		return resp['access_token']
Exemplo n.º 15
0
	def create(self, fields):
		super().create(fields)

		supports = {
			'name'            : True,
			'organization_id' : False
		}

		if self.enforce(fields, supports):
			req = APIRequest(self._origin, '/v1/projects', 'POST', {'params': fields})
			return Project(self._origin, req.exec_())
Exemplo n.º 16
0
    def create(self, fields):
        super().create(fields)

        supports = {'email': True, 'role_slug': True}

        if self.enforce(fields, supports):
            req = APIRequest(self._origin,
                             '/v1/projects/' + str(self._projectID) + '/users',
                             'POST', {'params': fields})

            return ProjectUser(self._origin, req.exec_())
Exemplo n.º 17
0
    def create(self, fields):
        super().create(fields)

        supports = {'number': True}

        if self.enforce(fields, supports):
            req = APIRequest(
                self._origin,
                '/v1/projects/' + str(self._projectID) + '/versions', 'POST',
                {'params': fields})

            return ProjectVersion(self._origin, req.exec_())
Exemplo n.º 18
0
    def exchangeAuthCode(self, clientID, clientSecret, grantType, code,
                         redirectURI):
        """

		Generates an access token string from the provided authorization code

		Keyword arguments:
		self         OAuth2Handler -- Self instance
		clientID     str           -- client ID given at application registration
		clientSecret str           -- client secret given at application registration
		grantType    str           -- oauth specific grant_type value (i.e.: authorization_code)
		code         str           -- authorization code obtained from the generated auth link
		redirectURI  str           -- URL to be redirected to after authorization

		Exceptions:
		SDKInvalidArgException if provided clientID param is not a string
		SDKInvalidArgException if provided clientSecret param is not a string
		SDKInvalidArgException if provided grantType param is not a string
		SDKInvalidArgException if provided code param is not a string
		SDKInvalidArgException if provided redirectURI param is not a string

		Returns:
		str - returns obtained access token string

		"""

        if not isinstance(clientID, str):
            raise SDKInvalidArgException('`clientID` must be a string')
        elif not isinstance(clientSecret, str):
            raise SDKInvalidArgException('`clientSecret` must be a string')
        elif not isinstance(grantType, str):
            raise SDKInvalidArgException('`grantType` must be a string')
        elif not isinstance(code, str):
            raise SDKInvalidArgException('`code` must be a string')
        elif not isinstance(redirectURI, str):
            raise SDKInvalidArgException('`redirectURI` must be a string')

        params = {
            'grant_type': grantType,
            'client_id': clientID,
            'client_secret': clientSecret,
            'redirect_uri': redirectURI,
            'code': code
        }

        req = APIRequest(self._origin, '/login/oauth/access_token', 'POST', {
            'base_uri': 'https://app.leantesting.com',
            'params': params
        })

        resp = req.exec_()
        return resp['access_token']
	def find(self, id_):
		super().find(id_)

		req = APIRequest(
			self._origin,
			'/v1/bugs/' + str(id_),
			'GET',
			{
				'params': {
					'include': 'steps,platform,attachments,comments,tags'
				}
			}
		)
		return Bug(self._origin, req.exec_())
Exemplo n.º 20
0
	def find(self, id_, params = None):
		super().find(id_)

		if params is None:
			params = {}

		req = APIRequest(
			self._origin,
			'/v1/projects/' + str(self._projectID) + '/sections/' + str(id_),
			'GET',
			{
				'params': params
			}
		)
		return ProjectSection(self._origin, req.exec_())
	def create(self, fields):
		super().create(fields)

		supports = {
			'number': True
		}

		if self.enforce(fields, supports):
			req = APIRequest(
				self._origin,
				'/v1/projects/' + str(self._projectID) + '/versions',
				'POST',
				{'params': fields}
			)

			return ProjectVersion(self._origin, req.exec_())
	def all(self, filters = None):
		if filters is None:
			filters = {}

		super().all(filters)

		request = APIRequest(self._origin, '/v1/platform/os/' + str(self._osID) + '/versions', 'GET')
		return EntityList(self._origin, request, PlatformOSVersion, filters)
	def all(self, filters = None):
		if filters is None:
			filters = {}

		super().all(filters)

		request = APIRequest(self._origin, '/v1/projects/' + str(self._projectID) + '/bug-priority-scheme', 'GET')
		return EntityList(self._origin, request, ProjectBugScheme, filters)
    def all(self, filters=None):
        if filters is None:
            filters = {}

        super().all(filters)

        request = APIRequest(self._origin, '/v1/platform/types', 'GET')
        return EntityList(self._origin, request, PlatformType, filters)
Exemplo n.º 25
0
	def all(self, filters = None):
		if filters is None:
			filters = {}

		super().all(filters)

		request = APIRequest(self._origin, '/v1/projects/' + str(self._projectID) + '/sections', 'GET')
		return EntityList(self._origin, request, ProjectSection, filters)
Exemplo n.º 26
0
    def all(self, filters=None):
        if filters is None:
            filters = {}

        super().all(filters)

        request = APIRequest(self._origin, '/v1/me/organizations', 'GET')
        return EntityList(self._origin, request, UserOrganization, filters)
Exemplo n.º 27
0
	def all(self, filters = None):
		if filters is None:
			filters = {}

		super().all(filters)

		request = APIRequest(self._origin, '/v1/projects/' + str(self._projectID) + '/integrations/webhooks', 'GET')
		return EntityList(self._origin, request, ProjectWebhook, filters)
Exemplo n.º 28
0
	def allArchived(self, filters = None):
		if filters is None:
			filters = {}

		super().all(filters)

		request = APIRequest(self._origin, '/v1/projects/archived', 'GET')
		return EntityList(self._origin, request, Project, filters)
Exemplo n.º 29
0
    def create(self, fields):
        super().create(fields)

        supports = {
            'name': True,
            'case_id': True,
            'version_id': True,
            'creator_id': False,
            'platform': False
        }

        if self.enforce(fields, supports):
            req = APIRequest(
                self._origin,
                '/v1/projects/' + str(self._projectID) + '/test-runs', 'POST',
                {'params': fields})

            return ProjectTestRun(self._origin, req.exec_())
	def create(self, fields):
		super().create(fields)

		supports = {
			'title'              : True,
			'status_id'          : True,
			'severity_id'        : True,
			'project_version'    : True,
			'project_version_id' : True,
			'project_section_id' : False,
			'type_id'            : False,
			'reproducibility_id' : False,
			'assigned_user_id'   : False,
			'description'        : False,
			'expected_results'   : False,
			'steps'              : False,
			'platform'           : False
			# 'device_model'       : False,
			# 'device_model_id'    : False,
			# 'os'                 : False,
			# 'os_version'         : False,
			# 'os_version_id'      : False,
			# 'browser_version_id' : False
		}

		if 'project_version_id' in fields.keys():
			supports['project_version'] = False
		elif 'project_version' in fields.keys():
			supports['project_version_id'] = False

		if self.enforce(fields, supports):
			initFields = {'include': 'steps,platform'}
			initFields.update(fields)
			fields = initFields

			req = APIRequest(
				self._origin,
				'/v1/projects/' + str(self._projectID) + '/bugs',
				'POST',
				{'params': fields}
			)

			return Bug(self._origin, req.exec_())
Exemplo n.º 31
0
    def all(self, filters=None):
        if filters is None:
            filters = {}

        super().all(filters)

        request = APIRequest(self._origin,
                             '/v1/bugs/' + str(self._bugID) + '/comments',
                             'GET')
        return EntityList(self._origin, request, BugComment, filters)
    def create(self, fields):
        super().create(fields)

        supports = {
            'title': True,
            'status_id': True,
            'severity_id': True,
            'project_version': True,
            'project_version_id': True,
            'project_section_id': False,
            'type_id': False,
            'reproducibility_id': False,
            'priority_id': False,
            'assigned_user_id': False,
            'description': False,
            'expected_results': False,
            'steps': False,
            'platform': False
            # 'device_model'       : False,
            # 'device_model_id'    : False,
            # 'os'                 : False,
            # 'os_version'         : False,
            # 'os_version_id'      : False,
            # 'browser_version_id' : False
        }

        if 'project_version_id' in fields.keys():
            supports['project_version'] = False
        elif 'project_version' in fields.keys():
            supports['project_version_id'] = False

        if self.enforce(fields, supports):
            initFields = {'include': 'steps,platform'}
            initFields.update(fields)
            fields = initFields

            req = APIRequest(self._origin,
                             '/v1/projects/' + str(self._projectID) + '/bugs',
                             'POST', {'params': fields})

            return Bug(self._origin, req.exec_())
    def all(self, filters=None):
        if filters is None:
            filters = {}

        super().all(filters)

        initFilters = {'include': 'versions'}
        initFilters.update(filters)
        filters = initFilters

        request = APIRequest(self._origin, '/v1/platform/browsers', 'GET')
        return EntityList(self._origin, request, PlatformBrowser, filters)
    def create(self, fields):
        super().create(fields)

        supports = {
            "title": True,
            "status_id": True,
            "severity_id": True,
            "project_version": True,
            "project_version_id": True,
            "project_section_id": False,
            "type_id": False,
            "reproducibility_id": False,
            "priority_id": False,
            "assigned_user_id": False,
            "description": False,
            "expected_results": False,
            "steps": False,
            "platform": False
            # 'device_model'       : False,
            # 'device_model_id'    : False,
            # 'os'                 : False,
            # 'os_version'         : False,
            # 'os_version_id'      : False,
            # 'browser_version_id' : False
        }

        if "project_version_id" in fields.keys():
            supports["project_version"] = False
        elif "project_version" in fields.keys():
            supports["project_version_id"] = False

        if self.enforce(fields, supports):
            initFields = {"include": "steps,platform"}
            initFields.update(fields)
            fields = initFields

            req = APIRequest(self._origin, "/v1/projects/" + str(self._projectID) + "/bugs", "POST", {"params": fields})

            return Bug(self._origin, req.exec_())
    def all(self, filters=None):
        if filters is None:
            filters = {}

        super().all(filters)

        initFilters = {'include': 'steps,platform,attachments,comments,tags'}
        initFilters.update(filters)
        filters = initFilters

        request = APIRequest(self._origin,
                             '/v1/projects/' + str(self._projectID) + '/bugs',
                             'GET')
        return EntityList(self._origin, request, Bug, filters)
Exemplo n.º 36
0
    def delete(self, id_):
        super().delete(id_)

        req = APIRequest(self._origin, '/v1/bugs/' + str(id_), 'DELETE')
        return req.exec_()
	def testAPIRequestBadJSONResponse(self):
		req = APIRequest(Client(), '/any/method', 'GET')
		req.call = MagicMock(return_value = {'data' : '{xxxxxxxxx', 'status' : 200})

		self.assertRaisesRegex(SDKBadJSONResponseException, '{xxxxxxxxx', req.exec_)
	def find(self, id_):
		super().find(id_)

		req = APIRequest(self._origin, '/v1/attachments/' + str(id_), 'GET')
		return BugAttachment(self._origin, req.exec_())
	def delete(self, id_):
		super().delete(id_)

		req = APIRequest(self._origin, '/v1/attachments/' + str(id_), 'DELETE')
		return req.exec_()
	def testAPIRequestExpectedStatus(self):
		req = APIRequest(Client(), '/any/method', 'GET')
		req.call = MagicMock(return_value = {'data' : '{"X": "X"}', 'status' : 200})
		req.exec_()

		req = APIRequest(Client(), '/any/method', 'POST')
		req.call = MagicMock(return_value = {'data' : '{"X": "X"}', 'status' : 200})
		req.exec_()

		req = APIRequest(Client(), '/any/method', 'PUT')
		req.call = MagicMock(return_value = {'data' : '{"X": "X"}', 'status' : 200})
		req.exec_()

		req = APIRequest(Client(), '/any/method', 'DELETE')
		req.call = MagicMock(return_value = {'data' : '1', 'status' : 204})
		req.exec_()
	def testAPIRequestUnexpectedStatusPUT(self):
		req = APIRequest(Client(), '/any/method', 'PUT')
		req.call = MagicMock(return_value = {'data' : 'XXXyyy', 'status' : 204})
		self.assertRaisesRegex(SDKErrorResponseException, 'XXXyyy', req.exec_)
	def testAPIRequestEmptyRespGET(self):
		req = APIRequest(Client(), '/any/method', 'GET')
		req.call = MagicMock(return_value = {'data' : '{}', 'status' : 200})
		self.assertRaisesRegex(SDKUnexpectedResponseException, 'Empty', req.exec_)
Exemplo n.º 43
0
	def find(self, id_):
		super().find(id_)

		req = APIRequest(self._origin, '/v1/me/organizations/' + str(id_), 'GET')
		return UserOrganization(self._origin, req.exec_())
	def find(self, id_):
		super().find(id_)

		req = APIRequest(self._origin, '/v1/projects/' + str(id_), 'GET')
		return Project(self._origin, req.exec_())
    def find(self, id_):
        super().find(id_)

        req = APIRequest(self._origin, "/v1/platform/devices/" + str(id_), "GET")
        return PlatformDevice(self._origin, req.exec_())
    def testAPIRequestBadJSONResponse(self):
        req = APIRequest(PyClient(), "/any/method", "GET")
        req.call = MagicMock(return_value={"data": "{xxxxxxxxx", "status": 200})

        self.assertRaisesRegex(SDKBadJSONResponseException, "{xxxxxxxxx", req.exec_)
    def testAPIRequestExpectedStatus(self):
        req = APIRequest(PyClient(), "/any/method", "GET")
        req.call = MagicMock(return_value={"data": '{"X": "X"}', "status": 200})
        req.exec_()

        req = APIRequest(PyClient(), "/any/method", "POST")
        req.call = MagicMock(return_value={"data": '{"X": "X"}', "status": 200})
        req.exec_()

        req = APIRequest(PyClient(), "/any/method", "PUT")
        req.call = MagicMock(return_value={"data": '{"X": "X"}', "status": 200})
        req.exec_()

        req = APIRequest(PyClient(), "/any/method", "DELETE")
        req.call = MagicMock(return_value={"data": "1", "status": 204})
        req.exec_()
 def testAPIRequestEmptyRespPUT(self):
     req = APIRequest(PyClient(), "/any/method", "PUT")
     req.call = MagicMock(return_value={"data": "{}", "status": 200})
     self.assertRaisesRegex(SDKUnexpectedResponseException, "Empty", req.exec_)
	def find(self, id_):
		super().find(id_)

		req = APIRequest(self._origin, '/v1/platform/types/' + str(id_), 'GET')
		return PlatformType(self._origin, req.exec_())
 def testAPIRequestUnexpectedStatusPUT(self):
     req = APIRequest(PyClient(), "/any/method", "PUT")
     req.call = MagicMock(return_value={"data": "XXXyyy", "status": 204})
     self.assertRaisesRegex(SDKErrorResponseException, "XXXyyy", req.exec_)
	def find(self, id_):
		super().find(id_)

		req = APIRequest(self._origin, '/v1/platform/browsers/' + str(id_), 'GET', {'params': {'include': 'versions'}})
		return PlatformBrowser(self._origin, req.exec_())