コード例 #1
0
 def setUp(self):
     self.cli = HBNBCommand()
     test_args = {'updated_at': datetime(2017, 2, 11, 23, 48, 34, 339879),
                  'id': 'd3da85f2-499c-43cb-b33d-3d7935bc808c',
                  'created_at': datetime(2017, 2, 11, 23, 48, 34, 339743),
                  'name': 'SELF.MODEL'}
     self.model = Amenity(**test_args)
     self.model.save()
コード例 #2
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_help_count(self):
     """ Test help count message """
     outputexpected = "Prints amount of instances of a class"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("help count"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #3
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_EOF_message(self):
     """ Test EOF message """
     outputexpected = "Exit the program"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("help EOF"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #4
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_exit(self):
     """Test to validate quit works."""
     with patch("sys.stdout", new=StringIO()) as o:
         self.assertTrue(HBNBCommand().onecmd("quit"))
コード例 #5
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_quit(self):
     """ checks if quit command is valid"""
     self.assertTrue(HBNBCommand().onecmd("quit"))
コード例 #6
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_eleven(self):
     """ Test task 11 """
     outputexpected = "** class doesn't exist **"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("all aasd"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #7
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_destroy_id_error(self):
     """ Test id error """
     outputexpected = "** no instance found **"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("destroy BaseModel asda231"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #8
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_destroy_only(self):
     """ Test test_destroy_only"""
     outputexpected = "** class name missing **"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("destroy"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #9
0
 def setUpClass(cls):
     """setup console class for test"""
     cls.cl = HBNBCommand()
コード例 #10
0
 def test_update(self):
     """ Tests console method """
     with patch('sys.stdout', new=StringIO()) as f:
         HBNBCommand().onecmd("update NOPE")
         self.assertEqual(f.getvalue(), "\n** class doesn't exist **\n")
コード例 #11
0
 def setUp(self):
     """ create instance global """
     self.instan = HBNBCommand()
コード例 #12
0
ファイル: test_console.py プロジェクト: kmerchan/AirBnB_clone
 def test_do_all(self):
     """ Tests all method """
     with patch('sys.stdout', new=StringIO()) as f:
         HBNBCommand().onecmd("create bad")
         self.assertEqual(f.getvalue(), "** class doesn't exist **\n")
コード例 #13
0
 def create(self):
     '''
         Create HBNBCommand()
     '''
     return HBNBCommand()
コード例 #14
0
    def test_do_create(self):
        """ Tests create method """
        # gets initial state count and place count
        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd("count State")
            state_count = int(f.getvalue())
        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd("count Place")
            place_count = int(f.getvalue())

        # checks error message if no class argument given
        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd("create")
            self.assertEqual(f.getvalue(), "** class name missing **\n")

        # checks error message if no class argument is invalid
        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd("create BadClassName")
            self.assertEqual(f.getvalue(), "** class doesn't exist **\n")

        # tests obj created successfully when first object
        HBNBCommand().onecmd("create State name=\"California\"")
        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd("count State")
            self.assertEqual(f.getvalue(), "{}\n".format(state_count + 1))
        storage.reload()

        # tests obj created successfully when not first
        HBNBCommand().onecmd("create State name=\"Nevada\"")
        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd("count State")
            self.assertEqual(f.getvalue(), "{}\n".format(state_count + 2))
        storage.reload()

        # creates State, City, and User
        # saves their ids to generate relationships for Place
        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd("create State name=\"Oklahoma\"")
            state_id = f.getvalue()
        storage.reload()

        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd(
                "create City name=\"Tulsa\" state_id={}".format(state_id))
            city_id = f.getvalue()
        storage.reload()

        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd(
                "create User name={} email={} password={}".format(
                    'Sean', '*****@*****.**', 'password'))
            user_id = f.getvalue()
        storage.reload()

        # tests obj created with different class (Place), saves id
        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd(
                "create Place name={} number_rooms=4 city_id={} user_id={}".
                format("\"My_little_house\"", city_id, user_id))
            p_id = f.getvalue()
            p_id = p_id[:-1]
        storage.reload()
        with patch('sys.stdout', new=StringIO()) as f:
            HBNBCommand().onecmd("count Place")
            self.assertEqual(f.getvalue(), "{}\n".format(place_count + 1))

        # checks that after do_create, obj exists in dictionary
        dict_key = "Place." + p_id
        print(p_id)
        all_obj = storage.all()
        self.assertIn(dict_key, all_obj.keys())

        # tests that underscores in value were changed to spaces
        self.assertEqual(all_obj.get(dict_key).name, "My little house")
コード例 #15
0
ファイル: test_console.py プロジェクト: Ripjawws/AirBnB_clone
 def create(self, server=None):
     """Creates HBNBCommand"""
     return HBNBCommand(stdin=self.mock_stdin, stdout=self.mock_stdout)
コード例 #16
0
 def setupClass(cls):
     """ will create an instance before the tests """
     cls.test_console = HBNBCommand()
コード例 #17
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_show_error(self):
     """ Test only show error """
     outputexpected = "** class doesn't exist **"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("show asd"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #18
0
 def create(self, server=None):
     '''freate console'''
     return(HBNBCommand(stdin=self.mock_stdin,
                        stdout=self.mock_stdout))
コード例 #19
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_destroy_class_only(self):
     """ Test only show """
     outputexpected = "** instance id missing **"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("destroy BaseModel"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #20
0
 def setUpClass(cls):
     """setup for the test"""
     cls.consol = HBNBCommand()
コード例 #21
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_update_class(self):
     """ Test update class error """
     outputexpected = "** class doesn't exist **"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("update asdas"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #22
0
 def setUpClass(cls):
     """
     Setup for unittest
     """
     cls.console = HBNBCommand()
コード例 #23
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_eleven_two(self):
     outputexpected = "*** Unknown syntax: asd.all()"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("asd.all()"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #24
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_help_destroy(self):
     """ Test help destroy message """
     outputexpected = "Deletes instances based on ID"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("help destroy"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #25
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_do_ni_idea(self):
     """all with errors"""
     with patch('sys.stdout', new=StringIO()) as f:
         HBNBCommand().onecmd("all()")
     msg = f.getvalue()[:-1]
     self.assertEqual(msg, "** class doesn't exist **")
コード例 #26
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_empty_line_and_enter(self):
     """ Test empty line """
     outputexpected = ""
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("\n"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #27
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
    def test_update_function(self):
        """ xxxxxdddddd """
        test1 = BaseModel()
        test1_id = test1.id
        test2 = User()
        test2_id = test2.id
        test3 = State()
        test3_id = test3.id
        test4 = City()
        test4_id = test4.id
        test5 = Amenity()
        test5_id = test5.id
        test6 = Place()
        test6_id = test6.id
        test7 = Review()
        test7_id = test7.id
        with patch("sys.stdout", new=StringIO()) as salida:
            HBNBCommand().onecmd('BaseModel.update("' + test1_id +
                                 '", {\'fn\': "facu", "age": 14, "w": 1.3})')
            self.assertTrue(hasattr(test1, 'fn'))
            self.assertTrue(hasattr(test1, 'age'))
            self.assertTrue(hasattr(test1, 'w'))
            HBNBCommand().onecmd("BaseModel.show(" + test1_id + ")")
            self.assertIn('facu', salida.getvalue())
            self.assertIn('14', salida.getvalue())
            self.assertIn('1', salida.getvalue())

        with patch("sys.stdout", new=StringIO()) as salida:
            HBNBCommand().onecmd('User.update("' + test2_id +
                                 '", {\'fn\': "mateo", "age": 21, "w": 18.7})')
            self.assertTrue(hasattr(test2, 'fn'))
            self.assertTrue(hasattr(test2, 'w'))
            HBNBCommand().onecmd("User.show(" + test2_id + ")")
            self.assertIn('mateo', salida.getvalue())
            self.assertIn('21', salida.getvalue())
            self.assertIn('18', salida.getvalue())

        with patch("sys.stdout", new=StringIO()) as salida:
            HBNBCommand().onecmd('State.update("' + test3_id +
                                 '", {\'fn\': "facu", "age": 14, "w": 1.3})')
            self.assertTrue(hasattr(test3, 'fn'))
            self.assertTrue(hasattr(test3, 'age'))
            self.assertTrue(hasattr(test3, 'w'))
            HBNBCommand().onecmd("State.show(" + test3_id + ")")
            self.assertIn('facu', salida.getvalue())
            self.assertIn('14', salida.getvalue())
            self.assertIn('1', salida.getvalue())

        with patch("sys.stdout", new=StringIO()) as salida:
            HBNBCommand().onecmd('City.update("' + test4_id +
                                 '", {\'fn\': "mateo", "age": 14, "w": 18.7})')
            self.assertTrue(hasattr(test4, 'fn'))
            self.assertTrue(hasattr(test4, 'w'))
            HBNBCommand().onecmd("City.show(" + test4_id + ")")
            self.assertIn('mateo', salida.getvalue())
            self.assertIn('14', salida.getvalue())
            self.assertIn('18', salida.getvalue())

        with patch("sys.stdout", new=StringIO()) as salida:
            HBNBCommand().onecmd('Amenity.update("' + test5_id +
                                 '", {\'fn\': "mateo", "age": 21, "w": 18.7})')
            self.assertTrue(hasattr(test5, 'fn'))
            self.assertTrue(hasattr(test5, 'w'))
            HBNBCommand().onecmd("Amenity.show(" + test5_id + ")")
            self.assertIn('mateo', salida.getvalue())
            self.assertIn('21', salida.getvalue())
            self.assertIn('18', salida.getvalue())

        with patch("sys.stdout", new=StringIO()) as salida:
            HBNBCommand().onecmd('Place.update("' + test6_id +
                                 '", {\'fn\': "facu", "age": 14, "w": 18.7})')
            self.assertTrue(hasattr(test6, 'fn'))
            self.assertTrue(hasattr(test6, 'w'))
            HBNBCommand().onecmd("Place.show(" + test6_id + ")")
            self.assertIn('facu', salida.getvalue())
            self.assertIn('14', salida.getvalue())
            self.assertIn('18', salida.getvalue())

        with patch("sys.stdout", new=StringIO()) as salida:
            HBNBCommand().onecmd('Review.update("' + test7_id +
                                 '", {\'fn\': "mateo", "age": 21, "w": 18.7})')
            self.assertTrue(hasattr(test7, 'fn'))
            self.assertTrue(hasattr(test7, 'w'))
            HBNBCommand().onecmd("Review.show(" + test7_id + ")")
            self.assertIn('mateo', salida.getvalue())
            self.assertIn('21', salida.getvalue())
            self.assertIn('18', salida.getvalue())
コード例 #28
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_sintax_error(self):
     """ Test sintax error """
     outputexpected = "*** Unknown syntax: asdas"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("asdas"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #29
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_help_all(self):
     """ Test help all message """
     outputexpected = "Prints all the str representation of the instances"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("help all"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #30
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_create_error_two(self):
     """ Test only create without class """
     outputexpected = "** class name missing **"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("create"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #31
0
ファイル: test_console.py プロジェクト: tomi1710/AirBnB_clone
 def test_help_create(self):
     """ Test help create message """
     outputexpected = "Creates instances of class"
     with patch("sys.stdout", new=StringIO()) as salida:
         self.assertFalse(HBNBCommand().onecmd("help create"))
         self.assertEqual(outputexpected, salida.getvalue().strip())
コード例 #32
0
class Test_Console(unittest.TestCase):
    """
    Test the console
    """

    def setUp(self):
        self.cli = HBNBCommand()
        test_args = {'updated_at': datetime(2017, 2, 11, 23, 48, 34, 339879),
                     'id': 'd3da85f2-499c-43cb-b33d-3d7935bc808c',
                     'created_at': datetime(2017, 2, 11, 23, 48, 34, 339743),
                     'name': 'SELF.MODEL'}
        self.model = Amenity(**test_args)
        self.model.save()

    def tearDown(self):
        self.cli.do_destroy("Amenity d3da85f2-499c-43cb-b33d-3d7935bc808c")

    def test_quit(self):
        with self.assertRaises(SystemExit):
            self.cli.do_quit(self.cli)

    # one test for db without time zone, one for file
    @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE', 'fs') != 'db', "db")
    def test_show_correct(self):
        with captured_output() as (out, err):
            self.cli.do_show("Amenity d3da85f2-499c-43cb-b33d-3d7935bc808c")
        output = out.getvalue().strip()
        self.assertFalse("2017, 2, 11, 23, 48, 91" in output)
        self.assertTrue('2017, 2, 11, 23, 48, 34' in output)

    @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE', 'fs') == 'db', "db")
    def test_show_correct(self):
        with captured_output() as (out, err):
            self.cli.do_show("Amenity d3da85f2-499c-43cb-b33d-3d7935bc808c")
        output = out.getvalue().strip()
        self.assertFalse("2017, 2, 11, 23, 48, 91, 339743" in output)
        self.assertTrue('2017, 2, 11, 23, 48, 34, 339743' in output)

    def test_show_error_no_args(self):
        with captured_output() as (out, err):
            self.cli.do_show('')
        output = out.getvalue().strip()
        self.assertEqual(output, "** class name missing **")

    def test_show_error_missing_arg(self):
        with captured_output() as (out, err):
            self.cli.do_show("Amenity")
        output = out.getvalue().strip()
        self.assertEqual(output, "** instance id missing **")

    def test_show_error_invalid_class(self):
        with captured_output() as (out, err):
            self.cli.do_show("Human 1234-5678-9101")
        output = out.getvalue().strip()
        self.assertEqual(output, "** class doesn't exist **")

    def test_show_error_class_missing(self):
        with captured_output() as (out, err):
            self.cli.do_show("d3da85f2-499c-43cb-b33d-3d7935bc808c")
        output = out.getvalue().strip()
        self.assertEqual(output, "** instance id missing **")

    def test_create_no_arg(self):
        with captured_output() as (out, err):
            self.cli.do_create('')
        output = out.getvalue().strip()
        self.assertEqual(output, "** class name missing **")

    @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE', 'fs') == 'db', "db")
    def test_create_with_FS(self):
        with captured_output() as (out, err):
            self.cli.do_create("Amenity")
        output = out.getvalue().strip()

        with captured_output() as (out, err):
            self.cli.do_show("Amenity {}".format(output))
        output2 = out.getvalue().strip()
        self.assertTrue(output in output2)

    def test_destroy_correct(self):
        test_args = {'updated_at': datetime(2017, 2, 12, 00, 31, 53, 331997),
                     'id': 'f519fb40-1f5c-458b-945c-2ee8eaaf4901',
                     'created_at': datetime(2017, 2, 12, 00, 31, 53, 331900),
                     'name': "TEST_DESTROY"}
        testmodel = Amenity(test_args)
        testmodel.save()
        self.cli.do_destroy("Amenity f519fb40-1f5c-458b-945c-2ee8eaaf4901")

        with captured_output() as (out, err):
            self.cli.do_show("Amenity f519fb40-1f5c-458b-945c-2ee8eaaf4901")
        output = out.getvalue().strip()
        self.assertEqual(output, "** no instance found **")

    def test_destroy_error_missing_id(self):
        with captured_output() as (out, err):
            self.cli.do_destroy("Amenity")
        output = out.getvalue().strip()
        self.assertEqual(output, "** instance id missing **")

    def test_destroy_error_class_missing(self):
        with captured_output() as (out, err):
            self.cli.do_destroy("d3da85f2-499c-43cb-b33d-3d7935bc808c")
        output = out.getvalue().strip()
        self.assertEqual(output, "** instance id missing **")

    def test_destroy_error_invalid_class(self):
        with captured_output() as (out, err):
            self.cli.do_destroy("Human d3da85f2-499c-43cb-b33d-3d7935bc808c")
        output = out.getvalue().strip()
        self.assertEqual(output, "** class doesn't exist **")

    def test_destroy_error_invalid_id(self):
        with captured_output() as (out, err):
            self.cli.do_destroy("Amenity " +
                                "f519fb40-1f5c-AAA-945c-2ee8eaaf4900")
        output = out.getvalue().strip()
        self.assertEqual(output, "** no instance found **")

    def test_all_correct(self):
        test_args = {'updated_at': datetime(2017, 2, 12, 00, 31, 53, 331997),
                     'id': 'f519fb40-1f5c-458b-945c-2ee8eaaf4900',
                     'created_at': datetime(2017, 2, 12, 00, 31, 53, 331900),
                     'name': "TEST_ALL_CORRECT"}
        testmodel = Amenity(test_args)
        testmodel.save()
        with captured_output() as (out, err):
            self.cli.do_all("")
        output = out.getvalue().strip()
        self.assertTrue("d3da85f2-499c-43cb-b33d-3d7935bc808c" in output)
        self.assertTrue("f519fb40-1f5c-458b-945c-2ee8eaaf4900" in output)
        self.assertFalse("123-456-abc" in output)

    def test_all_correct_with_class(self):
        with captured_output() as (out, err):
            self.cli.do_all("Amenity")
        output = out.getvalue().strip()
        self.assertTrue(len(output) > 0)
        self.assertTrue("d3da85f2-499c-43cb-b33d-3d7935bc808c" in output)

    def test_all_error_invalid_class(self):
        with captured_output() as (out, err):
            self.cli.do_all("Human")
        output = out.getvalue().strip()
        self.assertEqual(output, "** class doesn't exist **")

    def test_update_correct(self):
        with captured_output() as (out, err):
            self.cli.do_update("Amenity " +
                               "d3da85f2-499c-43cb-b33d-3d7935bc808c name Bay")
        output = out.getvalue().strip()
        self.assertEqual(output, '')

        with captured_output() as (out, err):
            self.cli.do_show("Amenity d3da85f2-499c-43cb-b33d-3d7935bc808c")
        output = out.getvalue().strip()
        self.assertTrue("Bay" in output)
        self.assertFalse("Ace" in output)

    def test_update_error_invalid_id(self):
        with captured_output() as (out, err):
            self.cli.do_update("Amenity 123-456-abc name Cat")
        output = out.getvalue().strip()
        self.assertEqual(output, "** no instance found **")

    def test_update_error_no_id(self):
        with captured_output() as (out, err):
            self.cli.do_update("Amenity name Cat")
        output = out.getvalue().strip()
        self.assertEqual(output, "** value missing **")

    def test_update_error_invalid_class(self):
        with captured_output() as (out, err):
            self.cli.do_update("Human " +
                               "d3da85f2-499c-43cb-b33d-3d7935bc808c name Cat")
        output = out.getvalue().strip()
        self.assertEqual(output, "** class doesn't exist **")

    def test_update_error_no_class(self):
        with captured_output() as (out, err):
            self.cli.do_update("d3da85f2-499c-43cb-b33d-3d7935bc808c name Cat")
        output = out.getvalue().strip()
        self.assertEqual(output, "** value missing **")

    def test_update_error_missing_value(self):
        with captured_output() as (out, err):
            self.cli.do_update("Amenity " +
                               "d3da85f2-499c-43cb-b33d-3d7935bc808c name")
        output = out.getvalue().strip()
        self.assertEqual(output, "** value missing **")

    def test_state_argument(self):
        with captured_output() as (out, err):
            self.cli.do_create('State name="WEIRD"')
        with captured_output() as (out, err):
            self.cli.do_all("State")
        output = out.getvalue().strip()
        self.assertTrue("WEIRD" in output)

    def test_city_2_arguments(self):
        with captured_output() as (out, err):
            self.cli.do_create('State name="Arizona"')
        output = out.getvalue().strip()
        with captured_output() as (out, err):
            self.cli.do_create('City state_id="{}" name="Fremont"'.format(
                output))

    def test_city_2_arguments_space(self):
        with captured_output() as (out, err):
            self.cli.do_create('State name="Arizona"')
        output = out.getvalue().strip()
        with captured_output() as (out, err):
            self.cli.do_create('City state_id="{}" name="Alpha_Beta"'.format(
                output))
        output = out.getvalue().strip()
        with captured_output() as (out, err):
            self.cli.do_show('City {}'.format(output))
        output = out.getvalue().strip()
        self.assertTrue("Alpha Beta" in output)

    def test_place(self):
        with captured_output() as (out, err):
            self.cli.do_create('State name="Another_State"')
        state_id = out.getvalue().strip()
        with captured_output() as (out, err):
            self.cli.do_create('City state_id="{}" name="Alpha_Beta"'.format(
                state_id))
        city_id = out.getvalue().strip()
        with captured_output() as (out, err):
            self.cli.do_create('User email="*****@*****.**" password="******" '
                               'first_name="John" last_name="Doe"')
        user_id = out.getvalue().strip()
        with captured_output() as (out, err):
            self.cli.do_create('Place city_id="{}" user_id="{}"'
                               ' name="My_house"'
                               ' description="no_description_yet"'
                               ' number_rooms=4 number_bathrooms=1 max_guest=3'
                               ' price_by_night=100 latitude=120.12'
                               ' longitude=101.4'.format(city_id, user_id))
        output = out.getvalue().strip()
        with captured_output() as (out, err):
            self.cli.do_show('Place {}'.format(output))
        output = out.getvalue().strip()
        self.assertTrue("My house" in output)
        self.assertTrue("100" in output)
        self.assertTrue("120.12" in output)