<s> import pytest <EOL> from datetime import datetime , timezone , timedelta <EOL> from twtxt . models import Tweet , Source <EOL> def test_source ( ) : <EOL> source = Source ( "<STR_LIT:foo>" , "<STR_LIT:bar>" ) <EOL> assert source . nick == "<STR_LIT:foo>" <EOL> assert source . url == "<STR_LIT:bar>" <EOL> with pytest . raises ( TypeError ) : <EOL> Source ( ) <EOL> def test_tweet_init ( ) : <EOL> with pytest . raises ( ValueError ) as e : <EOL> Tweet ( "<STR_LIT>" ) <EOL> assert "<STR_LIT>" in str ( e . value ) <EOL> with pytest . raises ( TypeError ) as e : <EOL> Tweet ( "<STR_LIT>" , <NUM_LIT:0> ) <EOL> assert "<STR_LIT>" in str ( e . value ) <EOL> source = Source ( "<STR_LIT:foo>" , "<STR_LIT:bar>" ) <EOL> created_at = datetime . now ( timezone . utc ) <EOL> tweet = Tweet ( "<STR_LIT>" , created_at , source ) <EOL> assert tweet . text == "<STR_LIT>" <EOL> assert tweet . created_at == created_at . replace ( microsecond = <NUM_LIT:0> ) <EOL> assert tweet . source == source <EOL> def test_tweet_str ( ) : <EOL> tweet = Tweet ( "<STR_LIT>" , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , tzinfo = timezone . utc ) ) <EOL> assert str ( tweet ) == "<STR_LIT>" <EOL> def test_tweet_relative_datetime ( ) : <EOL> tweet = Tweet ( "<STR_LIT>" ) <EOL> assert tweet . relative_datetime == "<STR_LIT>" <EOL> tweet = Tweet ( "<STR_LIT>" , datetime . now ( timezone . utc ) + timedelta ( hours = <NUM_LIT:1> , minutes = <NUM_LIT:1> ) ) <EOL> assert tweet . relative_datetime == "<STR_LIT>" <EOL> tweet = Tweet ( "<STR_LIT>" , datetime . now ( timezone . utc ) - timedelta ( hours = <NUM_LIT:1> , minutes = <NUM_LIT:1> ) ) <EOL> assert tweet . relative_datetime == "<STR_LIT>" <EOL> def test_tweet_absolute_datetime ( ) : <EOL> tweet = Tweet ( "<STR_LIT>" , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , tzinfo = timezone . utc ) ) <EOL> assert tweet . absolute_datetime == "<STR_LIT>" <EOL> def test_tweet_ordering ( ) : <EOL> now = datetime . now ( timezone . utc ) <EOL> tweet_1 = Tweet ( "<STR_LIT:A>" , now ) <EOL> tweet_2 = Tweet ( "<STR_LIT:B>" , now + timedelta ( hours = <NUM_LIT:1> ) ) <EOL> tweet_3 = Tweet ( "<STR_LIT:C>" , now + timedelta ( hours = <NUM_LIT:2> ) ) <EOL> tweet_4 = Tweet ( "<STR_LIT:D>" , now + timedelta ( hours = <NUM_LIT:2> ) ) <EOL> tweet_5 = Tweet ( "<STR_LIT:D>" , now + timedelta ( hours = <NUM_LIT:2> ) ) <EOL> source = Source ( "<STR_LIT:foo>" , "<STR_LIT:bar>" ) <EOL> with pytest . raises ( TypeError ) : <EOL> tweet_1 < source <EOL> with pytest . raises ( TypeError ) : <EOL> tweet_1 <= source <EOL> with pytest . raises ( TypeError ) : <EOL> tweet_1 > source <EOL> with pytest . raises ( TypeError ) : <EOL> tweet_1 >= source <EOL> assert tweet_1 != source <EOL> assert tweet_1 < tweet_2 <EOL> assert tweet_1 <= tweet_2 <EOL> assert tweet_2 > tweet_1 <EOL> assert tweet_2 >= tweet_1 <EOL> assert tweet_3 != tweet_4 <EOL> assert tweet_5 == tweet_4 <EOL> assert tweet_5 >= tweet_4 <EOL> assert tweet_5 <= tweet_4 <EOL> assert not ( tweet_3 <= tweet_4 ) <EOL> assert not ( tweet_3 >= tweet_4 ) </s>
