Ejemplo n.º 1
0
 def test_good_attribute_is_working_properly(self):
     """testing if the good attribute value can be properly set
     """
     g1 = Good(name='Good1')
     g2 = Good(name='Good2')
     g3 = Good(name='Good3')
     test_value = [g1, g2, g3]
     p = PriceList(**self.kwargs)
     self.assertNotEqual(p.goods, test_value)
     p.goods = test_value
     self.assertEqual(p.goods, test_value)
Ejemplo n.º 2
0
 def test_good_attribute_is_working_properly(self):
     """testing if the good attribute value can be properly set
     """
     g1 = Good(name='Good1')
     g2 = Good(name='Good2')
     g3 = Good(name='Good3')
     test_value = [g1, g2, g3]
     p = PriceList(**self.kwargs)
     assert p.goods != test_value
     p.goods = test_value
     assert p.goods == test_value
Ejemplo n.º 3
0
    def test_good_attribute_is_a_list_of_objects_which_are_not_goods(self):
        """testing if a TypeError will be raised when the goods attribute is
        not a list of Good instances
        """
        p = PriceList(**self.kwargs)
        with pytest.raises(TypeError) as cm:
            p.goods = ['not', 1, 'good', 'instances']

        assert str(cm.value) == \
            'PriceList.goods should be a list of stalker.model.bugdet.Good ' \
            'instances, not str'
Ejemplo n.º 4
0
    def test_goods_attribute_is_not_a_list(self):
        """testing if a TypeError will be raised when the goods attribute is
        set to a value other than a list
        """
        g1 = Good(name='Test Good')
        self.kwargs['goods'] = [g1]
        p = PriceList(**self.kwargs)
        with pytest.raises(TypeError) as cm:
            p.goods = 'this is not a list'

        assert str(cm.value) == \
            'Incompatible collection type: str is not list-like'
Ejemplo n.º 5
0
    def test_good_attribute_is_a_list_of_objects_which_are_not_goods(self):
        """testing if a TypeError will be raised when the goods attribute is
        not a list of Good instances
        """
        p = PriceList(**self.kwargs)
        with self.assertRaises(TypeError) as cm:
            p.goods = ['not', 1, 'good', 'instances']

        self.assertEqual(
            str(cm.exception),
            'PriceList.goods should be a list of stalker.model.bugdet.Good '
            'instances, not str'
        )
Ejemplo n.º 6
0
    def test_goods_attribute_is_None(self):
        """testing if a TypeError will be raised when the goods attribute 
        is set to None
        """
        g1 = Good(name='Test Good')
        self.kwargs['goods'] = [g1]
        p = PriceList(**self.kwargs)
        assert p.goods == [g1]

        with pytest.raises(TypeError) as cm:
            p.goods = None

        assert str(cm.value) == \
            'Incompatible collection type: None is not list-like'
Ejemplo n.º 7
0
    def test_goods_attribute_is_not_a_list(self):
        """testing if a TypeError will be raised when the goods attribute is
        set to a value other than a list
        """
        g1 = Good(name='Test Good')
        self.kwargs['goods'] = [g1]
        p = PriceList(**self.kwargs)
        with self.assertRaises(TypeError) as cm:
            p.goods = 'this is not a list'

        self.assertEqual(
            str(cm.exception),
            'Incompatible collection type: str is not list-like'
        )
Ejemplo n.º 8
0
    def test_goods_attribute_is_None(self):
        """testing if a TypeError will be raised when the goods attribute 
        is set to None
        """
        g1 = Good(name='Test Good')
        self.kwargs['goods'] = [g1]
        p = PriceList(**self.kwargs)
        self.assertEqual(p.goods, [g1])

        with self.assertRaises(TypeError) as cm:
            p.goods = None

        self.assertEqual(
            str(cm.exception),
            'Incompatible collection type: None is not list-like')
Ejemplo n.º 9
0
 def test_goods_argument_is_None(self):
     """testing if the goods attribute  will be an empty list when the goods
     argument is None
     """
     self.kwargs['goods'] = None
     p = PriceList(**self.kwargs)
     assert p.goods == []
Ejemplo n.º 10
0
    def test_goods_attribute_is_None(self):
        """testing if a TypeError will be raised when the goods attribute 
        is set to None
        """
        g1 = Good(name='Test Good')
        self.kwargs['goods'] = [g1]
        p = PriceList(**self.kwargs)
        self.assertEqual(p.goods, [g1])

        with self.assertRaises(TypeError) as cm:
            p.goods = None

        self.assertEqual(
            str(cm.exception),
            'Incompatible collection type: None is not list-like'
        )
Ejemplo n.º 11
0
    def test_goods_argument_is_not_a_list(self):
        """testing if a TypeError will be raised when the goods argument value
        is not a list
        """
        self.kwargs['goods'] = 'this is not a list'
        with pytest.raises(TypeError) as cm:
            PriceList(**self.kwargs)

        assert str(cm.value) == \
            'Incompatible collection type: str is not list-like'
Ejemplo n.º 12
0
 def test_good_argument_is_working_properly(self):
     """testing if the good argument value is properly passed to the good
     attribute
     """
     g1 = Good(name='Good1')
     g2 = Good(name='Good2')
     g3 = Good(name='Good3')
     test_value = [g1, g2, g3]
     self.kwargs['goods'] = test_value
     p = PriceList(**self.kwargs)
     assert p.goods == test_value
Ejemplo n.º 13
0
    def test_goods_argument_is_a_list_of_objects_which_are_not_goods(self):
        """testing if a TypeError will be raised when the goods argument is not
        a list of Good instances
        """
        self.kwargs['goods'] = ['not', 1, 'good', 'instances']
        with self.assertRaises(TypeError) as cm:
            PriceList(**self.kwargs)

        self.assertEqual(
            str(cm.exception),
            'PriceList.goods should be a list of stalker.model.bugdet.Good '
            'instances, not str')
Ejemplo n.º 14
0
def query_price_list(price_list_name):
    """returns a Type instance either it creates a new one or gets it from DB
    """
    if not price_list_name:
        return None

    price_list_ = PriceList.query.filter_by(name=price_list_name).first()

    if price_list_name and price_list_ is None:
        # create a new PriceList
        logger.debug('creating new price_list: %s' % (price_list_name))
        price_list_ = PriceList(name=price_list_name)
        DBSession.add(price_list_)

    return price_list_
Ejemplo n.º 15
0
 def test_goods_argument_is_skipped(self):
     """testing if the goods attribute will be an empty list when the goods
     argument is skipped
     """
     p = PriceList(**self.kwargs)
     assert p.goods == []