Exemple #1
0
 def test_id_should_accept_integer_string(self):
     sport = Sport()
     sport.id = "1"
     self.ddbb.session.add(sport)
     self.ddbb.session.commit()
     sport = self.ddbb.session.query(Sport).filter(Sport.id == 1).one()
     self.assertEqual(1, sport.id)
Exemple #2
0
 def test_id_should_accept_integer_string(self):
     sport = Sport()
     sport.id = "1"
     self.ddbb.session.add(sport)
     self.ddbb.session.commit()
     sport = self.ddbb.session.query(Sport).filter(Sport.id == 1).one()
     self.assertEquals(1, sport.id)
Exemple #3
0
 def test_id_should_not_accept_none(self):
     sport = Sport()
     try:
         sport.id = None
     except(TypeError):
         pass
     else:
         self.fail()
Exemple #4
0
 def test_id_should_not_accept_non_integer_string(self):
     sport = Sport()
     try:
         sport.id = "1.1"
     except(ValueError):
         pass
     else:
         self.fail()
Exemple #5
0
 def test_remove_sport_should_error_when_sport_has_unknown_id(self):
     sport = Sport()
     sport.id = 100
     try:
         self.sport_service.remove_sport(sport)
     except(SportServiceException):
         pass
     else:
         self.fail()
Exemple #6
0
 def test_remove_sport_should_error_when_sport_has_unknown_id(self):
     sport = Sport()
     sport.id = 100
     try:
         self.sport_service.remove_sport(sport)
     except (SportServiceException):
         pass
     else:
         self.fail()
Exemple #7
0
 def test_remove_sport_should_remove_associated_entries(self):
     self.mock_ddbb.select.return_value = [[1]]
     sport = Sport()
     sport.id = 1
     delete_arguments = []
     def mock_delete(*args):
         delete_arguments.append(args) 
     self.mock_ddbb.delete = mock.Mock(wraps=mock_delete)
     self.sport_service.remove_sport(sport)
     self.assertEquals(("records", "sport=1"), delete_arguments[0])
Exemple #8
0
 def test_remove_sport_should_error_when_sport_has_unknown_id(self):
     self.mock_ddbb.select.return_value = []
     sport = Sport()
     sport.id = 100
     try:
         self.sport_service.remove_sport(sport)
     except(SportServiceException):
         pass
     else:
         self.fail()
Exemple #9
0
 def test_id_should_not_accept_non_integer_string(self):
     sport = Sport()
     try:
         sport.id = "test"
         self.ddbb.session.add(sport)
         self.ddbb.session.flush()
     except (IntegrityError, DataError, OperationalError):
         pass
     else:
         self.fail()
Exemple #10
0
 def test_id_should_not_accept_non_integer_string(self):
     sport = Sport()
     try:
         sport.id = "test"
         self.ddbb.session.add(sport)
         self.ddbb.session.flush()
     except (IntegrityError, DataError):
         pass
     else:
         self.fail()
Exemple #11
0
 def test_id_should_not_accept_non_integer_string(self):
     if self.ddbb.engine.name == 'mysql':
         self.skipTest('Not supported on Mysql 5.6')
     sport = Sport()
     try:
         sport.id = "test"
         self.ddbb.session.add(sport)
         self.ddbb.session.flush()
     except (IntegrityError, DataError, OperationalError):
         pass
     else:
         self.fail()
Exemple #12
0
 def test_store_sport_should_update_row_when_sport_has_id(self):
     def mock_select(table, columns, where):
         if columns == "id_sports":
             return [[1]]
         else:
             return [(1, u"", 0, 0, 0, "0")]
     self.mock_ddbb.select = mock.Mock(wraps=mock_select)
     sport = Sport()
     sport.id = 1
     sport.name = u"New name"
     self.sport_service.store_sport(sport)
     self.mock_ddbb.update.assert_called_with("sports",  "name,weight,met,max_pace,color",
                                              [u"New name", 0.0, None, None, "0000ff"], "id_sports=1")
Exemple #13
0
 def test_store_sport_should_error_when_existing_sport_has_duplicate_name(self):
     def mock_select(table, columns, where):
         if columns == pytrainer.core.sport._ID_COLUMN:
             return [[2]]
         else:
             return [(1, u"Test name", 0, 0.0, "0"), (2, u"New name", 0, 0.0, "0")]
     self.mock_ddbb.select = mock.Mock(wraps=mock_select)
     sport = Sport()
     sport.id = 1
     sport.name = u"New name"
     try:
         self.sport_service.store_sport(sport)
     except(SportServiceException):
         pass
     else:
         self.fail()
Exemple #14
0
 def test_remove_sport_should_delete_sport_with_specified_id(self):
     self.mock_ddbb.select.return_value = [[1]]
     sport = Sport()
     sport.id = 1
     self.sport_service.remove_sport(sport)
     self.mock_ddbb.delete.assert_called_with("sports", "id_sports=1")
Exemple #15
0
 def test_id_should_accept_integer_string(self):
     sport = Sport()
     sport.id = "1"
     self.assertEquals(1, sport.id)
Exemple #16
0
 def test_id_should_accept_integer(self):
     sport = Sport()
     sport.id = 1
     self.assertEquals(1, sport.id)