Example #1
0
 def writingToLoc2(self):
     return self.allowing(execmock.call(lambda args:
       args[0] == "info-of-port" and args[1] == "1", ret=["0", "file", "ssh"])).\
       allowing(execmock.call(lambda args:
       args[0] == "info-of-port" and args[1] == "2", ret=["1", "file", "ssh"])).\
       allowing(execmock.call(lambda args:
       args[0] == "info-of-port" and args[1] in ["3", "specials"], ret=[]))
def test_shouldRemoveEmptyLinesAndSurroundingWhitespaceFromFuzzyOutput(fixture):
  fixture.execs.expect(fixture.executablePath, execmock.call(
    ("all-fuzzy",), ret=["A ", "B", " ", " C  D"]))

  assert fixture.functions.callFuzzy("all-fuzzy", [], {}) == ["A", "B", "C  D"]

  fixture.execs.check()
def test_shouldSplitLinesOfExactOutputAtNullBytes(fixture):
  uniterableOutput = object()

  fixture.execs.expect(fixture.executablePath, execmock.call(("list-files",), 
    ret=uniterableOutput, delimiter="\0"))

  assert fixture.functions.callExact("list-files", [], {}) is uniterableOutput

  fixture.execs.check()
def test_shouldCallExecutableWithOptionsInKeyValueFormat(fixture):
  options = {"First": "foo", "Second": "/tmp/quux"}

  fixture.execs.expect(fixture.executablePath, execmock.call(
      lambda args: args[0] == "sync" and args[1] == "arg" and set(args[2:4]) == 
          set(["First=foo", "Second=/tmp/quux"]) and len(args) == 4))

  fixture.functions.callVoid("sync", ["arg"], options)

  fixture.execs.check()
Example #5
0
 def _allowingOptionsCalls(self):
     return self.allowing(
         execmock.call(lambda args: args[0] == "available-options",
                       returningNotImplementedStatus=True))
Example #6
0
 def _allowingPortCalls(self):
     return self.allowing(
         execmock.call(lambda args: args[0] == "info-of-port",
                       returningNotImplementedStatus=True))
Example #7
0
 def _allowingCheckCall(self):
     return self.allowing(
         execmock.call(lambda args: args[0] == "check",
                       delimiter="\0",
                       returningNotImplementedStatus=True))
Example #8
0
 def allowing(indexString, protocols):
     return ret.allowing(
         execmock.call(lambda args: args ==
                       ("info-of-port", indexString),
                       ret=retValue))
Example #9
0
 def allowingPortSpecialsCalls(self, output=[]):
     return self.allowing(
         execmock.call(lambda args: args[0] == "info-of-port" and args[1] ==
                       "specials",
                       returningNotImplementedStatus=output == [],
                       ret=output))
Example #10
0
 def withOptions(self, *options):
     return self.allowing(
         execmock.call(lambda args: args[0] == "available-options",
                       ret=list(options)))
Example #11
0
 def expectingSync(self, matcher=lambda _: True):
     return self.expecting(
         execmock.call(lambda args: args[0] == "sync" and matcher(args)))
Example #12
0
 def expectingRestore(self, matcher=lambda _: True):
     return self.expecting(
         execmock.call(lambda args: args[0] == "restore" and matcher(args)))
Example #13
0
 def expectingListFiles(self, matcher=lambda _: True):
     return self.expecting(
         execmock.call(
             lambda args: args[0] == "list-files" and matcher(args),
             delimiter="\0"))
Example #14
0
 def syncerHavingAnyVersions(self):
     return self.aSyncer().allowingSetupCalls().allowing(
         execmock.call(lambda args: args[0] == "versions-of", ret=["0"]))
 def checkExceptionTypeWithExitStatus(exceptionType, exitStatus):
   fixture.execs.expect(fixture.executablePath, 
       execmock.call(partial(failWithExitStatus, exitStatus)))
   with pytest.raises(exceptionType):
     fixture.functions.callVoid("foo", [], {})
Example #16
0
 def checkOption(self, optionName, schedulings, matcher):
     self.execs.expect(
         "anacron",
         execmock.call(
             lambda args: matcher(args[1 + args.index(optionName)])))
     self.schedule(schedulings)