Пример #1
0
    def test_repr_multiple_posts(self):
        b = Blog('Test', "Test Author")
        b.posts = ['test']
        b2 = Blog('My Day', "Rolf")
        b2.posts = ['test', 'another']

        self.assertEqual(b.__repr__(), "<Test by Test Author (1 post)>")
        self.assertEqual(b2.__repr__(), "<My Day by Rolf (2 posts)>")
Пример #2
0
    def test_repr_multiple_posts(self):
        b = Blog('Test', 'Test Author')
        b.posts = ["Test"]
        b2 = Blog('My Day', 'Rolf')
        b2.posts = ['Test', 'Testing']

        self.assertEqual(b.__repr__(), 'Test by Test Author (1 post)')
        self.assertEqual(b2.__repr__(), 'My Day by Rolf (2 posts)')
Пример #3
0
    def test_repr_multiple_posts(self):
        b = Blog("Test", "Test Author")
        b.posts = ['test']
        self.assertEqual(b.__repr__(), "Test by Test Author (1 post)")

        b2 = Blog("Life in California", "Roy Goode")
        b2.posts = ["howdy" for word in range(5)]
        self.assertEqual(b2.__repr__(), "Life in California by Roy Goode (5 posts)")
Пример #4
0
    def test_repr_multiple(self):
        b=Blog('Two posts','Mary')
        b.posts=['test','test2']
        b2=Blog('One post','Harry')
        b2.posts['first post']

        self.assertEqual('Two posts by Mary (2 blog posts)', b.__repr__())
        self.assertEqual('One post by Harry (1 blog post', b2.__repr__())
Пример #5
0
    def test_multiple_post(self):
        b = Blog('Test', 'Test Author')
        b.posts = ['Test Post']
        b2 = Blog('Test', 'Test Author')
        b2.posts = ['Test Post', 'Test Post']

        self.assertEqual(b.__repr__(), 'Test by Test Author (1 post)')
        self.assertEqual(b2.__repr__(), 'Test by Test Author (2 posts)')
    def test_repr(self):
        """the __repr__ method must return our blog number(0 posts)
        """
        b = Blog("Test", "Test Author")
        b2 = Blog("My Day", "Victor")

        self.assertEqual(b.__repr__(), "Test by Test Author (0 posts)")
        self.assertEqual(b2.__repr__(), "My Day by Victor (0 posts)")
Пример #7
0
	def test_repr_multiple_posts(self):
		b = Blog('Meet and eat', 'Tom')
		b.posts = ['food post']
		b1 = Blog('I have a dog', 'Mary P')
		b1.posts = ['some post', 'dog post']

		self.assertEqual(b.__repr__(), 'Meet and eat by Tom (1 post)')
		self.assertEqual(b1.__repr__(), 'I have a dog by Mary P (2 posts)')
Пример #8
0
    def test_repr_multiple_posts(self):
        b = Blog("Test", "Test Author")
        b.posts = ["test"]
        b2 = Blog("My Day", "Rolf")
        b2.posts = ["test", "another"]

        self.assertEqual(b.__repr__(), "Test by Test Author (1 post)")
        self.assertEqual(b2.__repr__(), "My Day by Rolf (2 posts)")
Пример #9
0
    def test_repr_multiple_posts(self):
        b = Blog('Test', 'Test Author')
        b.posts = ['test']
        b2 = Blog('My Day', 'Rolf')
        b2.posts = ['test', 'another']

        self.assertEqual('Test by Test Author (1 post)', b.__repr__())
        self.assertEqual('My Day by Rolf (2 posts)', b2.__repr__())
Пример #10
0
    def test_repr_multiple_posts(self):
        b = Blog('Test', 'Test Author')
        b.posts = ['test']
        b2 = Blog('My Day', 'Eva')
        b2.posts = ['test', 'test2']

        self.assertEqual(b.__repr__(), 'Test by Test Author (1 post)')
        self.assertEqual(b2.__repr__(), 'My Day by Eva (2 posts)')
Пример #11
0
    def test_repr_multiple_posts(self):
        b = Blog('Test', 'Test Author')
        b.posts = ['test']
        b2 = Blog('My day', 'Athenkosi')
        b2.posts = ['test', 'Another']

        self.assertEqual(b.__repr__(), 'Test by Test Author (1 post)')
        self.assertEqual(b2.__repr__(), 'My day by Athenkosi (2 posts)')
Пример #12
0
    def test_repr_multiple_post(self):
        b = Blog('Test', 'Test Author')
        b.posts = ['test']
        b2 = Blog('My Day', 'Brian')
        b2.posts = ['test', 'another']

        self.assertEqual(b.__repr__(), 'Test by Test Author (1 post)')
        self.assertEqual(b2.__repr__(), 'My Day by Brian (2 posts)')
Пример #13
0
    def test_repr(self):
        blog = Blog('Title', 'Author')
        self.assertEqual(blog.__repr__(), 'Title by Author, 0 posts currently')

        blog.posts.append('Post_one')
        self.assertEqual(blog.__repr__(), 'Title by Author, 1 post currently')

        blog.posts.append('Post_two')
        self.assertEqual(blog.__repr__(), 'Title by Author, 2 posts currently')
Пример #14
0
    def test_repr_multiple_post(self):
        b = Blog('Test', 'Test Author')
        b.posts = ['test post']

        self.assertEqual(b.__repr__(), 'Test by Test Author (1 post)')

        b2 = Blog('My Dad', 'Rolf')
        b2.posts = ['post1', 'post2']
        self.assertEqual(b2.__repr__(), 'My Dad by Rolf (2 posts)')
Пример #15
0
    def test__repr__with_multiple_posts(self):
        b = Blog("Test", "Test Author")
        b.posts = ["Test post"]

        self.assertEqual(b.__repr__(), "Blog Test by Test Author (1 post)")

        b.posts.append("Another test post")

        self.assertEqual(b.__repr__(), "Blog Test by Test Author (2 posts)")
    def test_repr_multiple_posts(self):
        b = Blog('Title', 'Test Author')
        b.posts = ['test']

        b2 = Blog('My Day', 'Rolf')
        b2.posts = ['test', 'another']

        self.assertEqual(b.__repr__(), ('{} by {} (1 post)'.format(b.title, b.author)))
        self.assertEqual(b2.__repr__(), ('{} by {} (2 posts)'.format(b2.title, b2.author)))
Пример #17
0
    def test_multiple_repr(self):
        b = Blog('Test Blog', 'Manuel')
        b.posts = ['test']

        self.assertEqual("Test Blog by Manuel (1 post)", b.__repr__())

        b2 = Blog("my blog", 'Jordi')
        b2.posts = ['foo', 'bar']
        self.assertEqual("my blog by Jordi (2 posts)", b2.__repr__())
Пример #18
0
    def test_repr_multiple_posts(self):
        b = Blog("Název", "autor")
        b.posts = ["test"]

        b2 = Blog("Název2", "autor2")
        b2.posts = ["test1", "test2"]

        self.assertEqual(b.__repr__(), "Název by autor (1 post)")
        self.assertEqual(b2.__repr__(), "Název2 by autor2 (2 posts)")
Пример #19
0
    def test_reprr_multiple_posts(self):
        b = Blog("Title blog", "Author blog")
        b.posts = ['test']
        b2 = Blog("John title", "Oliver author")
        b2.posts = ["test", "another"]

        self.assertEqual(b.__repr__(), "Title blog by Author blog (1 posts)")
        self.assertEqual(b2.__repr__(),
                         "John title by Oliver author (2 posts)")
Пример #20
0
    def test_repr_multi_posts(self):
        new_blog = Blog("Test Title", "Test Author")
        new_blog.posts = ["test post"]
        my_blog = Blog("Calvin's Blog", "Calvin T")
        my_blog.posts = ["A day in the life", "How I set up projects", "Last Day"]


        self.assertEqual(new_blog.__repr__(), "Test Title by Test Author (1 post)")
        self.assertEqual(my_blog.__repr__(), "Calvin's Blog by Calvin T (3 posts)")
Пример #21
0
    def test_repr_multiple_posts(self):
        b = Blog('Test', 'Test Author')
        b.posts = ['Test Post']

        b2 = Blog('My Days', 'Julie')
        b2.posts = ['Test', 'Another post']

        self.assertEqual(b.__repr__(), 'Test by Test Author (1 post)')
        self.assertEqual(b2.__repr__(), 'My Days by Julie (2 posts)')
Пример #22
0
    def test_post(self):
        b = Blog('Test', 'Test Author')
        b.create_post('Test Post Title', 'Test Post Content')

        b2 = Blog('Generic', 'Generic Author')

        self.assertEqual(b.__repr__(),
                         '<title: Test, author: Test Author, posts: 1>')
        self.assertEqual(b2.__repr__(),
                         '<title: Generic, author: Generic Author, posts: 0>')
Пример #23
0
    def test_createdPost(self):
        b = Blog('BookName1','sem')
        b1 = Blog('BookName2','kamlesh')
        b1.post = ['1_post']
        b2 = Blog('BookName3','aman')
        b2.post = ['1_post','2_post']

        self.assertEqual(b.__repr__(),"BookName1 is test by sem(0 posts)")
        self.assertEqual(b1.__repr__(),"BookName2 is test by kamlesh(1 posts)")
        self.assertEqual(b2.__repr__(),"BookName3 is test by aman(2 posts)")
Пример #24
0
 def test_repr(self):
     new_blog = Blog("My Test Blog", "Amazing Anonym Author")
     self.assertEqual(new_blog.__repr__(),
                      "My Test Blog by Amazing Anonym Author - 0 Posts")
     new_blog.posts = ["This is a test Post"]
     self.assertEqual(new_blog.__repr__(),
                      "My Test Blog by Amazing Anonym Author - 1 Post")
     new_blog.posts = ["This is a test Post", "This is another test post"]
     self.assertEqual(new_blog.__repr__(),
                      "My Test Blog by Amazing Anonym Author - 2 Posts")
Пример #25
0
    def test_multiple_post_repr(self):
        blog_object = Blog('test_title', 'test_author')
        blog_object.posts = ['post']

        blog_object2 = Blog('test_title', 'test_author')
        blog_object2.posts = ['post1', 'post2']

        self.assertEqual(blog_object.__repr__(),
                         'test_title by test_author (1 post)')
        self.assertEqual(blog_object2.__repr__(),
                         'test_title by test_author (2 posts)')
Пример #26
0
 def test_repr_multiple_post(self):
     b = Blog("Test", "Test Author")
     b.posts = ['test']
     b2 = Blog("My Day", "John")
     b2.posts = ['test', 'test2']
     self.assertEqual(
         b.__repr__(), 'Test by Test Author ({} post{})'.format(
             len(b.posts), 's' if len(b.posts) != 1 else ''))
     self.assertEqual(
         b2.__repr__(), 'My Day by John ({} post{})'.format(
             len(b2.posts), 's' if len(b2.posts) != 1 else ''))
Пример #27
0
    def test_repr(self):
        blog_object = Blog('test_title', 'test_author')
        blog_object2 = Blog('Life is sucks', 'Ajmal Hussain')

        # Here we didn't set any blog title or author name yet. but we will. Now with _repr_() method we will check the blog post title and
        # author name (the string representation of it) directly without assigning any arguments or variable.
        # This is called TDD. Think it before you make it.
        #self.assertEqual(blog_object.__repr__(),'Test title by Test Author (0 posts)') # In the second arguments we pass the string or anything what we will want to pass in the repr() method but at first we will put it here. That is how TDD works.
        self.assertEqual(blog_object.__repr__(),
                         'test_title by test_author (0 posts)')
        self.assertEqual(blog_object2.__repr__(),
                         'Life is sucks by Ajmal Hussain (0 posts)')
Пример #28
0
    def test_repr(self):
        """
        Test for __repr__ method
        """
        b_1 = Blog('Test title', 'Test author')
        b_1.posts = ['One']

        b_2 = Blog('Test title2', 'Test author2')
        b_2.posts = ['One', 'Two']

        self.assertEqual(b_1.__repr__(), "Test title by Test author (1 post)")
        self.assertEqual(b_2.__repr__(),
                         "Test title2 by Test author2 (2 posts)")
Пример #29
0
 def test_repr(self):
     b = Blog("Test Title", "Test Author")
     b2 = Blog("How my life has been", "Neto")
     self.assertEqual("Test Title, by Test Author (0 posts)", b.__repr__(),
                      "The result of the method is not"
                      "correct")
     # This is the base of what TDD is: It's to create a test that will fail, but that sort of conveys what you want
     # to do (In case you create this test before implementing the method).
     self.assertEqual("How my life has been, by Neto (0 posts)",
                      b2.__repr__(), "The result of the method is not"
                      "correct")
     b3 = Blog("Testing 3 posts", "Neto")
     b3.posts = ["Testing", "Multiple", "Posts"]
     self.assertEqual("Testing 3 posts, by Neto (3 posts)", b3.__repr__(),
                      "The result of the method is not correct")
Пример #30
0
    def test_repr(self):
        b = Blog('Test title', 'Test author')
        b.posts = ['test post']
        b2 = Blog('My Day', 'Rolf')
        b2.posts = ['test post', 'test 2']

        self.assertEqual(b.__repr__(), 'Test title by Test author (1 post )')