Пример #1
0
 def test_file_tag_twice(self):
     found = file_search(hash=self.file_sha256)
     self.assertNotEqual(len(found), 0)
     file_tag_add(self.file_sha256, self.taglist[0].id)
     (total, found) = file_search(hash=self.file_sha256)
     self.assertGreaterEqual(total, 1)
     with self.assertRaises(IrmaError):
         file_tag_add(self.file_sha256, self.taglist[0].id)
Пример #2
0
 def test_file_search_limit(self):
     (total, _) = file_search()
     (total, res) = file_search(limit=total)
     self.assertEqual(type(res), list)
     self.assertEqual(len(res), total)
     offset = total - total / 2
     limit = total / 2
     (_, res) = file_search(offset=offset, limit=limit)
     self.assertEqual(type(res), list)
     self.assertEqual(len(res), limit)
Пример #3
0
 def test_file_search_limit(self):
     (total, _) = file_search()
     if total > 10:
         offset = total - 10
         limit = 10
     else:
         offset = 0
         limit = total
     (_, res) = file_search(offset=offset, limit=limit)
     self.assertEqual(type(res), list)
     self.assertEqual(len(res), limit)
Пример #4
0
 def test_file_search_name(self):
     force = False
     probes = probe_list()
     scan_files(FILEPATHS, force, probes, blocking=True)
     for name in FILENAMES:
         data = file_search(name=name)
         self.assertEqual(type(data), tuple)
         (total, res) = file_search(name, limit=1)
         self.assertEqual(type(res), list)
         self.assertEqual(type(res[0]), IrmaResults)
         self.assertEqual(len(res), 1)
         self.assertEqual(type(total), int)
Пример #5
0
 def test_file_search_hash(self):
     force = False
     probes = probe_list()
     scan_files(FILEPATHS, force, probes, blocking=True)
     for hash in HASHES:
         (_, res) = file_search(hash=hash)
         self.assertTrue(len(res) > 0)
         self.assertEqual(type(res[0]), IrmaResults)
Пример #6
0
 def test_file_search_tag(self):
     self.assertEqual(len(self.get_result.file_infos.tags), 0)
     tagged = []
     for tag in self.taglist:
         file_tag_add(self.file_sha256, tag.id)
         tagged.append(tag.id)
         (total, found) = file_search(name=self.file_name, tags=tagged)
         self.assertGreater(total, 0)
         self.assertIn(self.file_name, [x.name for x in found])
Пример #7
0
 def test_utf8(self):
     scan = self._make_scan(UTF8_PATHS)
     for get_result in scan.results:
         res = scan_proberesults(get_result.result_id)
         self.assertIn(res.name, UTF8_SAMPLES)
     for filename in UTF8_SAMPLES:
         (_, res) = file_search(filename, limit=1)
         self.assertEqual(type(res), list)
         self.assertEqual(len(res), 1)
         self.assertEqual(res[0].name, filename)
Пример #8
0
 def test_utf8(self):
     force = False
     scan = scan_files(UTF8_PATHS, force, blocking=True)
     for get_result in scan.results:
         res = scan_proberesults(get_result.result_id)
         self.assertIn(res.name, UTF8_SAMPLES)
     for filename in UTF8_SAMPLES:
         (_, res) = file_search(filename, limit=1)
         self.assertEqual(type(res), list)
         self.assertEqual(len(res), 1)
         self.assertEqual(res[0].name, filename)
Пример #9
0
 def test_file_search_not_existing_tag_and_name(self):
     invalid_tagid = max([x.id for x in self.taglist]) + 1
     with self.assertRaises(IrmaError):
         file_search(name=self.file_name, tags=[invalid_tagid])
Пример #10
0
 def test_file_search_hash_name(self):
     with self.assertRaises(IrmaError):
         file_search(name="name", hash="hash")