예제 #1
0
 def test_equals(self):
     """Test that the custom equals function is working.."""
     a = Address("Foo Bar", "Bridge Street", "01234", "City", ["a", "b"])
     b = Address("Foo Bar", "Bridge Street", "01234", "City", ["a", "b"])
     self.assertEquals(a, a)
     self.assertEquals(a, b)
     self.failUnless(not (a == Address("Bar Foo", "Bridge Street", "01234",
                                       "City", ["a", "b"])))
예제 #2
0
 def test_inequal(self):
     """Test that the custom ne function is working.."""
     address = Address("Foo Bar", "Bridge Street", "01234", "City",
                       ["a", "b"])
     itemA = InvoiceItem("foo", 10, vat=0.10, number=2)
     itemB = InvoiceItem("bar", 100, vat=0.20, number=5)
     items = [itemA, itemB]
     a = Invoice("01.01.2006", address, items)
     assert_false(a != Invoice("01.01.2006", address, items))
     assert_not_none(a)
     assert_not_equals(a, "invalid")
     assert_not_equals(a, Invoice("01.01.2006", a, None))
     assert_not_equals(a, Invoice("01.01.2006", None, items))
     assert_not_equals(
         a, Invoice("01.01.2006", address, items, default_vat=0.2))
     assert_not_equals(a, Invoice("02.01.2006", address, items))
     assert_not_equals(
         a, Invoice("01.01.2006", address, items, invoice_number="R00012"))
     assert_not_equals(
         a, Invoice("01.01.2006", address, items,
                    invoice_subject="foo bar"))
     assert_not_equals(a, Invoice("01.01.2006", address, items, note="foo"))
     assert_not_equals(Invoice("01.01.2006", address, items, language='en'),
                       a)
     assert_not_equals(
         Invoice("01.01.2006", address, items, currency='USD'), a)
예제 #3
0
 def test_parse(self):
     xml = """<billingAddress>
         <name>FooBar Inc.</name>
         <street>9th Avenue</street>
         <zip>12345</zip>
         <city>New York</city>
     </billingAddress>"""
     address = Address("FooBar Inc.", "9th Avenue", "12345", "New York", [])
     read_address = AddressParser.parse(content=xml)
     self.assertEquals(address, read_address)
예제 #4
0
 def setUp(self):
     self.path_to_template_file = 'invoicegenerator/generator/rml/rg.rml'
     self.lines = DEFAULT_CONFIG + [
         "rml_template='%s'" % self.path_to_template_file,
     ]
     ConfigStore.read_configuration(self.lines)
     self.billing_address = Address(name="", street="", zipcode="", city="")
     self.invoice = Invoice(invoice_date="19.08.2011",
                            billing_address=self.billing_address)
     self.generator = RMLGenerator(self.invoice)
예제 #5
0
 def test_equals(self):
     """Test that the custom equals function is working."""
     address = Address("Foo Bar", "Bridge Street", "01234", "City",
                       ["a", "b"])
     itemA = InvoiceItem("foo", 10, vat=0.10, number=2)
     itemB = InvoiceItem("bar", 100, vat=0.20, number=5)
     items = [itemA, itemB]
     a = Invoice(address, items, default_vat=0.42)
     b = Invoice(address, items, default_vat=0.42)
     assert_equals(a, a)
     assert_equals(a, b)
     assert_false(a == Invoice(a, None))
예제 #6
0
 def test_parse(self):
     address = Address("FooBar Inc.", "9th Avenue", "12345", "New York", [])
     itemA = InvoiceItem("Moon", 196, vat=0.42, number=3)
     itemB = InvoiceItem("Sun", -10.5, vat=0.10, number=2)
     items = [itemA, itemB]
     i = Invoice("30.02.2006",
                 address,
                 items,
                 default_vat=0.42,
                 invoice_number="R001",
                 invoice_subject="Rechnung",
                 note="Foobar")
     read_invoice = InvoiceParser.parse(content=generate_xml())
     self.assertEquals(i, read_invoice)
     self.assertEquals(Invoice.DEFAULT_LANGUAGE, i.get_language())
예제 #7
0
 def parse_element(self, element):
     (name, street, zipcode, city, additional) = (None, None, None, None,
                                                  [])
     for item in element.getchildren():
         if item.tag == "name":
             name = item.text
         elif item.tag == "nameDetail":
             additional.append(item.text)
         elif item.tag == "street":
             street = item.text
         elif item.tag == "zip":
             zipcode = item.text
         elif item.tag == "city":
             city = item.text
     return Address(name, street, zipcode, city, additional)
예제 #8
0
 def test_inequal(self):
     """Test that the custom ne function is working.."""
     a = Address("Foo Bar", "Bridge Street", "01234", "City", ["a", "b"])
     self.failUnless(not (a != Address("Foo Bar", "Bridge Street", "01234",
                                       "City", ["a", "b"])))
     self.failUnless(a != None)
     self.failUnless(a != "invalid")
     self.failUnless(a != Address("Bar Foo", "Bridge Street", "01234",
                                  "City", ["a", "b"]))
     self.failUnless(a != Address("Foo Bar", "Tower Street", "01234",
                                  "City", ["a", "b"]))
     self.failUnless(a != Address("Foo Bar", "Bridge Street", "12345",
                                  "City", ["a", "b"]))
     self.failUnless(a != Address("Foo Bar", "Bridge Street", "01234",
                                  "Village", ["a", "b"]))
     self.failUnless(
         a != Address("Foo Bar", "Bridge Street", "01234", "City", None))
     self.failUnless(a != Address("Foo Bar", "Bridge Street", "01234",
                                  "City", ["c", "d"]))