def test_embargo_creation(): next_year = arrow.utcnow().datetime + timedelta(days=+365) embargo = Embargo(until=next_year, reason="espionage") assert embargo.active last_year = arrow.utcnow().datetime + timedelta(days=-365) embargo = Embargo(until=last_year, reason="espionage") assert not embargo.active
def test_embargo_lift(): next_year = arrow.utcnow().datetime + timedelta(days=+365) last_year = arrow.utcnow().datetime + timedelta(days=-365) embargo_dict1 = {"until": next_year, "active": True, "reason": "espionage"} embargo_dict2 = {"until": last_year, "active": True, "reason": "espionage"} new_embargo = Embargo.from_dict(embargo_dict1) old_embargo = Embargo.from_dict(embargo_dict2) assert old_embargo.lift() assert not old_embargo.active assert not new_embargo.lift() assert new_embargo.active
def test_embargo_from_dict(): next_year = arrow.utcnow().datetime + timedelta(days=+365) embargo_dict = {"until": next_year, "active": True, "reason": "espionage"} embargo = Embargo.from_dict(embargo_dict) assert embargo.active assert embargo.until == next_year assert embargo.reason == "espionage" embargo_dict["until"] = next_year.strftime("%Y-%m-%d") assert embargo.dump() == embargo_dict