def stats(): """This route returns a json codified message """ return jsonify(amenities=storage.count("Amenity"), reviews=storage.count("Review"), states=storage.count("State"), users=storage.count("User"), places=storage.count("Place"))
def test_count_amenity(self): """Tests if returns the right quantity of elements""" num_objs = storage.count(Amenity) new_obj = Amenity(name="WiFi") new_obj.save() new_num_objs = storage.count(Amenity) self.assertEqual(num_objs, new_num_objs - 1, "Count not equal")
def stats(): all_objs = { 'reviews': storage.count('Review'), 'recipes': storage.count('Recipe'), 'users': storage.count('User') } return jsonify(all_objs)
def test_count(self): """ test count for db storage """ x = storage.count(State) state = State(name="Antioquia") state.save() y = storage.count(State) self.assertTrue((x + 1) == y)
def test_count_state(self): """Tests if returns the right quantity of elements""" num_objs = storage.count(State) new_obj = State(name="EstadoDePrueba") new_obj.save() new_num_objs = storage.count(State) self.assertEqual(num_objs, new_num_objs - 1, "Count not equal")
def test_count(self): """ test to check count method""" count_pre = storage.count(State) new_state = State(name="Georgia") new_state.save() count_post = storage.count(State) self.assertTrue((count_pre + 1) == count_post)
def test_count(self): """tests count""" pre = storage.count("Amenity") test_obj = Amenity(name="foo") storage.new(test_obj) post = storage.count("Amenity") self.assertEqual(pre + 1, post)
def stats(): """Returns states""" return jsonify({"amenities": storage.count("Amenity"), "places": storage.count("Place"), "reviews": storage.count("Review"), "states": storage.count("State"), "users": storage.count("User")})
def test_count_city(self): """Tests if returns the right quantity of elements""" num_objs = storage.count(City) new_obj = City(name="CiudadDePrueba", state_id=self.state_1.id) new_obj.save() new_num_objs = storage.count(City) self.assertEqual(num_objs, new_num_objs - 1, "Count not equal")
def test_count_user(self): """Tests if returns the right quantity of elements""" num_objs = storage.count(User) new_obj = User(name="User de prueba", email="b@b", password="******") new_obj.save() new_num_objs = storage.count(User) self.assertEqual(num_objs, new_num_objs - 1, "Count not equal")
def test_count(self): """ Test count method """ count = storage.count() u = State(name='Cartagena') storage.new(u) storage.save() count_state = storage.count(State) self.assertNotEqual(count, count_state)
def count_classes(): """ method to return a jsonified dictionary of stats. """ return jsonify({"musicplaylists ": storage.count("Musicplaylist"), "places": storage.count("Place"), "djs": storage.count("Dj"), "users": storage.count("User")})
def test_count(self): """ Test case for count method at state""" first_count = storage.count(State) dic_new_state = {'name': 'Valle'} new_obj = State(**dic_new_state) new_obj.save() second_count = storage.count(State) self.assertGreater(second_count, first_count)
def test_count_file_storage(self): """This test the get method in file_storage""" storage.reload() result = storage.all("") count = storage.count(None) self.assertEqual(len(result), count) result = storage.all("State") count = storage.count("State") self.assertEqual(len(result), count)
def count(self): """Test that save properly saves objects to file.json""" from models import storage count_all = len(storage.all()) count_states = len(storage.all(State)) n_s = State(name="Antioquia") n_s.save() self.assertEqual(storage.count(), count_all + 1) self.assertEqual(storage.count(State), count_states + 1)
def display_stats(): ''' Endpoint that retrieves the number of each object by type. ''' stats = { "users": storage.count("User"), "records": storage.count("Record") } return jsonify(stats)
def test_file_storage_count(self): """Tests the count method in file_storage""" storage.reload() res = storage.all("") count = storage.count(None) self.assertEqual(len(res), count) res = storage.all("State") count = storage.count("State") self.assertEqual(len(res), count)
def test_count(self): """Test count method""" from models import storage count_all = len(storage.all()) count_states = len(storage.all(State)) n_s = State(name="Nevada") n_s.save() self.assertEqual(storage.count(), count_all + 1) self.assertEqual(storage.count(State), count_states + 1)
def test_count_review(self): """Tests if returns the right quantity of elements""" num_objs = storage.count(Review) new_obj = Review(text="Review prueba", user_id=self.user_1.id, place_id=self.place_1.id) new_obj.save() new_num_objs = storage.count(Review) self.assertEqual(num_objs, new_num_objs - 1, "Count not equal")
def test_count(self): """Test that counts the number of objects in a class""" state = State(**{"name": "JennAndMichelleLand"}) state.save() city = City(**{"state_id": state.id, "name": "JennAndMichelleCity"}) city.save() self.assertIsInstance(storage.count(), int) self.assertIsInstance(storage.count(City), int) self.assertEqual(storage.count(), storage.count(None)) self.assertEqual(storage.count(City), 1)
def test_db_storage_count(self): ''' Check total count of objs in DBStorage ''' storage.reload() all_count = storage.count(None) self.assertIsInstance(all_count, int) cls_count = storage.count("State") self.assertIsInstance(cls_count, int) self.assertGreaterEqual(all_count, cls_count)
def test_storage_count(self): storage = FileStorage() initial_length = len(storage.all()) self.assertEqual(storage.count(), initial_length) state_len = len(storage.all("State")) self.assertEqual(storage.count("State"), state_len) new_state = State() new_state.save() self.assertEqual(storage.count(), initial_length + 1) self.assertEqual(storage.count("State"), state_len + 1)
def test_count(self): """ Test for the count method of database """ self.assertIsInstance(storage.count(), int) self.assertIsInstance(storage.count("State"), int) all_objects = storage.all() if all_objects: self.assertEqual(storage.count(), len(all_objects)) all_states = storage.all("State") if all_states: self.assertEqual(storage.count("State"), len(all_states))
def test_count_method(self): """ Test storage count method """ count_all = storage.count() count_state = storage.count(State) count_city = storage.count(City) new_state = State() new_state.name = "testing YOO" storage.new(new_state) storage.save() self.assertEqual(storage.count(State), count_state + 1)
def test_count_db_storage_no_class(self): ''' Tests the count method in db storage when no class is passed ''' storage.reload() first_count = storage.count() state = State(name="Colorado") state.save() second_count = storage.count() self.assertTrue(first_count + 1, second_count)
def test_count_db_storage_class(self): ''' Tests the count method in db storage when passing a class ''' storage.reload() first_count = storage.count("State") state = State(name="Illinois") state.save() second_count = storage.count("State") self.assertTrue(first_count + 1, second_count)
def test_count_method(self): """Test of the count method""" count = storage.count() len_all = len(storage.all()) state = State(name="Colorado") state.save() amenity = Amenity(name="Internet") amenity.save() self.assertEqual(len_all, count) self.assertIs(storage.count("User"), 0)
def test_count(self): """test count function""" from models import storage test = State(name="TEST") storage.new(test) storage.save() count_state = storage.count("State") count = storage.count() self.assertEqual(count, 1) self.assertEqual(count_state, 1)
def test_count_method(self): """Test of the count method""" count = storage.count() len_all = len(storage.all()) self.assertIs(count, len_all) state = State() state.save self.assertIs(storage.count(), len_all) self.assertEqual(storage.count("State"), len(storage.all("State"))) self.assertIs(storage.count("User"), 0)
def test_close(self): """ Tests the close method of filestorage """ self.assertIsInstance(storage.count(), int) self.assertIsInstance(storage.count("State"), int) all_objects = storage.all() if all_objects: self.assertEqual(storage.count(), len(all_objects)) all_states = storage.all("State") if all_states: self.assertEqual(storage.count("State"), len(all_states))