Exemplo n.º 1
0
    def testGetButtersByUser(self):
        user_name = 'nicholas'
        storage.add_user_(user_name)
        model_user = storage.get_user_by_name_(user_name)
        self.assertEquals(user_name, model_user.name)

        tag = Tag(name = 'tag1')
        storage.add_tag_(tag)

        storage.follow_tag(user_name, 'tag1')

        tag1 = Tag(name = 'tag1')
        tag2 = Tag(name = 'tag3')
        tag_collection = TagCollection(items = [tag1, tag2]) 
        expected_butter0 = Butter(content = 'hello', tags = tag_collection)
        model_butter = storage.add_butter_(expected_butter0)

        tag_collection = TagCollection(items = [tag1]) 
        expected_butter1 = Butter(content = 'hello3', tags = tag_collection)
        model_butter = storage.add_butter_(expected_butter1)

        model_butters = storage.get_butters_by_user_name_(user_name)
        self.assertEquals(2, len(model_butters))

        butters = storage.get_butters_by_user_name(user_name)
        self.assertEquals(2, len(butters))
        butter0 = butters[0]
        butter1 = butters[1]
        self.assertEquals(butter0, expected_butter0)
        self.assertEquals(butter1, expected_butter1)
Exemplo n.º 2
0
    def testGetButtersByUser(self):
        user_name = 'nicholas'
        storage.add_user_(user_name)
        model_user = storage.get_user_by_name_(user_name)
        self.assertEquals(user_name, model_user.name)

        tag = Tag(name='tag1')
        storage.add_tag_(tag)

        storage.follow_tag(user_name, 'tag1')

        tag1 = Tag(name='tag1')
        tag2 = Tag(name='tag3')
        tag_collection = TagCollection(items=[tag1, tag2])
        expected_butter0 = Butter(content='hello', tags=tag_collection)
        model_butter = storage.add_butter_(expected_butter0)

        tag_collection = TagCollection(items=[tag1])
        expected_butter1 = Butter(content='hello3', tags=tag_collection)
        model_butter = storage.add_butter_(expected_butter1)

        model_butters = storage.get_butters_by_user_name_(user_name)
        self.assertEquals(2, len(model_butters))

        butters = storage.get_butters_by_user_name(user_name)
        self.assertEquals(2, len(butters))
        butter0 = butters[0]
        butter1 = butters[1]
        self.assertEquals(butter0, expected_butter0)
        self.assertEquals(butter1, expected_butter1)
Exemplo n.º 3
0
    def testAddButter(self):
        tag1 = Tag(name = 'tag1')
        tag2 = Tag(name = 'tag2')
        tag_collection = TagCollection(items = [tag1, tag2]) 
        butter = Butter(content = 'hello', tags = tag_collection)
        model_butter = storage.add_butter_(butter)
        self.assertEquals(2, len(model_butter.tags))
        model_butters = storage.get_butters_by_tag_name_('tag1')
        self.assertEquals(1, len(model_butters))

        tag1 = Tag(name = 'tag1')
        tag2 = Tag(name = 'tag3')
        tag_collection = TagCollection(items = [tag1, tag2]) 
        butter = Butter(content = 'hello', tags = tag_collection)
        model_butter = storage.add_butter_(butter)
        model_butters = storage.get_butters_by_tag_name_('tag1')
        self.assertEquals(2, len(model_butters))

        model_butters = storage.get_butters_by_tag_name_('tag2')
        self.assertEquals(1, len(model_butters))
Exemplo n.º 4
0
    def testAddButter(self):
        tag1 = Tag(name='tag1')
        tag2 = Tag(name='tag2')
        tag_collection = TagCollection(items=[tag1, tag2])
        butter = Butter(content='hello', tags=tag_collection)
        model_butter = storage.add_butter_(butter)
        self.assertEquals(2, len(model_butter.tags))
        model_butters = storage.get_butters_by_tag_name_('tag1')
        self.assertEquals(1, len(model_butters))

        tag1 = Tag(name='tag1')
        tag2 = Tag(name='tag3')
        tag_collection = TagCollection(items=[tag1, tag2])
        butter = Butter(content='hello', tags=tag_collection)
        model_butter = storage.add_butter_(butter)
        model_butters = storage.get_butters_by_tag_name_('tag1')
        self.assertEquals(2, len(model_butters))

        model_butters = storage.get_butters_by_tag_name_('tag2')
        self.assertEquals(1, len(model_butters))