Пример #1
0
 def setUp(self):
     self.logger = logging.getLogger(__name__)
     self.new_tr = Trace(fObjt='requirement',
                         fName='Dataset policy',
                         tObjt='vulnerability',
                         tName='Certificate ubiquity')
     self.new_tr_dict = {'session_id': 'test', 'object': self.new_tr}
Пример #2
0
    def test_concept_map_model(self):
        url = '/api/requirements?environment=%s' % quote('Psychosis')
        reqBody1 = self.new_requirement_dict
        reqBody1['object'].theLabel = '1'
        reqBody1['object'].theName = 'OneRequirement'
        reqBody1['object'].theDescription = 'OneRequirement description'
        reqBody1['object'].attrs['asset'] = ''
        rv = self.app.post(url,
                           content_type='application/json',
                           data=jsonpickle.encode(reqBody1))
        if (sys.version_info > (3, )):
            responseData = rv.data.decode('utf-8')
        else:
            responseData = rv.data
        json_resp = jsonpickle.decode(responseData)
        self.assertIsNotNone(json_resp, 'No results after deserialization')

        reqBody2 = self.new_requirement_dict
        reqBody2['object'].theLabel = '2'
        reqBody2['object'].theName = 'AnotherRequirement'
        reqBody2['object'].theDescription = 'AnotherRequirement description'
        reqBody2['object'].attrs['asset'] = ''
        rv = self.app.post(url,
                           content_type='application/json',
                           data=jsonpickle.encode(reqBody2))
        if (sys.version_info > (3, )):
            responseData = rv.data.decode('utf-8')
        else:
            responseData = rv.data
        json_resp = jsonpickle.decode(responseData)
        self.assertIsNotNone(json_resp, 'No results after deserialization')

        aTrace = Trace(fObjt='requirement',
                       fName='OneRequirement',
                       tObjt='requirement',
                       tName='AnotherRequirement')
        traceDict = {'session_id': 'test', 'object': aTrace}
        rv = self.app.post('/api/traces',
                           content_type='application/json',
                           data=jsonpickle.encode(traceDict))

        url = '/api/requirements/model/environment/Psychosis/requirement/all?session_id=test'
        method = 'test_concept_map_model'
        self.logger.info('[%s] URL: %s', method, url)
        rv = self.app.get(url, content_type='application/json')
        if (sys.version_info > (3, )):
            responseData = rv.data.decode('utf-8')
        else:
            responseData = rv.data
        self.logger.debug('[%s] Response data: %s', method, responseData)
        self.assertIsNotNone(responseData, 'No results after deserialization')
        self.assertEqual(responseData.find('svg'), 1)
Пример #3
0
    def test_get_usecase_requirements(self):
        new_tr = Trace(fObjt='requirement',
                       fName='Dataset policy',
                       tObjt='usecase',
                       tName='Test use case')
        new_tr_dict = {'session_id': 'test', 'object': new_tr}
        rv = self.app.post('/api/traces',
                           content_type='application/json',
                           data=jsonpickle.encode(new_tr_dict))

        method = 'test_get_requirements_by_usecase_name'
        url = '/api/usecases/name/%s/requirements?session_id=test' % quote(
            self.existing_usecase_name)
        rv = self.app.get(url)
        self.assertIsNotNone(rv.data, 'No response')
        self.logger.debug('[%s] Response data: %s', method, rv.data)
        reqs = jsonpickle.decode(rv.data)
        self.assertIsNotNone(reqs, 'No results after deserialization')
        self.assertEqual(new_tr.theFromName, reqs[0])