def teste_inserir_documento_valido(self): string_json = '{"projeto": "teste_inserir"}' retorno = Op.inserir_json(self.colecao, string_json) self.assertTrue(retorno) valor_obtido = Op.buscar_json(self.colecao, string_json).count() self.assertEqual(valor_obtido, 1) Op.excluir_json(self.colecao, string_json)
def teste_alterar_documento_valido(self): string_json_inserir = '{"projeto": "teste_altera"}' Op.inserir_json(self.colecao, string_json_inserir) string_json_alterar = '{"projeto": "teste_alterado"}' retorno = Op.alterar_json(self.colecao, string_json_inserir, string_json_alterar) self.assertTrue(retorno) Op.excluir_json(self.colecao, string_json_alterar)
def teste_alterar_json_nova_vazia(self): string_json_inserir = '{"projeto": "teste_altera"}' Op.inserir_json(self.colecao, string_json_inserir) string_nova_json = '{}' with self.assertRaises(SystemExit) as ex: Op.alterar_json(self.colecao, string_json_inserir, string_nova_json) self.assertEqual(ex.exception.code, 5) Op.excluir_json(self.colecao, string_json_inserir)
def teste_excluir_documento_inexistente(self): string_json = '{"projeto": "projetoFalso"}' retorno = Op.excluir_json(self.colecao, string_json) self.assertFalse(retorno)
def teste_excluir_string_vazia(self): string_json = '' with self.assertRaises(SystemExit) as ex: Op.excluir_json(self.colecao, string_json) self.assertEqual(ex.exception.code, 2)