def test_already_associated(self, mock_criteria): associated = [ {'name': 'pulp1', 'author': 'john', 'version': '1.0'}, {'name': 'pulp2', 'author': 'josh', 'version': '2.0'} ] conduit = Mock() conduit.get_units = Mock(return_value=[]) criteria = Mock() mock_criteria.return_value = criteria # test and validation module = Mock() inventory = Inventory(conduit) inventory.associated = set() inventory.associated.add(tuple(associated[0].items())) inventory.associated.add(tuple(associated[1].items())) # should be associated module.unit_key = Mock(return_value=associated[0]) self.assertTrue(inventory.already_associated(module)) # should be associated module.unit_key = Mock(return_value=associated[1]) self.assertTrue(inventory.already_associated(module)) # should not be associated module.unit_key = Mock(return_value={}) self.assertFalse(inventory.already_associated(module))