def test_dim_subdim(self):
        p = Parser(self.acc)
        p.dim('2', 'Godis')
        dim, = blm.accounting.Dimension._query(number='2').run()
        assert dim.name == ['Godis']
        assert dim.subdim_of == []

        p.sub_dim('6', 'Polkagrisar', '2')
        subdim, = blm.accounting.Dimension._query(number='6').run()
        assert subdim.name == ['Polkagrisar']
        assert subdim.subdim_of == [dim]

        p.dim('21', 'Lokaler')
        p.sub_dim('22', 'Rum', '21')

        dim, = blm.accounting.Dimension._query(number='21').run()
        subdim, = blm.accounting.Dimension._query(number='22').run()

        assert dim.accounting == subdim.accounting == [self.acc]
        assert subdim.subdim_of == [dim]

        assert dim.name == ['Lokaler']
        assert subdim.name == ['Rum']

        p.accounting_object('21', '1', 'Byggnad 1')
        p.accounting_object('22', '11', 'Rum 1')

        ao1, = blm.accounting.AccountingObject._query(number='1').run()
        assert ao1.dimension == [dim]
        assert ao1.name == ['Byggnad 1']

        ao11, = blm.accounting.AccountingObject._query(number='11').run()
        assert ao11.dimension == [subdim]
        assert ao11.name == ['Rum 1']
 def test_subdim_of_undefined(self):
     p = Parser(self.acc)
     dim = p.sub_dim('22', 'Rum', '21')
     assert len(p.parse_warnings) == 1
     assert '21' in p.parse_warnings[0]
     assert dim.subdim_of[0].number == ['21']