Skip to content

Date tests - #1194

Open
joseangelhernao wants to merge 3 commits into
develop-21.9from
feature/tests
Open

Date tests#1194
joseangelhernao wants to merge 3 commits into
develop-21.9from
feature/tests

Conversation

@joseangelhernao

Copy link
Copy Markdown
Collaborator

No description provided.

@luis11011 luis11011 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great tests file, you can pull and merge from develop-21.9 into your tests branch to get better results for the generated tests before checking the pending changes.

t.create(method="cols.months_between", variant="multiple", cols=["Date Type", "timestamp", "last date seen"], value="29/02/2012", date_format='%d/%m/%Y', round="floor", output_cols=["dt", "ts", "da"])
t.create(method="cols.months_between", variant="multiple_today", cols=["Date Type", "timestamp", "last date seen"], round="ceil", output_cols=["dt", "ts", "da"])

t.create(method="cols.days_between", variant="all", cols="*", value='2000-1-1', date_format='%Y-%d-%m', round=False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

date_format is used to force the format of the input columns, a test like t.create(method="cols.days_between", variant="all", cols="*", value='2000-1-1', date_format='%Y-%d-%m', round=False) will work correctly.

You can pass a date_format in single columns or in columns with the same format but it's optional

('timestamp', 'time'): ['2014/12/24', datetime.datetime(2014, 6, 24, 15, 0), datetime.datetime(2014, 6, 24, 2, 12), datetime.datetime(2014, 6, 24, 23, 3, 59), "2021-04-05 17:38:11", datetime.datetime(2021, 9, 3, 0, 0, 1)],
})

t = TestCreator(op, df, name="date", configs=default_configs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get the days between values from two columns you can pass a column name to the value parameter (this also applies to the other functions).

df.cols.days_between(cols='some date', value='timestamp', round=False, output_cols="days")

Those operations also need to be tested.

@argenisleon should we use another parameter for this case? Like other_cols or simply renaming the already implemented parameter to other or value_or_cols.

Comment thread tests/test_created__date.py Outdated

def test_cols_days_between_single(self):
df = self.df
result = df.cols.days_between(cols=['date arrival'], value='Sat Sep 4 2021 10:05:39 -0400', date_format='%a %b %d %Y %H:%M:%S -%Y', round='down')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'%a %b %d %Y %H:%M:%S -%Y' is an invalid format:

error: redefinition of group name 'Y' as group 8; was group 4 at position 231

You should use '%a %b %d %Y %H:%M:%S %z' instead.

This repeats in several lines through the file.

Comment thread tests/creators/creator_date.py Outdated
t.create(method="cols.minutes_between", variant="all", cols="*", value='2000-1-1', date_format='%Y-%d-%m', round=False)
t.create(method="cols.minutes_between", variant="all_today", cols="*", round="up")
t.create(method="cols.minutes_between", variant="single", cols=["date arrival"], value="Sat Sep 4 2021 10:05:39 -0400", date_format='%a %b %d %Y %H:%M:%S -%Y', round="down")
t.create(method="cols.minutes_between", variant="single_timezone", cols=["date arrival", "same date"], round="round")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a typo, the column name should be "some date" instead of "same date".

This repeats in line 87.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants