Esempio n. 1
0
 def test_getprice_for_var_weight_prod(self):
     eanparser = EanParser('2369664001999')
     assert eanparser.getprice() == 1.99
Esempio n. 2
0
 def test_getmcode_for_bulk_product(self):
     eanparser = EanParser('230036490033000165000542')
     assert eanparser.getmcode() == 3649
Esempio n. 3
0
 def test_getmcode_errors(self):
     eanparser = EanParser('840036490033000165000542')
     with pytest.raises(ValueError) as e:
         eanparser.getmcode()
     assert 'EAN does not belong to: own, variable weight, or bulk' == str(
         e.value)
Esempio n. 4
0
 def test_getmcode_for_own_product(self):
     eanparser = EanParser('8480000278623')
     assert eanparser.getmcode() == 27862
Esempio n. 5
0
 def test_getmcode_for_variable_weight_product(self):
     eanparser = EanParser('2369664001999')
     assert eanparser.getmcode() == 69664
Esempio n. 6
0
 def test_getpvp_for_bulk(self):
     eanparser = EanParser('230036490033000165000542')
     assert eanparser.getpvp() == 1.65
Esempio n. 7
0
 def test_getweight_for_bulk(self):
     eanparser = EanParser('230036490033000165000542')
     assert eanparser.getweight() == 3.30
Esempio n. 8
0
 def test_variable_weight_product_valid_ean(self):
     eanparser = EanParser('2369664001999')
     assert eanparser.isvariableweightproduct()
Esempio n. 9
0
 def test_variable_weight_product_invalid_ean(self):
     eanparser = EanParser('238000027862300000000000')
     assert eanparser.isvariableweightproduct(
     ) == False, "This EAN can be only 13 characters, starting by '23'"
Esempio n. 10
0
 def test_is_own_product_valid_ean(self):
     eanparser = EanParser('8480000278623')
     assert eanparser.isownproduct()
Esempio n. 11
0
 def test_is_own_product_invalid_ean(self):
     eanparserinvalid = EanParser('848000027862300000000000')
     assert eanparserinvalid.isownproduct(
     ) == False, "This EAN can be only 13 characters, starting by '84'"
Esempio n. 12
0
 def test_ean_is_a_string_with_only_numbers(self):
     with pytest.raises(ValueError) as e:
         EanParser(self.nondigits)
     assert 'EAN is not a numeric string' == str(e.value)
Esempio n. 13
0
 def test_eanparser_raises_exception_with_other_string_length(self):
     with pytest.raises(ValueError) as e:
         EanParser(self.otherlength)
     assert 'Length of EAN is not 13 or 23' == str(e.value)
Esempio n. 14
0
 def test_ean_is_13_or_24_characters(self):
     eanparser24 = EanParser(self.eanstring24)
     assert isinstance(eanparser24, EanParser)
     eanparser13 = EanParser(self.eanstring13)
     assert isinstance(eanparser13, EanParser)
Esempio n. 15
0
 def test_getprice_for_bulk_prod(self):
     eanparser = EanParser('230036490033000165000542')
     assert eanparser.getprice() == 0.54
Esempio n. 16
0
 def test_is_bulk_product_valid_ean(self):
     eanparser = EanParser('230036490033000165000542')
     assert eanparser.isbulkproduct()
Esempio n. 17
0
 def test_getprice_for_no_price_prod(self):
     eanparser = EanParser('8480000278623')
     with pytest.raises(ValueError) as e:
         eanparser.getprice()
     assert 'EAN does not belong to variable weight or bulk prod' == str(
         e.value)
Esempio n. 18
0
 def test_is_bulk_product_invalid_ean(self):
     eanparser = EanParser('2369664001999')
     assert eanparser.isbulkproduct(
     ) == False, "This EAN can be only 24 characters, starting by '23'"
Esempio n. 19
0
 def test_getpvp_for_non_bulk(self):
     eanparser = EanParser('8480000278623')
     with pytest.raises(ValueError) as e:
         eanparser.getpvp()
     assert 'EAN is not bulk prod' == str(e.value)
Esempio n. 20
0
 def test_eanparser_class_exists(self):
     eanparser = EanParser(self.eanstring13)
     assert isinstance(eanparser, EanParser)