예제 #1
0
    def test_shouldCheckIfAllSharedOptionValuesOfAllRulesOfASchedulerAreEqual(
            self, fix):
        schedName = "sched-with-shared-opts"
        sched = mockSched(schedName,
                          sharedOptions=[
                              optInfo("ConfDir"),
                              optInfo("DestFile"),
                              optInfo("Version")
                          ])

        def rule(**schedOpts):
            return mockRule(scheduler=sched, schedOpts=schedOpts)

        rules = [
            rule(Version="1", ConfDir="/home", DestFile="/etc/foo"),
            rule(Version="1", ConfDir="/etc", DestFile="/etc/foo"),
            rule(Version="1", ConfDir="/usr/share")
        ]

        validator = self.construct()

        iterToTest(validator.validate(ruleSet(*rules))).\
            shouldContainMatchingInAnyOrder(
                stringThat.shouldInclude("ConfDir", "/home", "/etc", "/usr/share"),
                stringThat.shouldInclude("DestFile", "‘/etc/foo’", "‘’"))
예제 #2
0
    def test_shouldFindSyntaxErrorsInItsOptions(self, fixture):
        assert fixture.check(
            dict(AdditionalSyncOpts="--exclude '**/.*'")) == []

        iterToTest(
            fixture.check(
                dict(AdditionalSyncOpts="--exclude '",
                     RemoteShellCommand="("))).shouldContainMatchingInAnyOrder(
                         stringThat.shouldInclude("AdditionalSyncOpts",
                                                  "unexpected"),
                         stringThat.shouldInclude("RemoteShellCommand",
                                                  "unexpected"))
예제 #3
0
    def test_shouldFindSyntaxErrorsInTheExcludedDirsOption(self, fixture):
        assert fixture.check(dict(ExcludedDirs="'/foo bar'")) == []

        iterToTest(fixture.check(dict(ExcludedDirs="/foo'b"))).\
            shouldContainMatching(stringThat.shouldInclude(
              "unexpected", "ExcludedDirs"))

        iterToTest(fixture.check(dict(ExcludedDirs="relative/foo/bar"))).\
            shouldContainMatching(stringThat.shouldInclude("ExcludedDirs",
              "relative/foo/bar", "absolute"))
        iterToTest(fixture.check(dict(ExcludedDirs="'/foo' ''"))).\
            shouldContainMatching(stringThat.shouldInclude(
              "absolute", "ExcludedDirs"))
예제 #4
0
    def test_shouldTurnEachCheckErrorFromTheUsedSchedulersIntoAString(
            self, fix):
        sched1, sched2 = mockSched("first"), mockSched("second")
        rule1, rule2 = mockRule(scheduler=sched1), mockRule(scheduler=sched2)
        validator = self.construct()

        sched1.expectCalls(
            schedCallWithRules("check", rule1, ret=["foo", "bar"]))
        sched2.expectCalls(schedCallWithRules("check", rule2, ret=["quux"]))

        iterToTest(validator.validate(ruleSet(rule1, rule2))).\
            shouldContainMatchingInAnyOrder(
                stringThat.shouldInclude("first", "reported error", "foo"),
                stringThat.shouldInclude("first", "bar"),
                stringThat.shouldInclude("second", "quux"))
예제 #5
0
    def test_shouldReturnEachSyncerCheckErrorWithAnAppropriatePrefix(
            self, fix):
        rule1 = mockRule("first",
                         syncerName="syncer1",
                         syncerCheckErrors=["Wrong option syntax"])
        rule2 = mockRule(
            "second",
            syncerName="syncer2",
            syncerCheckErrors=["Contradictory values", "Unreadable File"])

        iterToTest(self.construct().validate(ruleSet(rule1, rule2))).\
            shouldContainMatchingInAnyOrder(
                stringThat.shouldInclude("syntax", "first", "syncer1"),
                stringThat.shouldInclude("Contradictory", "second", "syncer2"),
                stringThat.shouldInclude("Unreadable", "second", "syncer2"))
예제 #6
0
파일: rsync_test.py 프로젝트: pid0/sibt
    def test_shouldBeAbleToDryTestTheRsyncCommandThatWouldBeUsedToSync(
            self, fixture):
        assert "DryRun" in fixture.optionNames

        iterToTest(fixture.check(dict(DryRun=True, AdditionalSyncOpts="--bar"))).\
            shouldContainMatching(stringThat.shouldInclude("unknown option", "bar"))

        (fixture.loc1 / "file").write("")
        assert fixture.check({}) == []
        assert not os.path.isfile(str(fixture.loc2 / "file"))

        fixture.loc1.chmod(0o300)
        iterToTest(fixture.check(dict(DryRun=True))).shouldContainMatching(
            stringThat.shouldInclude("Permission denied"))
        assert fixture.check(dict(DryRun=False)) == []
예제 #7
0
파일: rsync_test.py 프로젝트: pid0/sibt
    def test_shouldFindSyntaxErrorsInItsOptions(self, fixture):
        assert fixture.check(
            dict(AdditionalSyncOpts="--one-file-system",
                 ExcludedDirs="/foo")) == []

        iterToTest(
            fixture.check(
                dict(AdditionalSyncOpts="'",
                     AdditionalOptsBothWays="'",
                     RemoteShellCommand="("))).shouldContainMatchingInAnyOrder(
                         stringThat.shouldInclude("unexpected",
                                                  "AdditionalOptsBothWays"),
                         stringThat.shouldInclude("unexpected",
                                                  "AdditionalSyncOpts"),
                         stringThat.shouldInclude("unexpected",
                                                  "RemoteShellCommand"))
예제 #8
0
    def test_shouldPrintTheActualMountPointIfTheAssertionTurnsOutFalse(
            self, fix):
        mountPoint = fix.tmpdir.mkdir("mount")

        with nonEmptyFSMountedAt(mountPoint):
            loc1 = mountPoint.mkdir("sub").mkdir("loc1")
            rule = mockRule(loc1=str(loc1), options=dict(MustBeMountPoint="1"))
            errors = self.construct().validate(ruleSet(rule))

        iterToTest(errors).shouldContainMatching(
            stringThat.shouldInclude("actual",
                                     str(mountPoint) + "’"))