'Assert that _set_attributes properly handles invalid attributes'

def test_set_attributes(self):

    attribute_error_message = 'No    attribute    on    %s    called    %s'
    invalid_attribute = {'invalid_attribute': None}
    valid_attribute = {'is_spotlight': None}
    collection = Collection(name=self.name, sr_names=[])
    Collection.by_name = Mock()
    Collection.by_name.return_value = collection
    with self.assertRaises(AttributeError) as e:
        CollectionStorage._set_attributes(self.name, invalid_attribute)
    self.assertEqual(e.exception.message, (attribute_error_message % (self.name, invalid_attribute.keys()[0])))
    with self.assertRaises(AttributeError) as e:
        CollectionStorage._set_attributes(self.name, dict(invalid_attribute, **valid_attribute))
    self.assertEqual(e.exception.message, (attribute_error_message % (self.name, invalid_attribute.keys()[0])))
    CollectionStorage._set_values = MagicMock()
    CollectionStorage._set_attributes(self.name, valid_attribute)
    CollectionStorage._set_values.assert_called_once_with(self.name, valid_attribute)
