2018-08-27 11:50:34 -04:00
|
|
|
"""Tests for ntp"""
|
|
|
|
|
|
|
|
___license___ = "MIT"
|
2018-08-29 07:38:59 -04:00
|
|
|
___dependencies___ = ["upip:unittest", "ntp", "wifi", "ugfx_helper"]
|
2018-08-27 11:50:34 -04:00
|
|
|
|
2018-08-29 07:38:59 -04:00
|
|
|
import unittest, wifi, ntp, machine, ugfx_helper
|
2018-08-27 11:50:34 -04:00
|
|
|
|
|
|
|
class TestWifi(unittest.TestCase):
|
|
|
|
|
|
|
|
def setUpClass(self):
|
2018-08-29 07:38:59 -04:00
|
|
|
ugfx_helper.init()
|
2018-08-27 11:50:34 -04:00
|
|
|
wifi.connect()
|
|
|
|
|
2018-08-29 07:38:59 -04:00
|
|
|
def tearDownClass(self):
|
|
|
|
ugfx_helper.deinit()
|
|
|
|
|
2018-08-27 11:50:34 -04:00
|
|
|
def test_get_time(self):
|
|
|
|
t = ntp.get_NTP_time()
|
|
|
|
self.assertTrue(t > 588699276)
|
|
|
|
self.assertTrue(t < 1851003302) # 27 August 2028
|
|
|
|
|
|
|
|
def test_set_time(self):
|
|
|
|
ntp.set_NTP_time()
|
|
|
|
rtc = machine.RTC()
|
|
|
|
self.assertTrue(rtc.now()[0] >= 2018)
|
|
|
|
self.assertTrue(rtc.now()[0] <= 2028)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|