1
+ import pytest
2
+
3
+ from dt_convert import years_ago , convert_eu_to_us_date
4
+
5
+
6
+ def test_years_ago ():
7
+ assert years_ago ('8 Aug, 2015' ) == 3
8
+ assert years_ago ('6 Sep, 2014' ) == 4
9
+ assert years_ago ('1 Oct, 2010' ) == 8
10
+ assert years_ago ('31 Dec, 1958' ) == 60
11
+
12
+
13
+ def test_years_ago_wrong_input ():
14
+ with pytest .raises (ValueError ):
15
+ # Sept != valid %b value 'Sep'
16
+ assert years_ago ('6 Sept, 2014' ) == 4
17
+
18
+
19
+ def test_convert_eu_to_us_date ():
20
+ assert convert_eu_to_us_date ('11/03/2002' ) == '03/11/2002'
21
+ assert convert_eu_to_us_date ('18/04/2008' ) == '04/18/2008'
22
+ assert convert_eu_to_us_date ('12/12/2014' ) == '12/12/2014'
23
+ assert convert_eu_to_us_date ('1/3/2004' ) == '03/01/2004'
24
+
25
+
26
+ def test_convert_eu_to_us_date_invalid_day ():
27
+ with pytest .raises (ValueError ):
28
+ convert_eu_to_us_date ('41/03/2002' )
29
+
30
+
31
+ def test_convert_eu_to_us_date_invalid_month ():
32
+ with pytest .raises (ValueError ):
33
+ convert_eu_to_us_date ('11/13/2002' )
34
+
35
+
36
+ def test_convert_eu_to_us_date_invalid_year ():
37
+ with pytest .raises (ValueError ):
38
+ convert_eu_to_us_date ('11/13/year' )
0 commit comments