def returns_the_intro_date_of_a_piece_of_legislation (self): legislation = Mock() legislation.intro_date = 5 feed_data = NewLegislationFeed() last_updated = feed_data.get_last_updated(legislation) assert_equal(last_updated, 5)
def returns_an_empty_dict_if_introduced_before_given_time (self): legislation = Mock() legislation.intro_date = date.min legislation.title = 'Hello, world!' feed_data = NewLegislationFeed() changes = feed_data.get_changes_to(legislation, datetime.now()) assert_equal(changes, ({}, datetime(1, 1, 1, 0, 0)))
def returns_the_title_if_introduced_since_given_time (self): legislation = Mock() legislation.intro_date = date(2012, 9, 20) legislation.title = 'Hello, world!' feed_data = NewLegislationFeed() changes = feed_data.get_changes_to(legislation, datetime.min) assert_equal(changes, ({'Title': 'Hello, world!'}, datetime(2012, 9, 20, 0, 0)))
def returns_the_intro_date_of_a_piece_of_legislation (self): content = [Mock(), Mock(), Mock()] content[0].intro_date = 5 feed_data = NewLegislationFeed() feed_data.get_content = Mock(return_value=content) last_updated = feed_data.get_last_updated_time() assert_equal(last_updated, 5)
def has_isSubscribed_set_to_true_when_current_user_is_subscribed(self): from django.contrib.auth.models import User from subscriptions.models import Subscriber, Subscription from subscriptions.feeds import ContentFeedLibrary from main.feeds import NewLegislationFeed subscriber = Subscriber(username="******") subscriber.set_password("world") subscriber.save() library = ContentFeedLibrary() library.register(NewLegislationFeed, 'blah blah') feed = NewLegislationFeed() subscription = subscriber.subscribe(feed) subscriber.save() # Make the request. client = Client() assert client.login(username="******", password="******") response = client.get('/legislation/') # Check the context assert response.context['is_subscribed'] assert_equal(response.context['subscription'], subscription)