def test_cleaned_dates(): bh = Buildhub() records = [ {"_source": { "download": {"date": "2019-01-28T23:49:22.717388+00:00"}, "source": {"revision": "abc"}, "target": {"version": "1"} }}, {"_source": { "download": {"date": "2019-01-29T23:49:22Z"}, "source": {"revision": "def"}, "target": {"version": "2"} }} ] expected = [ {"revision": "abc", "date": datetime(2019, 1, 28, 23, 49, 22, 717388), "version": "1"}, {"revision": "def", "date": datetime(2019, 1, 29, 23, 49, 22), "version": "2"} ] assert bh._distinct_and_clean(records) == expected
def test_unique_sorted(records): bh = Buildhub() records[1]["_source"]["source"]["revision"] = "abc" records[1]["_source"]["download"]["date"] = "2019-01-22T23:49:22Z" expected = [ {"revision": "abc", "date": datetime(2019, 1, 22, 23, 49, 22), "version": "2", "tree": "releases/mozilla-release"}, ] assert bh._distinct_and_clean(records) == expected
def test_cleaned_dates(records): bh = Buildhub() expected = [ {"revision": "abc", "date": datetime(2019, 1, 28, 23, 49, 22, 717388), "version": "1", "tree": "releases/mozilla-release"}, {"revision": "def", "date": datetime(2019, 1, 29, 23, 49, 22), "version": "2", "tree": "releases/mozilla-release"} ] assert bh._distinct_and_clean(records) == expected