コード例 #1
0
 def teste_excluir_documento_valido(self):
     string_json = '{"projeto": "teste_excluir"}'
     Op.inserir_json(self.colecao, string_json)
     valor_obtido = Op.buscar_json(self.colecao, string_json).count()
     self.assertEqual(valor_obtido, 1)
     Op.excluir_json(self.colecao, string_json)
     valor_obtido = Op.buscar_json(self.colecao, string_json).count()
     self.assertEqual(valor_obtido, 0)
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 def teste_inserir_documento_duplicado(self):
     string_json = '{"projeto": "teste_inserir"}'
     Op.inserir_json(self.colecao, string_json)
     Op.inserir_json(self.colecao, string_json)
     valor_obtido = Op.buscar_json(self.colecao, string_json).count()
     self.assertEqual(valor_obtido, 2)
     retorno = Op.excluir_json(self.colecao, string_json)
     self.assertTrue(retorno)
     retorno2 = Op.excluir_json(self.colecao, string_json)
     self.assertTrue(retorno2)
コード例 #5
0
    def __busca_projeto(self):
        string_busca = '{"projeto":"' + self.nome_projeto + '"}'
        documentos_encontrados = Operacoes.buscar_json(self.colecao, string_busca)

        if documentos_encontrados.count() == 0:
            Log.imprime("A BUSCA NAO RETORNOU NENHUM DOCUMENTO REFERENTE AO PROJETO.\nNOME DE PROJETO INFORMADO: " +
                        self.nome_projeto + "INSERINDO PROJETO NO MONGO", classe=InformacoesArtefatos)

            Operacoes.inserir_json(self.colecao, string_busca)

        self.__conexao.fechar_conexao()
        return documentos_encontrados[0]
コード例 #6
0
 def teste_inserir_json_vazio(self):
     string_json = '{}'
     with self.assertRaises(SystemExit) as ex:
         Op.inserir_json(self.colecao, string_json)
     self.assertEqual(ex.exception.code, 3)