def test_public_attr(self): """Test if the attributes are publics""" self.assertEqual(str, type(State().id)) self.assertEqual(datetime, type(State().created_at)) self.assertEqual(datetime, type(State().updated_at)) self.assertEqual(str, type(State.name))
def setUp(self): """ To define instructions that will be executed before each test """ self.my_state = State()
def test_str_method(self): """test that each method is printing accurately""" s3 = State() s3printed = s3.__str__() self.assertEqual(s3printed, "[State] ({}) {}".format(s3.id, s3.__dict__))
def test_class(self): ''' Test to check the State class ''' state1 = State() self.assertEqual(state1.__class__.__name__, "State")
def test_1_class(self): """ creates instance of State""" class_State = State() self.assertEqual(class_State.__class__.__name__, "State")
def test_class_name(self): """Tests if class is named correctly""" state_example = State() self.assertEqual(state_example.__class__.__name__, "State")
def test_state(self): """test State creation with a keyword argument""" a = State(name="Kamchatka", id="Kamchatka666") a.save() self.assertIn("Kamchatka666", storage.all("State").keys())
def test_get(self): """ test get method file storage """ state = State(name="Neiva") state.save() neiva = storage.get(State, state.id) self.assertTrue(state.id == neiva.id)
def setUpClass(cls): """ Setup State Class """ cls.state = State() cls.state.name = "Cundinamarca"
def test_state(self): """Test attributes of Class State""" my_state = State() my_state.name = "Antioquia" self.assertEqual(my_state.name, 'Antioquia')
def setUpClass(cls): ''' new_state up ''' cls.new_state = State() cls.new_state.name = "Florida" cls.new_state.save() cls.new_state_str = cls.new_state.to_dict()
def test_no_args_instantiates(self): self.assertEqual(State, type(State()))
from rich import print from models.military import Military from models.state import State from utils.displays import display, clear_screen, display_stats, typewrtier_print from utils.prompts import mc_prompt from functions import show_alerts from choices import change_enlistment_scheme # instantiate the military! military = Military() # start game state (round counter, time played) state = State() def start(): clear_screen() while True: gameloop() def gameloop(): while True: # only break when a choice has been made successfully # when a choice has been made, the current "round loop" ends, and the next round starts clear_screen()
def setUp(self): """SetUp method""" self.file_storage = State()
def test_father(self): state1 = State() self.assertEqual(state1.__class__.__name__, "State")
def setUpClass(cls): cls.state1 = State() cls.state1.name = "CA_the_golden_state"
def test_get(self): """ test to check get method""" st = State(name="Antioquia") st.save() state_test = storage.get(State, st.id) self.assertTrue(st.id == state_test.id)
def setUpClass(cls): """Instances for testing on""" cls.s1 = State() cls.s1.name = "California"
def test_inheritance(self): """Tests if Class inherits from BaseModel""" state_example = State() self.assertTrue(issubclass(state_example.__class__, BaseModel))
def setUpClass(cls): """ test """ cls.state = State() cls.state.name = "Montevideo"
def test_is_an_instance(self): '''check if my_model is an instance of BaseModel''' my_state = State() self.assertIsInstance(my_state, State)
def test_dbs_get_method(self): """Test for get nethod""" s = State(name="Florida") s.save() self.assertEqual(models.storage.get("State", s.id), s)
def test_father(self): ''' Test to check if the class is a subclass from BaseModel ''' state1 = State() self.assertEqual(state1.__class__.__name__, "State")
def test_dbs_count_method(self): """test for count method""" count = models.storage.count("State") s = State(name="Florida") s.save() self.assertEqual(models.storage.count("State"), count + 1)
def test_2_class_father(self): """ tests is subclass""" class_State = State() self.assertTrue(issubclass(class_State.__class__, BaseModel))
def test_get(self): """ test to check the get method """ new_state = State(name="Chia") new_state.save() self.assertIs(new_state, storage.get("State", new_state.id))
def test_init_arg(self): """pass in arg to new instance""" s0 = State(12) self.assertEqual(type(s0).__name__, "State") self.assertFalse(hasattr(s0, "12"))
def setUp(self): """Set up method""" self.state1 = State() self.state2 = State()
def test_subclass(self): """test subclass""" s89 = State() self.assertTrue(isinstance(s89, BaseModel)) self.assertTrue(isinstance(s89, State))
def test_check_in_storage(self): """Check if the instance is in __objects""" self.assertIn(State(), models.storage.all().values())