import time, datetime

from twisted.trial import unittest
from twisted.internet import defer

from opennsa import nsa
from opennsa.backends import dud




class DUDBackendTest(unittest.TestCase):

    def setUp(self):
        self.backend = dud.DUDNSIBackend('TestDUD')

        source_stp  = nsa.STP('Aruba', 'A1' )
        dest_stp    = nsa.STP('Aruba', 'A3' )
        start_time = datetime.datetime.utcfromtimestamp(time.time() + 0.1 )
        end_time   = datetime.datetime.utcfromtimestamp(time.time() + 10 )
        bandwidth = 200

        self.service_params  = nsa.ServiceParameters(start_time, end_time, source_stp, dest_stp, bandwidth)


    @defer.inlineCallbacks
    def testBasicUsage(self):

        conn = self.backend.createConnection('A1', 'A3', self.service_params)

        yield conn.reserve()

        da, dp = conn.provision()
        yield da # provision acknowledged
        yield dp # provision performed

        yield conn.release()

        yield conn.terminate()


@@ -87,16 +87,47 @@
  defer%0A%0A
+from dateutil.tz import tzutc%0A%0A
 from ope
@@ -418,35 +418,32 @@
 tetime.datetime.
-utc
 fromtimestamp(ti
@@ -457,16 +457,25 @@
 () + 0.1
+, tzutc()
  )%0A     
@@ -508,19 +508,16 @@
 atetime.
-utc
 fromtime
@@ -538,16 +538,26 @@
 e() + 10
+,  tzutc()
  )%0A     

fix dud test to use timestamps with explicit tz info