Skip to content

Commit

Permalink
Merge pull request #11 from Semi-ATE/nerohmot
Browse files Browse the repository at this point in the history
added more tests
  • Loading branch information
nerohmot authored Feb 23, 2021
2 parents 7a1a193 + 8b8a6f6 commit 5f5b57e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 21 deletions.
15 changes: 0 additions & 15 deletions Semi_ATE/TnD/TnD.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@ def iso_to_gregorian(iso_year, iso_week, iso_day):
return year_start + datetime.timedelta(days=iso_day - 1, weeks=iso_week - 1)


def url_datetime_string_to_epoch(url_datetime):
retval = url_datetime
print(retval)
retval = retval.split(",")[1].strip()
retval = retval.replace("GMT", "").strip()
retval = datetime.datetime.strptime(retval, "%d %b %Y %H:%M:%S")
return int((retval - datetime.datetime(1970, 1, 1)).total_seconds())


def micronas_time_structure_to_epoch(Datum=0, Uhrzeit=0):
"""
Micronas uses the following legacy structures:
Expand Down Expand Up @@ -122,12 +113,6 @@ class DTError(RuntimeError):
def __init__(self, arg):
self.args = arg

def __str__(self):
return "".join(self.args)

def __repr__(self):
return "".join(self.args)


class TD(object):
"""
Expand Down
24 changes: 18 additions & 6 deletions tests/test_TD.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 18 22:42:32 2021
import time

from Semi_ATE.TnD.TnD import DT, TD


try:
_ = DT()
_ = _ - DT(_.epoch + 1)
except:
assert False
else:
assert True

one = 34858861
two = 2 * one

assert TD(one).__str__() == "1 year 1 month 1 week 1 day 1 hour 1 minute 1 second"
assert TD(two).__str__() == "2 years 2 months 2 weeks 2 days 2 hours 2 minutes 2 seconds"

@author: nerohmot
"""
5 changes: 5 additions & 0 deletions tests/test_is_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from Semi_ATE.TnD.TnD import is_date

assert is_date("32000000") is False
assert is_date("00130000") is False
assert is_date(0) is False
8 changes: 8 additions & 0 deletions tests/test_is_datecode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from Semi_ATE.TnD.TnD import is_datecode

assert is_datecode("00540") is False
assert is_datecode("00XX0") is False
assert is_datecode("00010") is False
assert is_datecode("00018") is False
assert is_datecode("0001X") is False
assert is_datecode(0) is False
3 changes: 3 additions & 0 deletions tests/test_micronas_time_structure_to_epoch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from Semi_ATE.TnD.TnD import micronas_time_structure_to_epoch

assert True

0 comments on commit 5f5b57e

Please sign in to comment.