"""
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'
    mapold='geology'

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

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

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

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

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

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

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

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