12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- from __future__ import absolute_import
- from ondemand.service import find_repetitions
- from ondemand.service import cloud_download
- import unittest
- import time
- class TestGeneral(unittest.TestCase):
- def test_find_repetitions(self):
- found = find_repetitions([
- {'timestamp': 1519769650, 'confidence': 5},
- {'timestamp': 1519769655, 'confidence': 5},
- {'timestamp': 1519769660, 'confidence': 15},
- {'timestamp': 1519769665, 'confidence': 15},
- {'timestamp': 1519769670, 'confidence': 25},
- {'timestamp': 1519769675, 'confidence': 47},
- {'timestamp': 1519769680, 'confidence': 150},
- {'timestamp': 1519769685, 'confidence': 47},
- {'timestamp': 1519769690, 'confidence': 19},
- {'timestamp': 1519769695, 'confidence': 15},
- {'timestamp': 1519769700, 'confidence': 15},
- {'timestamp': 1519769705, 'confidence': 15},
- {'timestamp': 1519769710, 'confidence': 15},
- {'timestamp': 1519769720, 'confidence': 15},
- {'timestamp': 1519769725, 'confidence': 150},
- {'timestamp': 1519769730, 'confidence': 300},
- {'timestamp': 1519769735, 'confidence': 5},
- ])
- self.assertEquals(len(found), 2)
- self.assertEquals(found[0], 1519769670)
- self.assertEquals(found[1], 1519769725)
- def test_find_empty_repetitions(self):
- found = find_repetitions([])
- self.assertTrue(not found)
- def test_find_not_enough_data(self):
- found = find_repetitions([
- {'timestamp': 1519769650, 'confidence': 5},
- {'timestamp': 1519769655, 'confidence': 5},
- {'timestamp': 1519769660, 'confidence': 100},
- {'timestamp': 1519769665, 'confidence': 15},
- {'timestamp': 1519769670, 'confidence': 25}
- ])
- self.assertTrue(not found)
- def test_cloud_download(self):
- filename, md5hash = cloud_download(ad_key='-L6EoklO90painUCd7df')
- print(filename, md5hash)
- pass
- if __name__ == '__main__':
- unittest.main()
|