def test_dehydrate_data(self, resolwe_mock): data_obj = Data(id=1, resolwe=MagicMock()) data_obj.id = 1 # this is overriden when initialized process = self.process_mock result = Resolwe._process_inputs(resolwe_mock, {"genome": data_obj}, process) self.assertEqual(result, {'genome': 1}) result = Resolwe._process_inputs(resolwe_mock, {"reads": [data_obj]}, process) self.assertEqual(result, {'reads': [1]})
def test_dehydrate_data(self, resolwe_mock): data_obj = Data(id=1, resolwe=MagicMock()) data_obj.id = 1 # this is overriden when initialized process = self.process_json[0] result = Resolwe._process_inputs(resolwe_mock, {"genome": data_obj}, process) self.assertEqual(result, {'genome': 1}) result = Resolwe._process_inputs(resolwe_mock, {"reads": [data_obj]}, process) self.assertEqual(result, {'reads': [1]})
def test_dehydrate_data(self, resolwe_mock, copy_mock): data_obj = Data(id=1, resolwe=MagicMock()) data_obj.id = 1 # this is overriden when initialized process = self.process_mock # I appears it is not possible to deepcopy MagicMocks so we just patch # the deepcopy functionality: copy_mock.deepcopy = MagicMock(return_value={"genome": data_obj}) result = Resolwe._process_inputs(resolwe_mock, {"genome": data_obj}, process) self.assertEqual(result, {'genome': 1}) # I appears it is not possible to deepcopy MagicMocks so we just patch # the deepcopy functionality: copy_mock.deepcopy = MagicMock(return_value={"reads": data_obj}) result = Resolwe._process_inputs(resolwe_mock, {"reads": [data_obj]}, process) self.assertEqual(result, {'reads': [1]})
def test_get_data_id(self): data = Data(id=1, resolwe=MagicMock()) data.id = 1 # this is overriden when initialized self.assertEqual(get_data_id(data), 1) self.assertEqual(get_data_id(2), 2)