Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmajetich committed Feb 19, 2020
2 parents 18e53c8 ff42f69 commit b448d74
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions console.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 228,10 @@ def do_count(self, args):
count = 1
print(count)

def help_count(self):
""" """
print("Usage: count <class_name>")

def do_update(self, args):
""" Updates a certain object with new info """
c_name = c_id = att_name = att_val = kwargs = ''
Expand Down
30 changes: 30 additions & 0 deletions tests/test_console.py
Original file line number Diff line number Diff line change
@@ -0,0 1,30 @@
#!/usr/bin/python3
import unittest
from unittest.mock import patch
from io import StringIO
from console import HBNBCommand
""" Module for console tests """


class test_console(unittest.TestCase):
""" Tests for the console """

def test_help(self):
with unittest.mock.patch('sys.stdout', new=StringIO()) as f:
HBNBCommand().onecmd("help")
c = f.getvalue()
self.assertEqual(c, f.getvalue())

def test_create(self):
with unittest.mock.patch('sys.stdout', new=StringIO()) as f:
HBNBCommand().onecmd("create BaseModel")
c = f.getvalue()
self.assertEqual(c, f.getvalue())

def test_show(self):
with unittest.mock.patch('sys.stdout', new=StringIO()) as f:
HBNBCommand().onecmd("create BaseModel")
c = f.getvalue()
HBNBCommand().onecmd("update BaseModel {}".format(c))
c = f.getvalue()
self.assertEqual(c, f.getvalue())

0 comments on commit b448d74

Please sign in to comment.