예제 #1
0
 def test_files_offset_limit(self, m_FileExt):
     offset = randint(1000, 2000)
     limit = randint(0, 1000)
     api_files.list(offset=offset, limit=limit)
     m_FileExt.query_find_by_name().limit.assert_called_once_with(limit)
     m_offset = m_FileExt.query_find_by_name().limit().offset
     m_offset.assert_called_once_with(offset)
예제 #2
0
 def test_files_raise_none_None(self):
     name = "whatever"
     hash = "something"
     with self.assertRaises(ValueError) as context:
         api_files.list(name=name, hash=hash)
     self.assertEqual(str(context.exception),
                      "Can't find using both name and hash")
예제 #3
0
 def test_files_raise_none_None(self):
     name = "whatever"
     hash = "something"
     with self.assertRaises(ValueError) as context:
         api_files.list(name=name, hash=hash)
     self.assertEqual(str(context.exception),
                      "Can't find using both name and hash")
예제 #4
0
 def test_files_offset_limit(self, m_FileExt):
     offset = randint(1000, 2000)
     limit = randint(0, 1000)
     api_files.list(offset=offset, limit=limit)
     m_FileExt.query_find_by_name().limit.assert_called_once_with(limit)
     m_offset = m_FileExt.query_find_by_name().limit().offset
     m_offset.assert_called_once_with(offset)
예제 #5
0
 def test_files_by_sha256(self, m_FileExt):
     h = hashlib.md5()
     data = "something".encode("utf-8")
     h.update(data)
     hash_val = h.hexdigest()
     api_files.list(hash=hash_val)
     m_FileExt.query_find_by_hash.assert_called_once_with(
         "md5", hash_val, None, self.session)
예제 #6
0
 def test_files_by_sha256(self, m_FileExt):
     h = hashlib.md5()
     data = "something".encode("utf-8")
     h.update(data)
     hash_val = h.hexdigest()
     api_files.list(hash=hash_val)
     m_FileExt.query_find_by_hash.assert_called_once_with("md5",
                                                          hash_val,
                                                          None,
                                                          self.session)
예제 #7
0
 def test_files_by_tags(self, m_FileExt):
     tag_list = ["tag1", "tag2"]
     api_files.list(tags=tag_list)
     m_FileExt.query_find_by_name.assert_called_once_with(
         "", tag_list, self.session)
예제 #8
0
 def test_files_all(self, m_FileExt):
     api_files.list()
     m_FileExt.query_find_by_name.assert_called_once_with(
         "", None, self.session)
예제 #9
0
 def test_files_by_name(self, m_FileExt):
     name = "something"
     api_files.list(name=name)
     m_FileExt.query_find_by_name.assert_called_once_with(
         name, None, self.session)
예제 #10
0
 def test_files_raise_h_type_None(self):
     hash = "something"
     with self.assertRaises(ValueError) as context:
         api_files.list(hash=hash)
     self.assertEqual(str(context.exception), "Hash not supported")
예제 #11
0
 def test_files_by_tags(self, m_FileExt):
     tag_list = ["tag1", "tag2"]
     api_files.list(tags=tag_list)
     m_FileExt.query_find_by_name.assert_called_once_with("",
                                                          tag_list,
                                                          self.session)
예제 #12
0
 def test_files_all(self, m_FileExt):
     api_files.list()
     m_FileExt.query_find_by_name.assert_called_once_with("",
                                                          None,
                                                          self.session)
예제 #13
0
 def test_files_by_name(self, m_FileExt):
     name = "something"
     api_files.list(name=name)
     m_FileExt.query_find_by_name.assert_called_once_with(name,
                                                          None,
                                                          self.session)
예제 #14
0
 def test_files_raise_h_type_None(self):
     hash = "something"
     with self.assertRaises(ValueError) as context:
         api_files.list(hash=hash)
     self.assertEqual(str(context.exception),
                      "Hash not supported")