"""
Name:       v.to.db
Purpose:    Tests v.to.db and its flags/options.
	
Author:     Sunveer Singh
Copyright:  (C) 2017 by Sunveer Singh and the GRASS Development Team
Licence:    This program is free software under the GNU General Public
	            License (>=v2). Read the file COPYING that comes with GRASS
	            for details.
"""

import os
from grass.gunittest.case import TestCase

class Testvtodb(TestCase):
    map='geology'
    mapused='geology'

    @classmethod
    def setUpClass(cls):
        cls.use_temp_region()
        cls.runModule('g.copy', vector=(cls.map, cls.mapused))   

    @classmethod
    def tearDownClass(cls):
        cls.del_temp_region()
        if os.path.isfile(cls.mapused):
	        os.remove(cls.mapused)

    def testlength(self):
        """Testing option lenght and columns onemap_pro"""
        self.assertModule('v.to.db', map=self.map, option="length", columns="onemap_pro")
        topology = dict(points=0)
	self.assertVectorFitsTopoInfo(self.map, topology)

    def testarea(self):
        """Testing option area and columns PERIMETER"""
        self.assertModule('v.to.db', map=self.map, option="area", columns="PERIMETER")
        topology = dict(points=0)
	self.assertVectorFitsTopoInfo(self.map, topology)

    def testperimeter(self):
        """Testing option perimeter and columns SHAPE_area"""
        self.assertModule('v.to.db', map=self.map, option="perimeter", columns="SHAPE_area")
        topology = dict(points=0)
	self.assertVectorFitsTopoInfo(self.map, topology)

    def testcount(self):
        """Testing option count and columns SHAPE_len"""
        self.assertModule('v.to.db', map=self.map, option="count", columns="SHAPE_len")
        topology = dict(points=0)
	self.assertVectorFitsTopoInfo(self.map, topology)

    def testslope(self):
        """Testing option sides and with two columns GEOL250_ID, GEO_NAME"""
        self.assertModule('v.to.db', map=self.map, option="sides", columns="GEOL250_ID, GEO_NAME")
        topology = dict(points=0)
	self.assertVectorFitsTopoInfo(self.map, topology)

if __name__ == '__main__':
    from grass.gunittest.main import test
    test()
