Пример #1
0
 def test_set_executable_no_options(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-e", "fooble"])
     prj = MockProject.instances[-1]
     assert prj.saved
     self.assertEqual(prj.default_executable.path, "fooble")
Пример #2
0
 def test_set_executable_and_main(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-m", "main.foo", "-e", "fooble"])
     prj = MockProject.instances[-1]
     self.assertEqual(prj.default_main_file, "main.foo")
     self.assertEqual(prj.default_executable.path, "fooble")
Пример #3
0
 def test_set_main_no_executable_registered_extension_should_set_executable(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-m", "file_with_registered_extension"])
     prj = MockProject.instances[-1]
     self.assertEqual(prj.default_main_file, "file_with_registered_extension")
     self.assertEqual(prj.default_executable.script_file, "file_with_registered_extension")
Пример #4
0
 def test_archive_option_set_to_true(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "--archive", "true"])
     prj = MockProject.instances[-1]
     self.assertIsInstance(prj.data_store, datastore.ArchivingFileSystemDataStore)
     self.assertEqual(prj.data_store.archive_store, os.path.abspath(".smt/archive"))
Пример #5
0
 def test_set_executable_and_main(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-m", "main.foo", "-e", "fooble"])
     prj = MockProject.instances[-1]
     self.assertEqual(prj.default_main_file, "main.foo")
     self.assertEqual(prj.default_executable.path, "fooble")
Пример #6
0
 def test_set_main_no_executable_unregistered_extension_should_set_executable_to_None(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-m", "main.foo"])
     prj = MockProject.instances[-1]
     self.assertEqual(prj.default_main_file, "main.foo")
     self.assertEqual(prj.default_executable, None)
Пример #7
0
 def test_set_main_no_executable_registered_extension_should_set_executable(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-m", "file_with_registered_extension"])
     prj = MockProject.instances[-1]
     self.assertEqual(prj.default_main_file, "file_with_registered_extension")
     self.assertEqual(prj.default_executable.script_file, "file_with_registered_extension")
Пример #8
0
 def test_set_executable_no_options(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-e", "fooble"])
     prj = MockProject.instances[-1]
     assert prj.saved
     self.assertEqual(prj.default_executable.path, "fooble")
Пример #9
0
 def test_archive_option_set_to_true(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "--archive", "true"])
     prj = MockProject.instances[-1]
     self.assertIsInstance(prj.data_store, datastore.ArchivingFileSystemDataStore)
     self.assertEqual(prj.data_store.archive_store, os.path.abspath(".smt/archive"))
Пример #10
0
 def test_set_main_no_executable_unregistered_extension_should_set_executable_to_None(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-m", "main.foo"])
     prj = MockProject.instances[-1]
     self.assertEqual(prj.default_main_file, "main.foo")
     self.assertEqual(prj.default_executable, None)
Пример #11
0
 def test_set_incompatible_executable_and_main(self):
     # not really sure what should happen here. Raise exception or just warning?
     # for now compatibility is not checked
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-m", "main.sli", "-e", "python"])
     prj = MockProject.instances[-1]
     self.assertEqual(prj.default_main_file, "main.sli")
     self.assertEqual(prj.default_executable.path, "python")
Пример #12
0
 def test_set_incompatible_executable_and_main(self):
     # not really sure what should happen here. Raise exception or just warning?
     # for now compatibility is not checked
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-m", "main.sli", "-e", "python"])
     prj = MockProject.instances[-1]
     self.assertEqual(prj.default_main_file, "main.sli")
     self.assertEqual(prj.default_executable.path, "python")
Пример #13
0
 def test_with_repository_option_should_perform_checkout(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "--repository", "/path/to/repos"])
     self.assertEqual(MockProject.instances[-1].default_repository.url,
                      "/path/to/repos")
     self.assert_(
         MockProject.instances[-1].default_repository._checkout_called,
         "/path/to/repos")
Пример #14
0
 def test_store_option_should_get_record_store(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init([
         "NewProject",
         "-s",
         "/path/to/store",
     ])
     prj = MockProject.instances[-1]
     self.assertEqual(prj.record_store.path, "/path/to/store")
Пример #15
0
 def test_archive_option_set_to_path(self):
     some_path = "./test_commands_archive_option"
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "--archive", some_path])
     prj = MockProject.instances[-1]
     self.assertIsInstance(prj.data_store, datastore.ArchivingFileSystemDataStore)
     self.assertEqual(prj.data_store.archive_store, os.path.abspath(some_path))
     if os.path.exists(some_path):
         os.rmdir(some_path)
Пример #16
0
 def test_archive_option_set_to_path(self):
     some_path = "./test_commands_archive_option"
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "--archive", some_path])
     prj = MockProject.instances[-1]
     self.assertIsInstance(prj.data_store, datastore.ArchivingFileSystemDataStore)
     self.assertEqual(prj.data_store.archive_store, os.path.abspath(some_path))
     if os.path.exists(some_path):
         os.rmdir(some_path)
Пример #17
0
import datetime

def inspectFolder(foldername, projectpath = '.', timestamp = datetime.datetime(2010, 1, 1, 11, 14, 40, 915039)):
    project = load_project(projectpath)
    logging.debug('Scan folder %s' %foldername)
    initialRoot = project.data_store.root
    project.data_store = datastore.FileSystemDataStore(foldername)
    record = project.new_record(
            main_file=sys.argv[0],
            parameters=foldername,
            executable=sumatra.programs.get_executable(sys.executable),
            reason='Scan folder %s' %foldername
        )
    record.output_data = record.datastore.find_new_data(timestamp)
    project.add_record(record)
    project.save()
    project.data_store = datastore.FileSystemDataStore(initialRoot)

if __name__ == '__main__':
    logging.basicConfig(level='INFO')
    projectpath = '.'
    try:
        project = load_project(projectpath)
    except IOError:
        logging.warning("Creating sumatra project")
        commands.init(['deduplication'])
        project = load_project(projectpath)
        print project.info()

    inspectFolder(sys.argv[1])
Пример #18
0
 def test_with_single_args__should_create_Project(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject"])
     self.assertEqual(MockProject.instances[-1].name, "NewProject")
Пример #19
0
 def test_with_repository_option_should_perform_checkout(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "--repository", "/path/to/repos"])
     self.assertEqual(MockProject.instances[-1].default_repository.url, "/path/to/repos")
     self.assert_(MockProject.instances[-1].default_repository._checkout_called, "/path/to/repos")
Пример #20
0
 def test_store_option_should_get_record_store(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject", "-s", "/path/to/store",])
     prj = MockProject.instances[-1]
     self.assertEqual(prj.record_store.path, "/path/to/store")
Пример #21
0
 def test_with_single_args__should_create_Project(self):
     commands.load_project = no_project
     commands.Project = MockProject
     commands.init(["NewProject"])
     self.assertEqual(MockProject.instances[-1].name, "NewProject")