Exemple #1
0
def test_deterministic(tmpdir):
    make_repo(
        tmpdir,
        nodes={
            "node1": {
                'bundles': ["bundle1"],
            },
        },
        bundles={
            "bundle1": {
                'files': {
                    "/test": {
                        'content': "${node.name}",
                    },
                },
            },
        },
    )

    hashes = set()

    for i in range(3):
        with io.capture() as captured:
            main("hash", path=str(tmpdir))
        hashes.add(captured['stdout'].strip())

    assert len(hashes) == 1
    assert hashes.pop() == "8c155b4e7056463eb2c8a8345f4f316f6d7359f6"
Exemple #2
0
def test_nondeterministic(tmpdir):
    make_repo(
        tmpdir,
        nodes={
            "node1": {
                'bundles': ["bundle1"],
            },
        },
        bundles={
            "bundle1": {
                'files': {
                    "/test": {
                        'content_type': 'mako',
                        'content': "<% import random %>${random.randint(1, 9999)}",
                    },
                },
            },
        },
    )

    hashes = set()

    for i in range(3):
        with io.capture() as captured:
            main("hash", path=str(tmpdir))
        hashes.add(captured['stdout'].strip())

    assert len(hashes) > 1
 def test_simple_create(self, exit):
     chdir(self.tmpdir)
     main("repo", "create")
     self.assertFalse(isfile(join(self.tmpdir, "bundles", "test", "bundle.py")))
     self.assertFalse(isdir(join(self.tmpdir, "bundles", "test", "files")))
     main("repo", "bundle", "create", "test")
     self.assertTrue(isfile(join(self.tmpdir, "bundles", "test", "bundle.py")))
     self.assertTrue(isdir(join(self.tmpdir, "bundles", "test", "files")))
Exemple #4
0
def test_not_a_repo_test(tmpdir):
    with pytest.raises(SystemExit):
        main('nodes', path=str(tmpdir))
 def test_exit(self):
     chdir(self.tmpdir)
     with self.assertRaises(SystemExit):
         main("debug")
 def test_simple_create(self, exit):
     chdir(self.tmpdir)
     main("repo", "create")
     self.assertTrue(getsize(join(self.tmpdir, "nodes.py")) > 1)
Exemple #7
0
def test_empty(tmpdir):
    make_repo(tmpdir)
    with io.capture() as captured:
        main("hash", path=str(tmpdir))
    assert captured['stdout'] == "bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f\n"
    assert captured['stderr'] == ""