-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
44 lines (32 loc) · 4.06 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import pytest
import datetime
import dates
import numpy as np
class TestDates:
date = datetime.date(2019, 8, 7)
str_date = '20190807'
start_date = datetime.date(2019, 2, 1)
end_date = datetime.date(2019, 8, 9)
dates = ['20190201', '20190202', '20190203', '20190204', '20190205', '20190206', '20190207', '20190208', '20190209', '20190210', '20190211', '20190212', '20190213', '20190214', '20190215', '20190216', '20190217', '20190218', '20190219', '20190220', '20190221', '20190222', '20190223', '20190224', '20190225', '20190226', '20190227', '20190228', '20190301', '20190302', '20190303', '20190304', '20190305', '20190306', '20190307', '20190308', '20190309', '20190310', '20190311', '20190312', '20190313', '20190314', '20190315', '20190316', '20190317', '20190318', '20190319', '20190320', '20190321', '20190322', '20190323', '20190324', '20190325', '20190326', '20190327', '20190328', '20190329', '20190330', '20190331', '20190401', '20190402', '20190403', '20190404', '20190405', '20190406', '20190407', '20190408', '20190409', '20190410', '20190411', '20190412', '20190413', '20190414', '20190415', '20190416', '20190417', '20190418', '20190419', '20190420', '20190421', '20190422', '20190423', '20190424', '20190425', '20190426', '20190427', '20190428', '20190429', '20190430', '20190501', '20190502', '20190503', '20190504', '20190505', '20190506', '20190507', '20190508', '20190509', '20190510', '20190511', '20190512', '20190513', '20190514', '20190515', '20190516', '20190517', '20190518', '20190519', '20190520', '20190521', '20190522', '20190523', '20190524', '20190525', '20190526', '20190527', '20190528', '20190529', '20190530', '20190531', '20190601', '20190602', '20190603', '20190604', '20190605', '20190606', '20190607', '20190608', '20190609', '20190610', '20190611', '20190612', '20190613', '20190614', '20190615', '20190616', '20190617', '20190618', '20190619', '20190620', '20190621', '20190622', '20190623', '20190624', '20190625', '20190626', '20190627', '20190628', '20190629', '20190630', '20190701', '20190702', '20190703', '20190704', '20190705', '20190706', '20190707', '20190708', '20190709', '20190710', '20190711', '20190712', '20190713', '20190714', '20190715', '20190716', '20190717', '20190718', '20190719', '20190720', '20190721', '20190722', '20190723', '20190724', '20190725', '20190726', '20190727', '20190728', '20190729', '20190730', '20190731', '20190801', '20190802', '20190803', '20190804', '20190805', '20190806', '20190807', '20190808']
str_days = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
days = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
months = ['02', '03', '04', '05', '06', '07', '08']
march_dates = ['20190301', '20190302', '20190303', '20190304', '20190305', '20190306', '20190307', '20190308', '20190309', '20190310', '20190311', '20190312', '20190313', '20190314', '20190315', '20190316', '20190317', '20190318', '20190319', '20190320', '20190321', '20190322', '20190323', '20190324', '20190325', '20190326', '20190327', '20190328', '20190329', '20190330', '20190331']
datetime64 = np.datetime64('1970-01-01T00:00:00')
datetimedate = datetime.date(1970, 1, 1)
def test_create_str_date(self):
result = dates.date2str(self.date)
assert result == self.str_date
def test_get_dates(self):
result = dates.get_dates(self.start_date, self.end_date)
assert result == self.dates
def test_get_full_month(self):
result = dates.get_full_month(year='2019', month='03', days=self.str_days)
assert result == self.march_dates
def test_add_missing_zeros(self):
result = dates.pad_with_zeros(self.days)
assert result == self.str_days
#def test_get_start_date(self):
def test_convert_date(self):
result = dates.convert_date(self.datetime64)
assert result == self.datetimedate