示例#1
0
    def case_update_record(self, refresh_db_before):
        """ Create test record in Tag table and then update it."""
        original_name = "tag3"
        update_name = "tag33"

        original_tag = TagOp.add(original_name)

        updated_tag_local = TagOp.update(original_tag, update_name)

        self.assertEqual(updated_tag_local.name, update_name)

        updated_tag_get = TagOp.get(name=update_name)

        self.assertTrue(len(updated_tag_get) is 1)
        self.assertEqual(updated_tag_get[0].name, update_name)
        self.assertEqual(updated_tag_get[0].id, original_tag.id)
示例#2
0
    def test_update(self, mock_tag, mock_val_name, mock_db):
        """ Assumptions:
                - update method run
        """
        new_name = "Test Name"
        tag_obj = mock_tag()

        updated_admin = TagOp.update(tag_obj, new_name)

        self.assertTrue(mock_val_name.called)

        db_exp_calls = [
            mock.call.session.add(updated_admin),
            mock.call.session.commit(),
        ]

        mock_db.assert_has_calls(db_exp_calls)