示例#1
0
 def __create_address(self, address, county, postal_code, country):
     created_address = Address()
     created_address.set_address(address)
     created_address.set_county(county)
     created_address.set_postal_code(postal_code)
     created_address.set_country(country)
     return created_address
    def test_bill_repo(self):
        invoice_repo = BillRepo(Invoice)

        invoice = Invoice()
        address = Address()
        address.set_address("Strada Academiei nr. 7")
        address.set_county("Bucuresti")
        address.set_country("Romania")
        address.set_postal_code("010011")
        customer = Customer("Ion", "Radu", "*****@*****.**",
                            "0758245170", address)
        company = Company()
        company.set_address(address)
        company.set_first_name("Plesoiu")
        company.set_last_name("Alexandru")
        company.set_fiscal_no("RO0123")
        company.set_registration_number("123456")
        company.set_company_name("Pleso Academy")
        company.set_fiscal_no("RO2345")
        company.set_registration_number("0000123456789")
        item = BillItem()
        currency = Currency("LEU", "Leu", "RON")
        item.set_name("Water")
        item.set_currency(currency)
        item.set_price(2)
        item.set_discount(0)
        item.set_description("Drinkabale liquid")
        item.set_id(1)
        customer.set_id(1)
        invoice.set_currency(currency)
        invoice.set_items([item])
        invoice.set_total(2)
        invoice.set_issuer(company)
        invoice.set_id(1)
        invoice.set_issue_date("12.12.2020")
        invoice.set_due_date("16.12.2020")
        invoice.set_customer(customer)
        invoice_repo.store(invoice)
        self.assertEqual(invoice_repo.get(1), invoice)
        item.set_quantity(2)
        invoice.set_items([item])
        invoice.set_total(4)
        invoice_repo.update(1, invoice)
        self.assertEqual(invoice_repo.get(1), invoice)
        invoice_repo.delete(1)
        self.assertEqual(invoice_repo.get_all(), [])
        self.assertEqual(invoice_repo.get(69), None)
        try:
            repo = BillRepo("asdas")
            self.assertFalse(True)
        except Exception as exp:
            self.assertFalse(False)

        with self.assertRaises(TypeError):
            invoice_repo.update(1, 1)

        with self.assertRaises(TypeError):
            invoice_repo.store(1)
示例#3
0
 def test_customer_getters(self):
     address = Address()
     address.set_address("Strada Academiei nr. 7")
     address.set_county("Bucuresti")
     address.set_country("Romania")
     address.set_postal_code("010011")
     customer = Customer("Ion", "Radu", "*****@*****.**",
                         "0758245170", address)
     self.assertEqual(customer.get_first_name(), "Ion")
     self.assertEqual(customer.get_last_name(), "Radu")
     self.assertEqual(customer.get_email_address(), "*****@*****.**")
     self.assertEqual(customer.get_phone_number(), "0758245170")
     self.assertEqual(customer.get_address(), address)
示例#4
0
 def ui_add(self):
     address_id = int(input("introduce the id: "))
     name = input("introduce the name: ")
     number = int(input("introduce the number: "))
     x = int(input("introduce x: "))
     y = int(input("introduce y: "))
     address = Address(address_id, name, number, x, y)
     self._address_controller.add(address)
示例#5
0
 def create_individual(self):
     individual = Individual()
     individual.set_cnp(input("Cnp: "))
     individual.set_first_name(input("First Name: "))
     individual.set_last_name(input("Last Name: "))
     individual.set_phone_number(input("Phone Number: "))
     individual.set_email_address(input("Email Address: "))
     address = input("Give address: ")
     county = input("Give county: ")
     postal_code = input("Give postal code: ")
     country = input("Give country: ")
     customer_address = Address()
     customer_address.set_address(address)
     customer_address.set_county(county)
     customer_address.set_country(country)
     customer_address.set_postal_code(postal_code)
     individual.set_address(address)
     return individual
示例#6
0
 def create_company(self):
     company = Company()
     company.set_first_name(input("First Name: "))
     company.set_last_name(input("Last Name: "))
     company.set_phone_number(input("Phone Number: "))
     company.set_email_address(input("Email Address: "))
     company.set_company_name(input("Company Name: "))
     company.set_fiscal_no(input("Fiscal Number: "))
     company.set_registration_number(input("Registration Number: "))
     address = input("Give address: ")
     county = input("Give county: ")
     postal_code = input("Give postal code: ")
     country = input("Give country: ")
     customer_address = Address()
     customer_address.set_address(address)
     customer_address.set_county(county)
     customer_address.set_country(country)
     customer_address.set_postal_code(postal_code)
     company.set_address(customer_address)
     return company
示例#7
0
 def test_all(self):
     address_repo = Repository()
     address_c = AddressController(address_repo)
     a1 = Address(1, "ghdoja", 10, 18, 20)
     a2 = Address(2, "rovine", 16, 20, 19)
     address_c.add(a1)
     self.assertEqual(len(address_repo.return_all()), 1)
     self.assertEqual(a1.id, 1)
     self.assertEqual(a1.name, "ghdoja")
     self.assertEqual(a1.number, 10)
     self.assertEqual(a1.x, 18)
     self.assertEqual(a1.y, 20)
     address_c.add(a2)
     self.assertNotEqual(len(address_repo.return_all()), 1)
     self.assertEqual(len(address_repo.return_all()), 2)
     self.assertNotEqual(a1, a2)
     lista1 = []
     for i in address_c.display_string("gh"):
         lista1.append(i)
     self.assertEqual((address_c.display_string("gh")), lista1)
     lista = []
     for i in address_c.distance(a1, 10):
         lista.append(i)
     self.assertEqual(lista, address_c.distance(a1, 10))
示例#8
0
 def test_equal(self):
     address = Address()
     address.set_address("Strada Academiei nr. 7")
     address.set_county("Bucuresti")
     address.set_country("Romania")
     address.set_postal_code("010011")
     customer = Customer("Ion", "Radu", "*****@*****.**",
                         "0758245170", address)
     customer2 = copy.deepcopy(customer)
     customer.set_id(1)
     customer2.set_id(2)
     self.assertNotEqual(customer, customer2)
     customer2.set_id(1)
     customer2.set_last_name("Dan")
     self.assertNotEqual(customer, customer2)
     customer2.set_last_name(customer.get_last_name())
     customer2.set_first_name("Pop")
     self.assertNotEqual(customer, customer2)
     customer2.set_first_name(customer.get_first_name())
     customer2.set_email_address("isk")
     self.assertNotEqual(customer, customer2)
     customer2.set_email_address(customer.get_email_address())
     customer2.set_phone_number("dokf")
     self.assertNotEqual(customer, customer2)
    def post(self):
        order = Order.get_instance().load(request.get_json())

        order.status = OrderStatus.created
        order.deleted = False
        order.total = 0

        order.address.deleted = False

        address = Address.get_instance().load(order.address)

        order.save()
        address.save()

        return None, 201
示例#10
0
 def test_service(self):
     service = Service("json_test.json", "json_test.json", "json_test.json",
                       "json_test.json")
     # Customer Options
     company = Company()
     address = Address()
     address.set_address("Strada Academiei nr. 7")
     address.set_county("Bucuresti")
     address.set_country("Romania")
     address.set_postal_code("010011")
     company.set_id(1)
     company.set_address(address)
     company.set_company_name("La Geani")
     company.set_registration_number("RO0123")
     company.set_fiscal_no("0000231523647")
     company.set_email_address("*****@*****.**")
     company.set_first_name("Ion")
     company.set_last_name("Bogdan")
     company.set_phone_number("0752314567")
     company.set_fiscal_no("0000012345678")
     company.set_registration_number("RO01923")
     service.create_customer(company)
     self.assertEqual(service.get_company_customer(1), company)
     company.set_company_name("Marketplex")
     service.modify_customer(1, company)
     self.assertEqual(service.get_company_customer(1), company)
     service.delete_customer(company)
     self.assertEqual(service.view_all_company_customer(), [])
     individual = Individual()
     individual.set_cnp("1971209075425")
     individual.set_id(1)
     individual.set_first_name("Petre")
     individual.set_last_name("Vasile")
     individual.set_phone_number("0745321784")
     individual.set_email_address("*****@*****.**")
     service.create_customer(individual)
     self.assertEqual(service.get_individual_customer(1), individual)
     individual.set_last_name("Gigel")
     service.modify_customer(1, individual)
     self.assertEqual(service.get_individual_customer(1), individual)
     service.delete_customer(individual)
     self.assertEqual(service.view_all_individual_customer(), [])
     individual.set_address(address)
     # Currency Options
     currency = Currency("$", "Dollar", "USD")
     currency.set_id(1)
     currency.set_exchange_rate(4.5)
     service.create_currency(currency)
     self.assertEqual(currency, service.get_currency(1))
     currency.set_exchange_rate(4.2)
     service.modify_currency(1, currency)
     self.assertEqual(currency, service.get_currency(1))
     service.delete_currency(1)
     self.assertEqual(service.view_currency(), [])
     # Item Options
     item = Item()
     item.set_id(1)
     item.set_currency(currency)
     item.set_name("McChicken")
     item.set_description("Chicken hamburger")
     item.set_price(2)
     item.set_discount(0)
     service.create_item(item)
     self.assertEqual(item, service.choose_item(1))
     item.set_price(3)
     service.modify_item(1, item)
     self.assertEqual(item, service.choose_item(1))
     service.delete_item(1)
     self.assertEqual(service.view_items(), [])
     # Bill Options
     bill_item = BillItem()
     bill_item.set_id(1)
     bill_item.set_currency(currency)
     bill_item.set_name("McChicken")
     bill_item.set_description("Chicken hamburger")
     bill_item.set_price(3)
     bill_item.set_discount(0)
     bill = Invoice()
     bill.set_customer(individual)
     bill.set_currency(currency)
     bill.set_items([bill_item])
     bill.set_id(1)
     bill.set_issuer(company)
     bill.set_issue_date("24.01.2021")
     bill.set_due_date("10.02.2021")
     bill.set_notes("Platiti la Banca Transilvania")
     service.create_item(item)
     service.create_bill(bill)
     self.assertEqual(service.get_invoice(1), bill)
     bill.set_notes("asdfge")
     service.modify_bill(1, bill)
     self.assertEqual(service.get_invoice(1), bill)
     service.add_item_to_bill(1, bill)
     bill.add_items(bill_item)
     self.assertEqual(service.get_invoice(1), bill)
     service.invoice_to_fiscal(1)
     fiscal_bill = FiscalBill()
     fiscal_bill.set_customer(individual)
     fiscal_bill.set_currency(currency)
     bill_item.set_quantity(2)
     fiscal_bill.set_total(3.0)
     fiscal_bill.set_items([bill_item])
     fiscal_bill.set_id(1)
     fiscal_bill.set_issuer(company)
     fiscal_bill.set_issue_date("24.01.2021")
     fiscal_bill.set_due_date("10.02.2021")
     fiscal_bill.set_notes("asdfge")
     self.assertEqual(fiscal_bill, service.get_fiscal(1))
     service.delete_bill(bill)
     file = open("json_test.json", "w")
     file.truncate(0)
     file.write("{}")
     file.close()