Пример #1
0
 def test_hashfile_creation(self):
     # creation should not be run if hash file does not exist
     self.assertFalse(
         bootstrap.check_source_changes(TEST_FILENAME,
                                        hash_store_name=TEST_HASH_STORE))
     self.assertFalse(
         bootstrap.check_source_changes(TEST_FILENAME,
                                        hash_store_name=TEST_HASH_STORE))
Пример #2
0
 def test_source_change(self):
     # source change False if no hash file provided
     self.assertFalse(bootstrap.check_source_changes(TEST_FILENAME))
     self.assertFalse(bootstrap.check_source_changes(TEST_FILENAME))
     # source change True if no hash file provided but
     # no_hast_store_default set to True
     self.assertTrue(
         bootstrap.check_source_changes(TEST_FILENAME,
                                        no_hash_store_default=True))
Пример #3
0
 def test_hashfile_creation_with_option(self):
     # creation should be run if hash file does exist
     self.assertTrue(
         bootstrap.check_source_changes(TEST_FILENAME,
                                        hash_store_name=TEST_HASH_STORE,
                                        key_not_exist_default=True))
     self.assertFalse(
         bootstrap.check_source_changes(TEST_FILENAME,
                                        hash_store_name=TEST_HASH_STORE,
                                        key_not_exist_default=True))
Пример #4
0
 def test_list(self):
     test_list = [TEST_FILENAME, ANOTHER_TEST_FILENAME]
     self.assertFalse(
         bootstrap.check_source_changes(test_list,
                                        hash_store_name=TEST_HASH_STORE))
     self.assertFalse(
         bootstrap.check_source_changes(test_list,
                                        hash_store_name=TEST_HASH_STORE))
     sleep(1)
     with open(ANOTHER_TEST_FILENAME, 'w') as fil:
         fil.write('hello world')
     self.assertTrue(
         bootstrap.check_source_changes(test_list,
                                        hash_store_name=TEST_HASH_STORE))
Пример #5
0
 def test_regular_file_change(self):
     self.assertFalse(
         bootstrap.check_source_changes(TEST_FILENAME,
                                        hash_store_name=TEST_HASH_STORE))
     self.assertFalse(
         bootstrap.check_source_changes(TEST_FILENAME,
                                        hash_store_name=TEST_HASH_STORE))
     with open(TEST_FILENAME, 'a') as fil:
         fil.write('ha')
     self.assertTrue(
         bootstrap.check_source_changes(TEST_FILENAME,
                                        hash_store_name=TEST_HASH_STORE))
     self.assertFalse(
         bootstrap.check_source_changes(TEST_FILENAME,
                                        hash_store_name=TEST_HASH_STORE))
Пример #6
0
 def test_ignore_non_files(self):
     # if we decide to not track then we can also reload
     # non-trackable resources
     self.assertTrue(
         bootstrap.check_source_changes('https://google.com',
                                        no_hash_store_default=True))
     # if the source is untrackable we should not able to force
     # it to reload because the key is absent
     self.assertFalse(
         bootstrap.check_source_changes('https://google.com',
                                        hash_store_name=TEST_HASH_STORE,
                                        key_not_exist_default=True))
     self.assertFalse(
         bootstrap.check_source_changes('https://google.com',
                                        hash_store_name=TEST_HASH_STORE,
                                        key_not_exist_default=True))
Пример #7
0
 def test_shapefile_changes(self):
     try:
         os.remove(TEST_HASH_STORE)
     except FileNotFoundError:
         pass
     self.assertFalse(
         bootstrap.check_source_changes(TEST_SHAPEFILE,
                                        hash_store_name=TEST_HASH_STORE))
     self.assertFalse(
         bootstrap.check_source_changes(TEST_SHAPEFILE,
                                        hash_store_name=TEST_HASH_STORE))
     schema = {'geometry': 'Point', 'properties': {'test': 'str'}}
     args = TEST_SHAPEFILE, 'w', 'ESRI Shapefile', schema
     with fiona.open(TEST_SHAPEFILE) as collection:
         data = list(collection)
     with fiona.open(*args) as new_collection:
         for item in data:
             new_collection.write(item)
     self.assertTrue(
         bootstrap.check_source_changes(TEST_SHAPEFILE,
                                        hash_store_name=TEST_HASH_STORE))