def test_dehydrated_activity(self): activity_object = Pin(id=1) activity = Activity(1, LoveVerb, activity_object) dehydrated = activity.get_dehydrated() self.assertTrue(isinstance(dehydrated, DehydratedActivity)) self.assertEquals( dehydrated.serialization_id, activity.serialization_id)
def test_serialization_length(self): activity_object = Pin(id=1) activity = Activity(1, LoveVerb, activity_object) assert len(str(activity.serialization_id)) == 26
def add_entry(self, user_id, activity_id): verb = Love() activity = Activity(user_id, verb, activity_id) self.add_user_activity(user_id, activity)
def generate_activities(self): activities = [] for x in range(1, 20): activity = Activity(x, LoveVerb, Pin(id=x)) activities.append(activity) return activities
def test_contains_extraneous_object(self): activity = AggregatedActivity(1, [Activity(1, LoveVerb, Pin(id=1))]) with self.assertRaises(ValueError): activity.contains(Pin(id=1))
def test_compare_apple_and_oranges(self): activity = AggregatedActivity(1, [Activity(1, LoveVerb, Pin(id=1))]) with self.assertRaises(ValueError): activity == Pin(id=1)
def test_duplicated_activities(self): activity = Activity(1, LoveVerb, Pin(id=1)) aggregated = AggregatedActivity(1, [activity]) with self.assertRaises(DuplicateActivityException): aggregated.append(activity)
def test_contains(self): activity = Activity(1, LoveVerb, Pin(id=1)) aggregated = AggregatedActivity(1, [activity]) self.assertTrue(aggregated.contains(activity))
def test_compare_apple_and_oranges(self): activity_object = Pin(id=1) activity = Activity(1, LoveVerb, activity_object) with self.assertRaises(ValueError): activity == activity_object
def test_serialization_overflow_check_role_id(self): activity_object = Pin(id=1) Verb = type('Overflow', (LoveVerb,), {'id': 9999}) activity = Activity(1, Verb, activity_object) with self.assertRaises(TypeError): activity.serialization_id
def test_serialization_overflow_check_object_id(self): activity_object = Pin(id=10 ** 10) activity = Activity(1, LoveVerb, activity_object) with self.assertRaises(TypeError): activity.serialization_id
def test_serialization_type(self): activity_object = Pin(id=1) activity = Activity(1, LoveVerb, activity_object) assert isinstance(activity.serialization_id, (int, long, float))