def test_updating_existing_project(tmpfolder, caplog): # Given a project already exists, but was generated without # namespace, create_project(project="my-proj") assert tmpfolder.join("my-proj/src/my_proj").check() assert not tmpfolder.join("my-proj/src/my/ns").check() # when the project is updated with a namespace, create_project( project="my-proj", update=True, namespace="my.ns", extensions=[namespace.Namespace("namespace")], ) # then the package folder should be moved to a nested position, assert not tmpfolder.join("my-proj/src/my_proj").check() assert tmpfolder.join("my-proj/src/my/ns/my_proj").check() # and the user should see a warn expected_warnings = ( "A folder", "exists in the project directory", "a namespace option was passed", "Please make sure", ) log = caplog.text for text in expected_warnings: assert text in log
def test_create_project_with_empty_namespace(tmpfolder): for j, ns in enumerate(["", None, False]): # Given options with the namespace extension, opts = dict(project="my-proj{}".format(j), namespace=ns, extensions=[namespace.Namespace("namespace")]) # when the project is created, create_project(opts) # then plain structure should exist assert path_exists("my-proj{}/src/my_proj{}/__init__.py".format(j, j))
def test_create_project_with_namespace(tmpfolder): # Given options with the namespace extension, opts = dict(project="my-proj", namespace="ns.ns2", extensions=[namespace.Namespace('namespace')]) # when the project is created, create_project(opts) # then nested structure should exist assert path_exists("my-proj/src/ns/__init__.py") assert path_exists("my-proj/src/ns/ns2/__init__.py") assert path_exists("my-proj/src/ns/ns2/my_proj/__init__.py") # and plain structure should not exist assert not path_exists("my-proj/src/my_proj/__init__.py")