def add_all_nodes_from_dir(self, path): path = os.path.abspath(path) for path in walk_directory(path): node = Node(path) node.update_info(self) self.add_or_update_node(node) self.update_dir_hashes()
os.remove(DB_NAME) ds = Datastore(DB_NAME) ds.clear() print 'Can a Node be added to the Datastore and increase the row count?' node = Node('testdata/hello.txt') ds.add_or_update_node(node) assert(ds.num_items() == 1) print 'PASSED\n' print 'Does a file Node generate an expected hash?' assert(generate_hash(node) == '60fde9c2310b0d4cad4dab8d126b04387efba289') print 'PASSED\n' print 'If we run the Node\'s update_info() method do we see valid attributes set on the Node?' node.update_info(ds) assert(node.hash == '60fde9c2310b0d4cad4dab8d126b04387efba289') assert(node.bytes == 14) assert(node.type == 'f') assert(node.permissions > 0) assert(len(node.created) == 19) assert(len(node.modified) == 19) assert(len(node.last_seen) == 19) print 'PASSED\n' print 'Can the Datastore add all the Nodes of a given directory?' ds.add_all_nodes_from_dir('testdata') assert(ds.num_items() == 9) print 'PASSED\n' print 'Can we get back Node info that should have been added automatically?'