def test_save_provider(self): providers = len(ProviderModel.list()) new_provider = ProviderModel() new_provider.name = "Fornecedor 02" new_provider.cnpj = "98617744000154" new_provider.address = "Endereço 02" new_provider.city = "Cidade 02" new_provider.country = "País 02" new_provider.cep_code = "000000-000" new_provider.responsible_name = "Matheus D'Adamo Milani 01" new_provider.responsible_email = "*****@*****.**" new_provider.responsible_phone = "+55(11)97717-8888" new_provider.active = True new_provider.save() assert providers + 1 == len(ProviderModel.list())
def test_get_provider(self): provider = ProviderModel.get(1) assert provider.name == 'Fornecedor 01' provider = ProviderModel.get_by_cnpj('04790618000153') assert provider.name == 'Fornecedor 01' providers = ProviderModel.list() assert len(providers) == 1 assert type(providers) == type([])
def get(self): if 'id' in request.args: item = ProviderModel.get(request.args['id']) item = serialize_model(item) return item elif 'email' in request.args: item = ProviderModel.get_by_email(request.args['email']) item = serialize_model(item) return item elif 'cnpj' in request.args: item = ProviderModel.get_by_cnpj(request.args['cnpj']) item = serialize_model(item) return item list = ProviderModel.list() return serialize_model_list(list)
def test_delete_provider(self): providers = len(ProviderModel.list()) provider = ProviderModel.delete(2) assert providers - 1 == len(ProviderModel.list())