def test_get_activity(self): # Positive db = AmmDB(self.password) observed = db.get_activity(1, 'testName', 4, 1, 3, 1, 25, 9, 'AND') expected = ({'id': 1, 'name': 'testName', 'numplayers': 3, 'available': 1, 'skill': 4, 'category': 25, 'longitude': Decimal('0.0000'), 'datetime': datetime.datetime(2017, 4, 13, 18, 36, 49), 'private': 0, 'latitude': Decimal('0.0000'), 'leader': 9, 'duration': 1},) self.assertEqual(observed, expected) # Negative observed = db.get_activity(0, 'badName', 4, 1, 3, 1, 25, 9, 'AND') expected = () self.assertEqual(observed, expected)
def test_add_activity(self): # Positive # Add user db = AmmDB(password) dur = random.randint(0, 10000) skil = random.randint(0, 4) nplayers = random.randint(0, 10000) db.add_activity('test_activity', skil, datetime.datetime(2017, 4, 13, 18, 36, 49), dur, nplayers, 0, 1, 25, 9, Decimal('0.0000'), Decimal('0.0000')) observed = db.get_activity(name='test_activity', skill=skil, duration=dur, numplayers=nplayers, category=25, available=1) #We have no way of determining id from add activity so we cannot check this against expected del (observed[0])['id'] expected = ({ 'available': 1, 'category': 25, 'datetime': datetime.datetime(2017, 4, 13, 18, 36, 49), 'duration': dur, 'latitude': Decimal('0.0000'), 'leader': 9, 'longitude': Decimal(0.0000), 'name': 'test_activity', 'numplayers': nplayers, 'private': 0, 'skill': skil }, ) self.assertEqual(observed, expected)
def test_add_activity(self): # Positive # Add user db = AmmDB(self.password) dur = random.randint(0, 10000) skil = random.randint(0,4) nplayers = random.randint(0, 10000) db.add_activity('test_activity', skil, datetime.datetime(2017, 4, 13, 18, 36, 49), dur, nplayers, 0, 1, 25, 9, Decimal('0.0000'), Decimal('0.0000')) observed = db.get_activity(name='test_activity', skill=skil, duration=dur, numplayers=nplayers, category=25, available=1) #We have no way of determining id from add activity so we cannot check this against expected del (observed[0])['id'] expected = ({'available': 1, 'category': 25, 'datetime': datetime.datetime(2017, 4, 13, 18, 36, 49), 'duration': dur, 'latitude': Decimal('0.0000'), 'leader': 9, 'longitude': Decimal(0.0000), 'name': 'test_activity', 'numplayers': nplayers, 'private': 0, 'skill': skil},) self.assertEqual(observed, expected)