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
Exemple #2
0
class ProjectPackageDataTests (unittest.TestCase):
    def setUp (self):
        self.project = Project(basedir="/imaginary", name="Unittest")
    
    def test_should_raise_exception_when_package_name_not_given (self):
        self.assertRaises(ValueError, self.project.include_file, None, "spam")
        
    def test_should_raise_exception_when_filename_not_given (self):
        self.assertRaises(ValueError, self.project.include_file, "my_package", None)

    def test_should_raise_exception_when_package_name_is_empty_string (self):
        self.assertRaises(ValueError, self.project.include_file, "    \n", "spam")
        
    def test_should_raise_exception_when_filename_is_empty_string (self):
        self.assertRaises(ValueError, self.project.include_file, "eggs", "\t    \n")
        
    def test_should_package_data_dictionary_is_empty (self):
        self.assertEquals({}, self.project.package_data)
        
    def test_should_add_filename_to_list_of_included_files_for_package_spam (self):
        self.project.include_file("spam", "eggs")
        
        self.assertEquals({"spam": ["eggs"]}, self.project.package_data)

    def test_should_add_two_filenames_to_list_of_included_files_for_package_spam (self):
        self.project.include_file("spam", "eggs")
        self.project.include_file("spam", "ham")
        
        self.assertEquals({"spam": ["eggs", "ham"]}, self.project.package_data)
        
    def test_should_add_two_filenames_to_list_of_included_files_for_two_different_packages (self):
        self.project.include_file("spam", "eggs")
        self.project.include_file("monty", "ham")
        
        self.assertEquals({"monty": ["ham"], "spam": ["eggs"]}, self.project.package_data)

    def test_should_add_two_filenames_to_list_of_included_files_and_to_manifest (self):
        self.project.include_file("spam", "eggs")
        self.project.include_file("monty", "ham")
        
        self.assertEquals({"monty": ["ham"], "spam": ["eggs"]}, self.project.package_data)
        self.assertEquals(["spam/eggs", "monty/ham"], self.project.manifest_included_files)
class BuildPackageDataStringTest(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.project = Project('.')

    def test_should_return_empty_package_data_string_when_no_files_to_include_given(self):
        self.assertEqual('', build_package_data_string(self.project))

    def test_should_return_package_data_string_when_including_file(self):
        self.project.include_file("spam", "egg")

        self.assertEqual("package_data = {'spam': ['egg']},", build_package_data_string(self.project))

    def test_should_return_package_data_string_when_including_three_files(self):
        self.project.include_file("spam", "egg")
        self.project.include_file("ham", "eggs")
        self.project.include_file("monty", "python")

        self.assertEqual("package_data = {'ham': ['eggs'], 'monty': ['python'], "\
                         "'spam': ['egg']},", build_package_data_string(self.project))

    def test_should_return_package_data_string_with_keys_in_alphabetical_order(self):
        self.project.include_file("b", "beta")
        self.project.include_file("m", "Mu")
        self.project.include_file("e", "epsilon")
        self.project.include_file("k", "Kappa")
        self.project.include_file("p", "psi")
        self.project.include_file("z", "Zeta")
        self.project.include_file("i", "Iota")
        self.project.include_file("a", "alpha")
        self.project.include_file("d", "delta")
        self.project.include_file("t", "theta")
        self.project.include_file("l", "lambda")
        self.project.include_file("x", "chi")

        self.assertEqual("package_data = {'a': ['alpha'], 'b': ['beta'], 'd': ['delta'], "\
                         "'e': ['epsilon'], 'i': ['Iota'], 'k': ['Kappa'], 'l': ['lambda'], "\
                         "'m': ['Mu'], 'p': ['psi'], 't': ['theta'], 'x': ['chi'], "\
                         "'z': ['Zeta']},", build_package_data_string(self.project))