# -*- mode: python; coding: utf-8 -*-
# Copyright 2016 the HERA Collaboration
# Licensed under the 2-clause BSD license.

"""Testing for `hera_mc.geo_location and geo_handling`.


"""

from __future__ import absolute_import, division, print_function

import unittest

from hera_mc import geo_location, geo_handling, mc


class test_connections(unittest.TestCase):

    def setUp(self):
        self.test_db = mc.connect_to_mc_testing_db()
        self.test_conn = self.test_db.engine.connect()
        self.test_trans = self.test_conn.begin()
        self.test_session = mc.MCSession(bind=self.test_conn)

    def tearDown(self):
        self.test_trans.rollback()
        self.test_conn.close()

    def test_add_part(self):
        self.test_session.add(geo_location.GeoLocation())

    def test_cofa(self):
        cofa = geo_handling.cofa(False)
        self.assertTrue('cofa' in cofa.station_name.lower())

    def test_get_location(self):
        located = geo_handling.get_location(['HH0'])
        self.assertTrue(located[0].station_name=='HH0')

    # def test_commit_part(self):
    #     part = connections.Parts()
    #     part.hpn ='happy_thing'
    #     part.manufacture_date = 'Oct 26, 2011'
    #     part.kind = 'vapor'
    #     print(part)
    #     self.test_session.add(part)
    #     self.test_session.commit()

if __name__ == '__main__':
    unittest.main()

@@ -325,27 +325,19 @@
 ss test_
-connections
+geo
 (unittes
@@ -766,32 +766,33 @@
 ocation())%0A%0A    
+#
 def test_cofa(se
@@ -804,16 +804,14 @@
     
+#
     
-cofa
+h
  = g
@@ -822,16 +822,50 @@
 andling.
+Handling(self.test_db)%0A    #    h.
 cofa(Fal
@@ -868,24 +868,25 @@
 (False)%0A    
+#
     self.ass
@@ -931,24 +931,25 @@
 wer())%0A%0A    
+#
 def test_get
@@ -965,24 +965,74 @@
 (self):%0A    
+#    h = geo_handling.Handling(self.test_db)%0A    #
     located 
@@ -1068,24 +1068,25 @@
 'HH0'%5D)%0A    
+#
     self.ass

patch to make geo tests work for now