Exemplo n.º 1
0
 def test_list_from_tuples(self):
     tmp_dir = self._make_test_data()
     l = FCL([
         (self._FILE_1, self._CHK_1),
         (self._FILE_2, self._CHK_2),
     ])
     self.assertEqual(
         l, FCL.from_files([self._FILE_1, self._FILE_2], root_dir=tmp_dir))
Exemplo n.º 2
0
  def test_to_json(self):
    expected = '''\
[
  [
    "a.txt", 
    "7bf1c5c4153ecb5364b0c7fcb2e767fadc6880e0c2620b69df56b6bb5429448d"
  ], 
  [
    "b.txt", 
    "429340c7abf63fe50eb3076d3f1d5d996f3b4ee3067734ae8832129af244653c"
  ]
]'''
    self.assertEqualIgnoreWhiteSpace( expected, FCL.from_files([ 'a.txt', 'b.txt' ], root_dir = self.data_dir()).to_json() )
Exemplo n.º 3
0
  def test_load_checksums_file(self):
    content = '''\
[
  [
    "a.txt", 
    "7bf1c5c4153ecb5364b0c7fcb2e767fadc6880e0c2620b69df56b6bb5429448d"
  ], 
  [
    "b.txt", 
    "429340c7abf63fe50eb3076d3f1d5d996f3b4ee3067734ae8832129af244653c"
  ]
]'''
    tmp_file = temp_file.make_temp_file(content = content)
    expected = FCL.from_files([ 'a.txt', 'b.txt' ], root_dir = self.data_dir())
    self.assertEqual( expected, FCL.load_checksums_file(tmp_file) )
Exemplo n.º 4
0
  def test_save_checksums_file(self):
    tmp_file = temp_file.make_temp_file()
    a = FCL.from_files([ 'a.txt', 'b.txt' ], root_dir = self.data_dir())
    a.save_checksums_file(tmp_file)
    expected = '''\
[
  [
    "a.txt", 
    "7bf1c5c4153ecb5364b0c7fcb2e767fadc6880e0c2620b69df56b6bb5429448d"
  ], 
  [
    "b.txt", 
    "429340c7abf63fe50eb3076d3f1d5d996f3b4ee3067734ae8832129af244653c"
  ]
]'''
    self.assertEqual( expected, file_util.read(tmp_file, codec = 'utf8') )
Exemplo n.º 5
0
    def test_save_checksums_file(self):
        tmp_dir = self._make_test_data()
        tmp_file = temp_file.make_temp_file()
        a = FCL.from_files([self._FILE_1, self._FILE_2], root_dir=tmp_dir)
        a.save_checksums_file(tmp_file)
        expected = '''\
[
  [
    "a.data", 
    "65ab12a8ff3263fbc257e5ddf0aa563c64573d0bab1f1115b9b107834cfa6971"
  ], 
  [
    "b.data", 
    "5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953"
  ]
]'''
        self.assertEqual(expected, file_util.read(tmp_file, codec='utf8'))
Exemplo n.º 6
0
    def test_to_json(self):
        tmp_dir = self._make_test_data()
        expected = '''\
[
  [
    "a.data", 
    "65ab12a8ff3263fbc257e5ddf0aa563c64573d0bab1f1115b9b107834cfa6971"
  ], 
  [
    "b.data", 
    "5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953"
  ]
]'''
        self.assertEqualIgnoreWhiteSpace(
            expected,
            FCL.from_files([self._FILE_1, self._FILE_2],
                           root_dir=tmp_dir).to_json())
Exemplo n.º 7
0
    def test_load_checksums_file(self):
        tmp_dir = self._make_test_data()
        content = '''\
[
  [
    "a.data", 
    "65ab12a8ff3263fbc257e5ddf0aa563c64573d0bab1f1115b9b107834cfa6971"
  ], 
  [
    "b.data", 
    "5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953"
  ]
]'''
        tmp_file = temp_file.make_temp_file(content=content)
        expected = FCL.from_files([self._FILE_1, self._FILE_2],
                                  root_dir=tmp_dir)
        self.assertEqual(expected, FCL.load_checksums_file(tmp_file))
Exemplo n.º 8
0
 def test_list_from_tuples(self):
   l = FCL([
     ( 'a.txt', self.A_CHK ),
     ( 'b.txt', self.B_CHK ),
   ])
   self.assertEqual( l, FCL.from_files([ 'a.txt', 'b.txt' ], root_dir = self.data_dir()))
Exemplo n.º 9
0
 def test_from_files(self):
   self.assertEqual( [
     ( 'a.txt', self.A_CHK ),
     ( 'b.txt', self.B_CHK ),
   ], FCL.from_files([ 'a.txt', 'b.txt' ], root_dir = self.data_dir()) )