def test_reindex_cad_edit(self, definition_type, attribute_type, value): """Test reindex after CAD editing""" model_name = cad.get_inflector_model_name_dict()[definition_type] model_id = factories.get_model_factory(model_name)().id expected = [model_id] title = "test_title %s %s" % (definition_type, attribute_type) cad_model = models.all_models.CustomAttributeDefinition response = self.api.post(cad_model, [ self._create_cad_body( title, attribute_type, definition_type, model_name ) ]) self.assert200(response) cad_obj = db.session.query(cad_model).filter_by(title=title).first() title_edited = "%s_edited" % title self.api.put(cad_obj, {"title": title_edited}) self.assert200(response) ids = self.simple_query( model_name, expression=[title_edited, "=", value], type_="ids", field="ids" ) self.assertItemsEqual(ids, expected)
def handle_cad_deleting(sender, obj=None, service=None, event=None): """Make reindex after deleting CAD from admin panel Args: sender: A class of Resource handling the POST request. obj: A list of model instances created from the POSTed JSON. service: The instance of Resource handling the PUT request. event: Instance of an Event (if change took place) or None otherwise """ # pylint: disable=unused-argument model_name = cad.get_inflector_model_name_dict()[obj.definition_type] views.start_update_cad_related_objs(event.id, model_name, need_revisions=True)
def handle_cad_deleting(sender, obj=None, service=None, event=None): """Make reindex after deleting CAD from admin panel Args: sender: A class of Resource handling the POST request. obj: A list of model instances created from the POSTed JSON. service: The instance of Resource handling the PUT request. event: Instance of an Event (if change took place) or None otherwise """ # pylint: disable=unused-argument model_name = cad.get_inflector_model_name_dict()[obj.definition_type] views.start_update_cad_related_objs( event.id, model_name, need_revisions=True )
def test_reindex_cad_create(self, definition_type, attribute_type, value): """Test reindex after CAD creating""" model_name = cad.get_inflector_model_name_dict()[definition_type] model_id = factories.get_model_factory(model_name)().id expected = [model_id] title = "test_title %s %s" % (definition_type, attribute_type) cad_model = models.all_models.CustomAttributeDefinition response = self.api.post(cad_model, [ self._create_cad_body(title, attribute_type, definition_type, model_name) ]) self.assert200(response) ids = self.simple_query(model_name, expression=[title, "=", value], type_="ids", field="ids") self.assertItemsEqual(ids, expected)
def handle_cad_creating_editing(sender, obj=None, src=None, service=None, event=None, initial_state=None): """Make reindex without creating revisions for related objects after creating/editing CAD from admin panel Args: sender: A class of Resource handling the POST request. obj: A list of model instances created from the POSTed JSON. src: A list of original POSTed JSON dictionaries. service: The instance of Resource handling the PUT request. event: Instance of an Event (if change took place) or None otherwise initial_state: A named tuple of initial values of an object before applying any change. """ # pylint: disable=unused-argument model_name = cad.get_inflector_model_name_dict()[obj.definition_type] views.start_update_cad_related_objs(event.id, model_name)
def test_reindex_cad_delete(self, definition_type, attribute_type, value): """Test reindex after CAD deleting""" model_name = cad.get_inflector_model_name_dict()[definition_type] title = "test_title %s %s" % (definition_type, attribute_type) cad_model = models.all_models.CustomAttributeDefinition response = self.api.post(cad_model, [ self._create_cad_body(title, attribute_type, definition_type, model_name) ]) self.assert200(response) cad_obj = db.session.query(cad_model).filter_by(title=title).first() response = self.api.delete(cad_obj) self.assert200(response) ids = self.simple_query(model_name, expression=[title, "=", value], type_="ids", field="ids") self.assertItemsEqual(ids, [])
def handle_cad_creating_editing(sender, obj=None, src=None, service=None, event=None, initial_state=None): """Make reindex without creating revisions for related objects after creating/editing CAD from admin panel Args: sender: A class of Resource handling the POST request. obj: A list of model instances created from the POSTed JSON. src: A list of original POSTed JSON dictionaries. service: The instance of Resource handling the PUT request. event: Instance of an Event (if change took place) or None otherwise initial_state: A named tuple of initial values of an object before applying any change. """ # pylint: disable=unused-argument model_name = cad.get_inflector_model_name_dict()[obj.definition_type] views.start_update_cad_related_objs(event.id, model_name)
def test_reindex_cad_delete(self, definition_type, attribute_type, value): """Test reindex after CAD deleting""" model_name = cad.get_inflector_model_name_dict()[definition_type] title = "test_title %s %s" % (definition_type, attribute_type) cad_model = models.all_models.CustomAttributeDefinition response = self.api.post(cad_model, [ self._create_cad_body( title, attribute_type, definition_type, model_name ) ]) self.assert200(response) cad_obj = db.session.query(cad_model).filter_by(title=title).first() response = self.api.delete(cad_obj) self.assert200(response) ids = self.simple_query( model_name, expression=[title, "=", value], type_="ids", field="ids" ) self.assertItemsEqual(ids, [])