예제 #1
0
 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)
예제 #2
0
 def test_serialization_length(self):
     activity_object = Pin(id=1)
     activity = Activity(1, LoveVerb, activity_object)
     assert len(str(activity.serialization_id)) == 26
예제 #3
0
 def add_entry(self, user_id, activity_id):
     verb = Love()
     activity = Activity(user_id, verb, activity_id)
     self.add_user_activity(user_id, activity)
예제 #4
0
 def generate_activities(self):
     activities = []
     for x in range(1, 20):
         activity = Activity(x, LoveVerb, Pin(id=x))
         activities.append(activity)
     return activities
예제 #5
0
 def test_contains_extraneous_object(self):
     activity = AggregatedActivity(1, [Activity(1, LoveVerb, Pin(id=1))])
     with self.assertRaises(ValueError):
         activity.contains(Pin(id=1))
예제 #6
0
 def test_compare_apple_and_oranges(self):
     activity = AggregatedActivity(1, [Activity(1, LoveVerb, Pin(id=1))])
     with self.assertRaises(ValueError):
         activity == Pin(id=1)
예제 #7
0
 def test_duplicated_activities(self):
     activity = Activity(1, LoveVerb, Pin(id=1))
     aggregated = AggregatedActivity(1, [activity])
     with self.assertRaises(DuplicateActivityException):
         aggregated.append(activity)
예제 #8
0
 def test_contains(self):
     activity = Activity(1, LoveVerb, Pin(id=1))
     aggregated = AggregatedActivity(1, [activity])
     self.assertTrue(aggregated.contains(activity))
예제 #9
0
 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
예제 #10
0
 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
예제 #11
0
 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
예제 #12
0
 def test_serialization_type(self):
     activity_object = Pin(id=1)
     activity = Activity(1, LoveVerb, activity_object)
     assert isinstance(activity.serialization_id, (int, long, float))