Beispiel #1
0
 def test002_files_raise_h_type_None(self, m_process_error):
     self.request.query['hash'] = "something"
     api_search.files(self.db)
     self.assertTrue(m_process_error.called)
     self.assertIsInstance(m_process_error.call_args[0][0], ValueError)
     self.assertEqual(str(m_process_error.call_args[0][0]),
                      "Hash not supported")
Beispiel #2
0
 def test003_files_by_name(self, m_FileWeb):
     name = "something"
     self.request.query['name'] = name
     api_search.files(self.db)
     m_FileWeb.query_find_by_name.assert_called_once_with(name,
                                                          None,
                                                          self.db)
Beispiel #3
0
 def test002_files_raise_h_type_None(self, m_process_error):
     self.request.query['hash'] = "something"
     api_search.files(self.db)
     self.assertTrue(m_process_error.called)
     self.assertIsInstance(m_process_error.call_args[0][0], ValueError)
     self.assertEqual(str(m_process_error.call_args[0][0]),
                      "Hash not supported")
Beispiel #4
0
 def test006_files_by_sha256(self, m_FileWeb):
     h = hashlib.md5()
     h.update("something")
     hash_val = h.hexdigest()
     self.request.query['hash'] = hash_val
     api_search.files(self.db)
     m_FileWeb.query_find_by_hash.assert_called_once_with(
         "md5", hash_val, None, self.db)
Beispiel #5
0
 def test001_files_raise_none_None(self, m_process_error):
     self.request.query['name'] = "whatever"
     self.request.query.hash = "something"
     api_search.files(self.db)
     self.assertTrue(m_process_error.called)
     self.assertIsInstance(m_process_error.call_args[0][0], ValueError)
     self.assertEqual(str(m_process_error.call_args[0][0]),
                      "Can't find using both name and hash")
Beispiel #6
0
 def test001_files_raise_none_None(self, m_process_error):
     self.request.query['name'] = "whatever"
     self.request.query.hash = "something"
     api_search.files(self.db)
     self.assertTrue(m_process_error.called)
     self.assertIsInstance(m_process_error.call_args[0][0], ValueError)
     self.assertEqual(str(m_process_error.call_args[0][0]),
                      "Can't find using both name and hash")
Beispiel #7
0
 def test008_files_offset_limit(self, m_FileWeb):
     offset = randint(1000, 2000)
     limit = randint(0, 1000)
     self.request.query['offset'] = offset
     self.request.query['limit'] = limit
     api_search.files(self.db)
     m_limit = m_FileWeb.query_find_by_name().limit
     m_limit.assert_called_once_with(limit)
     m_limit().offset.assert_called_once_with(offset)
Beispiel #8
0
 def test008_files_offset_limit(self, m_FileWeb):
     offset = randint(1000, 2000)
     limit = randint(0, 1000)
     self.request.query['offset'] = offset
     self.request.query['limit'] = limit
     api_search.files(self.db)
     m_limit = m_FileWeb.query_find_by_name().limit
     m_limit.assert_called_once_with(limit)
     m_limit().offset.assert_called_once_with(offset)
Beispiel #9
0
 def test006_files_by_sha256(self, m_FileWeb):
     h = hashlib.md5()
     h.update("something")
     hash_val = h.hexdigest()
     self.request.query['hash'] = hash_val
     api_search.files(self.db)
     m_FileWeb.query_find_by_hash.assert_called_once_with("md5",
                                                          hash_val,
                                                          None,
                                                          self.db)
Beispiel #10
0
 def test007_files_all(self, m_FileWeb):
     api_search.files(self.db)
     m_FileWeb.query_find_by_name.assert_called_once_with("", None, self.db)
Beispiel #11
0
 def test003_files_by_name(self, m_FileWeb):
     name = "something"
     self.request.query['name'] = name
     api_search.files(self.db)
     m_FileWeb.query_find_by_name.assert_called_once_with(
         name, None, self.db)
Beispiel #12
0
 def test007_files_all(self, m_FileWeb):
     api_search.files(self.db)
     m_FileWeb.query_find_by_name.assert_called_once_with("",
                                                          None,
                                                          self.db)