Beispiel #1
0
    def test_get_user(self):
        # Positive
        db = AmmDB(password)
        passwd = b'$2b$12$Z2OaKVc39OH6duIxaKFnkefKztlq7oPiYpzdNHfSwQDvBRfFjVCJ6'
        observed = db.get_user(9,
                               fn='test',
                               email='*****@*****.**',
                               phone='5555555555',
                               ln='test',
                               uname='test',
                               operator='AND',
                               exact=False)
        expected = ({
            'suspension': None,
            'admin': 0,
            'uname': 'test',
            'passwd': passwd,
            'email': '*****@*****.**',
            'id': 9,
            'phone': '5555555555',
            'fn': 'test',
            'ln': 'test'
        }, )
        self.assertEqual(observed, expected)

        # Negative
        observed = db.get_user('-1', 'bad', '*****@*****.**', '-11111111', 'bad',
                               'bad', 'AND', False)
        expected = ()
        self.assertEqual(observed, expected)
Beispiel #2
0
    def test_edit_user(self):
        # Positive
        db = AmmDB(password)
        passwd = b'$2b$12$Z2OaKVc39OH6duIxaKFnkefKztlq7oPiYpzdNHfSwQDvBRfFjVCJ6'
        #random.seed()
        #randomfn = random.randint(1, 100)
        #randomln = random.randint(1, 100)
        db.edit_user(9, '*****@*****.**', 'test', 'test', passwd, '5555555555')
        observed = db.get_user(9, 'test', '*****@*****.**', '5555555555',
                               'test', 'test')
        expected = ({
            'admin': 0,
            'email': '*****@*****.**',
            'fn': 'test',
            'id': 9,
            'ln': 'test',
            'passwd':
            b'$2b$12$Z2OaKVc39OH6duIxaKFnkefKztlq7oPiYpzdNHfSwQDvBRfFjVCJ6',
            'phone': '5555555555',
            'suspension': None,
            'uname': 'test'
        }, )
        self.assertEqual(observed, expected)

        # Negative, trying to edit a user that does not exist
        db.edit_user(0, '*****@*****.**', 'test', 'test', passwd, '5555555555')
        observed = db.get_user(0, 'test', '*****@*****.**', '5555555555',
                               'test', 'test')
        expected = ()
        self.assertEqual(observed, expected)
Beispiel #3
0
    def test_get_user(self):
        # Positive
        db = AmmDB(self.password)
        passwd = b'$2b$12$Z2OaKVc39OH6duIxaKFnkefKztlq7oPiYpzdNHfSwQDvBRfFjVCJ6'
        observed = db.get_user(9, fn='test', email='*****@*****.**', phone='5555555555', ln='test', uname='test', operator='AND', exact=False)
        expected = ({'suspension': None, 'admin': 0, 'uname': 'test', 'passwd': passwd, 'email': '*****@*****.**', 'id': 9, 'phone': '5555555555', 'fn': 'test', 'ln': 'test'},)
        self.assertEqual(observed, expected)

        # Negative
        observed = db.get_user('-1', 'bad', '*****@*****.**', '-11111111', 'bad', 'bad', 'AND', False)
        expected = ()
        self.assertEqual(observed, expected)
Beispiel #4
0
    def test_edit_user(self):
        # Positive
        db = AmmDB(self.password)
        passwd=b'$2b$12$Z2OaKVc39OH6duIxaKFnkefKztlq7oPiYpzdNHfSwQDvBRfFjVCJ6'
        #random.seed()
        #randomfn = random.randint(1, 100)
        #randomln = random.randint(1, 100)
        db.edit_user(9, '*****@*****.**', 'test', 'test', passwd, '5555555555')
        observed = db.get_user(9, 'test', '*****@*****.**', '5555555555', 'test', 'test')
        expected = ({'admin': 0,'email': '*****@*****.**','fn': 'test','id': 9,'ln': 'test','passwd': b'$2b$12$Z2OaKVc39OH6duIxaKFnkefKztlq7oPiYpzdNHfSwQDvBRfFjVCJ6','phone': '5555555555','suspension': None,'uname': 'test'},)
        self.assertEqual(observed, expected)

        # Negative, trying to edit a user that does not exist
        db.edit_user(0, '*****@*****.**', 'test', 'test', passwd, '5555555555')
        observed = db.get_user(0, 'test', '*****@*****.**', '5555555555', 'test', 'test')
        expected = ()
        self.assertEqual(observed, expected)
Beispiel #5
0
 def test_add_user(self):
     # Positive
     db = AmmDB()
     db.add_user('test', '*****@*****.**', 'test', 'test', 'test', 0, '1234567890')
     passwd = b'$2b$12$Z2OaKVc39OH6duIxaKFnkefKztlq7oPiYpzdNHfSwQDvBRfFjVCJ6'
     observed = db.get_user(9, 'test', '*****@*****.**', '1234567890', 'test', 'test', 'AND', False)
     expected = ({'suspension': None, 'admin': 0, 'email': '*****@*****.**', 'uname': 'test', 'passwd': passwd, 'id': 9, 'phone': '1234567890', 'ln': 'test', 'fn': 'test'},)
     self.assertEqual(observed, expected)