def _perform_test(self, function_to_call, function_parameters, expected_output, annex_reply=None, function_result=None): self.annex.input = io.StringIO(annex_reply) result = function_to_call(*function_parameters) self.assertEqual(result, function_result) self.assertEqual(utils.buffer_lines(self.output)[1].rstrip(), "EXTENSIONS") self.assertEqual(utils.buffer_lines(self.output)[2].rstrip(), expected_output)
def TestLogging(self): self.annex.Listen(io.StringIO("PREPARE")) buffer_lines = utils.buffer_lines(self.output) self.assertEqual(buffer_lines[1], "DEBUG root - WARNING - test") self.assertEqual(buffer_lines[2], "DEBUG this is a new line")
def TestGetinfo(self): self.remote.info = {'info field 1': 'infovalue', 'info field 2':'infovalue 2'} self.annex.Listen(io.StringIO("GETINFO")) self.assertEqual(utils.buffer_lines(self.output)[1:], ['INFOFIELD info field 1', 'INFOVALUE infovalue', 'INFOFIELD info field 2', 'INFOVALUE infovalue 2', 'INFOEND'] )
def TestListconfigs(self): self.remote.listconfigs.return_value = { 'Name': 'Description', 'con1': "necessary configuration", 'opt': "optional configuration" } self.annex.Listen(io.StringIO("LISTCONFIGS")) self.assertEqual(self.remote.listconfigs.call_count, 1) self.assertEqual( utils.buffer_lines(self.output)[1:], [ 'CONFIG Name Description', 'CONFIG con1 necessary configuration', 'CONFIG opt optional configuration', 'CONFIGEND' ])
def TestGetinfo(self): self.remote.info = { "info field 1": "infovalue", "info field 2": "infovalue 2" } self.annex.Listen(io.StringIO("GETINFO")) self.assertEqual( utils.buffer_lines(self.output)[1:], [ "INFOFIELD info field 1", "INFOVALUE infovalue", "INFOFIELD info field 2", "INFOVALUE infovalue 2", "INFOEND", ], )
def TestListconfigs(self): self.remote.listconfigs.return_value = { "Name": "Description", "con1": "necessary configuration", "opt": "optional configuration", } self.annex.Listen(io.StringIO("LISTCONFIGS")) self.assertEqual(self.remote.listconfigs.call_count, 1) self.assertEqual( utils.buffer_lines(self.output)[1:], [ "CONFIG Name Description", "CONFIG con1 necessary configuration", "CONFIG opt optional configuration", "CONFIGEND", ], )
def TestGetinfoNone(self): self.remote.info = {} self.annex.Listen(io.StringIO("GETINFO")) self.assertEqual(utils.buffer_lines(self.output)[1:], ["INFOEND"])