def test_versioning(): directory = mkgittree(GIT_ROOT + ROOT_SVC) v1 = Discovery(Forge()).search(directory)[0].version assert v1.endswith(".git") with open(os.path.join(directory, "root.py"), "write") as fd: fd.write("blah") v2 = Discovery(Forge()).search(directory)[0].version assert v2.endswith(".sha") with open(os.path.join(directory, "root.py"), "write") as fd: fd.write("blahblah") v3 = Discovery(Forge()).search(directory)[0].version assert v3.endswith(".sha") assert v2 != v3
def test_discovery_nested(): directory = mkgittree(GIT_ROOT + NESTED_SVC) disco = Discovery(Forge()) found = disco.search(directory) assert [f.name for f in found] == ["nested"] svc = disco.services["nested"] assert set(svc.dockerfiles) == set(["Dockerfile"]) assert set(svc.files) == set([ ".gitignore", ".forgeignore", "service.yaml", "Dockerfile", "nested.py", "service.yaml", "blah.rootignore" ])
def test_discovery_root(): directory = mkgittree(GIT_ROOT + ROOT_SVC) disco = Discovery(Forge()) found = disco.search(directory) assert [f.name for f in found] == ["root"] svc = disco.services["root"] assert set(svc.dockerfiles) == set(["Dockerfile", "subdir/Dockerfile"]) assert set(svc.files) == set([ ".gitignore", ".forgeignore", "service.yaml", "Dockerfile", "root.py", "subdir/Dockerfile", "subdir/app.py" ])
def test_discovery_combined(): directory = mkgittree(GIT_ROOT + ROOT_SVC + NESTED_SVC) disco = Discovery(Forge()) found = disco.search(directory) assert [f.name for f in found] == ["root", "nested"] root = disco.services["root"] assert set(root.dockerfiles) == set(["Dockerfile", "subdir/Dockerfile"]) assert set(root.files) == set([ ".gitignore", ".forgeignore", "service.yaml", "Dockerfile", "root.py", "subdir/Dockerfile", "subdir/app.py" ]) nested = disco.services["nested"] assert set(nested.dockerfiles) == set(["Dockerfile"]) assert set(nested.files) == set([ ".gitignore", ".forgeignore", "service.yaml", "Dockerfile", "nested.py", "service.yaml" ]) assert root.version == nested.version
def test_nondirectory(): try: Discovery(Forge()).search(__file__) except TaskError, e: assert "not a directory" in str(e)
def test_nonexistent(): try: Discovery(Forge()).search("thisfileshouldreallynotexist") except TaskError, e: assert "no such directory" in str(e)