def create_project():
    project = Project("/")
    project.build_depends_on("testingframework")
    project.depends_on("sometool")
    project.depends_on("pyassert", url="https://github.com/downloads/halimath/pyassert/pyassert-0.2.2.tar.gz")
    project.name = "Spam and Eggs"
    project.version = "1.2.3"
    project.summary = "This is a simple integration-test for distutils plugin."
    project.description = "As you might have guessed we have nothing to say here."
    project.authors = [Author("Udo Juettner", "*****@*****.**"), Author("Michael Gruber", "*****@*****.**")]
    project.license = "WTFPL"
    project.url = "http://github.com/pybuilder/pybuilder"

    def return_dummy_list():
        return ["spam", "eggs"]

    project.list_scripts = return_dummy_list
    project.list_packages = return_dummy_list

    project.set_property("distutils_classifiers", ["Development Status :: 5 - Beta", "Environment :: Console"])
    project.install_file("dir", "file1")
    project.install_file("dir", "file2")
    project.include_file("spam", "eggs")

    return project
Beispiel #2
0
class ProjectDataFilesTests (unittest.TestCase):
    def setUp (self):
        self.project = Project(basedir="/imaginary", name="Unittest")
     
    def test_should_return_empty_list_for_property_files_to_install (self):
        self.assertEquals([], self.project.files_to_install)
        
    def test_should_return_file_to_install (self):
        self.project.install_file("destination", "filename")
        
        self.assertEquals([("destination", ["filename"])], self.project.files_to_install)
        
    def test_should_raise_exception_when_no_destination_given (self):
        self.assertRaises(ValueError, self.project.install_file, None, "Hello world.")
    
    def test_should_raise_exception_when_no_filename_given (self):
        self.assertRaises(ValueError, self.project.install_file, "destination", None)
    
    def test_should_raise_exception_when_filename_empty (self):
        self.assertRaises(ValueError, self.project.install_file, "destination", "\t   \n")
    
    def test_should_return_files_to_install_into_same_destination (self):
        self.project.install_file("destination", "filename1")
        self.project.install_file("destination", "filename2")
        
        self.assertEquals([("destination", ["filename1", "filename2"])], self.project.files_to_install)
    
    def test_should_return_files_to_install_into_different_destinations (self):
        self.project.install_file("destination_a", "filename_a_1")
        self.project.install_file("destination_a", "filename_a_2")
        self.project.install_file("destination_b", "filename_b")
        
        self.assertEquals([("destination_a", ["filename_a_1", "filename_a_2"]),
                           ("destination_b", ["filename_b"])], self.project.files_to_install)
    
    def test_should_return_files_to_install_into_different_destinations_and_add_them_to_manifest (self):
        self.project.install_file("destination_a", "somepackage1/filename1")
        self.project.install_file("destination_a", "somepackage2/filename2")
        self.project.install_file("destination_b", "somepackage3/filename3")
        
        self.assertEquals([("destination_a", ["somepackage1/filename1", "somepackage2/filename2"]),
                           ("destination_b", ["somepackage3/filename3"])], self.project.files_to_install)
        self.assertEquals(["somepackage1/filename1", "somepackage2/filename2", "somepackage3/filename3"], self.project.manifest_included_files)
class BuildDataFilesStringTest(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.project = Project(".")

    def test_should_return_empty_data_files_string(self):
        self.assertEqual("", build_data_files_string(self.project))

    def test_should_return_data_files_string_including_several_files(self):
        self.project.install_file("bin", "activate")
        self.project.install_file("bin", "command-stub")
        self.project.install_file("bin", "rsync")
        self.project.install_file("bin", "ssh")

        self.assertEqual("data_files = [('bin', ['activate', 'command-stub', 'rsync', 'ssh'])],",\
            build_data_files_string(self.project))

    def test_should_return_data_files_string_with_files_to_be_installed_in_several_destinations(self):
        self.project.install_file("/usr/bin", "pyb")
        self.project.install_file("/etc", "pyb.cfg")
        self.project.install_file("data", "pyb.dat")
        self.project.install_file("data", "howto.txt")
        self.assertEqual("data_files = [('/usr/bin', ['pyb']), ('/etc', ['pyb.cfg']),"\
                         " ('data', ['pyb.dat', 'howto.txt'])],",\
            build_data_files_string(self.project))