예제 #1
0
파일: tests.py 프로젝트: lakiw/cripts
 def testSourceDataQuery(self):
     objs = TestSourceObject
     # User does not have source, should not return results
     resp = handlers.data_query(objs, self.user.username)
     self.assertEqual(resp['count'], 0)
     self.assertEqual(resp['result'], 'OK')
     self.assertEqual(resp['cripts_type'], 'TestSourceBase')
     self.assertEqual(resp['msg'], '')
     self.assertTrue(isinstance(resp['data'], CriptsQuerySet))
     # Add source for user and query again
     data = {
         'username': self.user.username,
         'first_name': self.user.first_name,
         'last_name': self.user.last_name,
         'email': self.user.email,
         'role': self.user.role,
         'sources': [
             TSRC,
         ],
         'secret': '',
         'organization': TSRC,
         'subscriptions': [],
         'totp': False,
     }
     handlers.modify_source_access(self.user.username, data)
     resp = handlers.data_query(objs, self.user.username)
     # Now we should get one result, but not the UnknownSource object
     self.assertEqual(resp['count'], 1)
     self.assertEqual(resp['result'], 'OK')
     self.assertEqual(resp['cripts_type'], 'TestSourceBase')
     self.assertEqual(resp['msg'], '')
     self.assertEqual(resp['data'][0].name, TOBJS_NAME)
     self.assertEqual(resp['data'][0].value, TOBJS_VALUE)
     self.assertEqual(resp['data'][0]._meta['cripts_type'],
                      "TestSourceBase")
예제 #2
0
파일: tests.py 프로젝트: lakiw/cripts
 def testSourceDataQuery(self):
     objs = TestSourceObject
     # User does not have source, should not return results
     resp = handlers.data_query(objs, self.user.username)
     self.assertEqual(resp['count'], 0)
     self.assertEqual(resp['result'], 'OK')
     self.assertEqual(resp['cripts_type'], 'TestSourceBase')
     self.assertEqual(resp['msg'], '')
     self.assertTrue(isinstance(resp['data'], CriptsQuerySet))
     # Add source for user and query again
     data = {'username': self.user.username,
             'first_name': self.user.first_name,
             'last_name': self.user.last_name,
             'email': self.user.email,
             'role': self.user.role,
             'sources': [TSRC, ],
             'secret': '',
             'organization': TSRC,
             'subscriptions': [],
             'totp': False,
             }
     handlers.modify_source_access(self.user.username, data)
     resp = handlers.data_query(objs, self.user.username)
     # Now we should get one result, but not the UnknownSource object
     self.assertEqual(resp['count'], 1)
     self.assertEqual(resp['result'], 'OK')
     self.assertEqual(resp['cripts_type'], 'TestSourceBase')
     self.assertEqual(resp['msg'], '')
     self.assertEqual(resp['data'][0].name, TOBJS_NAME)
     self.assertEqual(resp['data'][0].value, TOBJS_VALUE)
     self.assertEqual(resp['data'][0]._meta['cripts_type'], "TestSourceBase")
예제 #3
0
파일: tests.py 프로젝트: lakiw/cripts
 def testSourceCSVQuery(self):
     obj = TestSourceObject
     fields = "status,name,source,modified,value"
     data = {
         'username': self.user.username,
         'first_name': self.user.first_name,
         'last_name': self.user.last_name,
         'email': self.user.email,
         'role': self.user.role,
         'sources': [
             TSRC,
         ],
         'organization': TSRC,
         'secret': '',
         'subscriptions': [],
         'totp': False,
     }
     handlers.modify_source_access(self.user.username, data)
     resp = handlers.csv_query(obj,
                               self.user.username,
                               fields=fields.split(','))
     lines = resp.splitlines()
     item = lines[1].split(',')
     self.assertEqual(item[0], "New")
     self.assertEqual(item[1], TOBJS_NAME)
     self.assertEqual(item[2], TSRC)
     self.assertEqual(item[4], TOBJS_VALUE)
     self.assertEqual(lines[0], fields)
예제 #4
0
파일: tests.py 프로젝트: lakiw/cripts
 def testSourceCSVQuery(self):
     obj = TestSourceObject
     fields = "status,name,source,modified,value"
     data = {'username': self.user.username,
             'first_name': self.user.first_name,
             'last_name': self.user.last_name,
             'email': self.user.email,
             'role': self.user.role,
             'sources': [TSRC, ],
             'organization': TSRC,
             'secret': '',
             'subscriptions': [],
             'totp': False,
             }
     handlers.modify_source_access(self.user.username, data)
     resp = handlers.csv_query(obj,
                               self.user.username,
                               fields=fields.split(',')
                               )
     lines = resp.splitlines()
     item = lines[1].split(',')
     self.assertEqual(item[0], "New")
     self.assertEqual(item[1], TOBJS_NAME)
     self.assertEqual(item[2], TSRC)
     self.assertEqual(item[4], TOBJS_VALUE)
     self.assertEqual(lines[0], fields)