Exemplo n.º 1
0
 def test_2_board_create(self):
     """Test. The creation of a board."""
     headers = {"UserName": "******", "UserSecret": "456"}
     x = (({
         "title": 'New board',
         "columns": ["ToDo", "InProgress", "Done"]
     }, {
         "status": "The board is created."
     }), ({
         "itle": 'New board',
         "columns": ["ToDo", "InProgress", "Done"]
     }, {
         "status": "Invalid request form 'data' of client."
     }), ({
         "title": 'New board',
         "columns": ["ToDo", "InProgress", "Done"]
     }, {
         'status': 'This a board already exist.'
     }))
     for value in x:
         data, extended = value
         with app.test_client() as client:
             request = client.post('api/v1/board/create',
                                   headers=headers,
                                   json=data)
             with self.subTest(x=value):
                 self.assertEqual(request.json, extended)
Exemplo n.º 2
0
    def test_write_message_3(self):
        """ /write_message/ Save massage in BD  
            not valid json(time) """
        test_time_1 = {
            "password": "******",
            "message": "Hi kik!",
            "whom": "test_kik",
            "data": "1589871051.0788183"
        }
        test_time_2 = {
            "password": "******",
            "message": "Hi kik!",
            "whom": "test_kik",
            "data": 15898710510788183
        }
        test_time_3 = {
            "password": "******",
            "message": "Hi kik!",
            "whom": "test_kik",
            "data": [1, 2, 3]
        }

        x = (test_time_1, test_time_2, test_time_3)
        for sent in x:
            with app.test_client() as client:
                relult = client.post('/api/v2/test_bob/write_message/',
                                     json=sent)
                with self.subTest(sent):
                    self.assertEqual(relult.json, {
                        "status": False,
                        "info": "incorrect json (time)"
                    })
Exemplo n.º 3
0
 def test_7_card_delete(self):
     """Test. The creation test of a new card.The test of remove the card."""
     headers = {"UserName": "******", "UserSecret": "456"}
     x = (({
         "itle": "Card 1",
         "board": "New board"
     }, {
         "status": "Invalid request form 'data' of client."
     }), ({
         "title": "Some kind of card",
         "board": "New board"
     }, {
         "status": "The card does not exist."
     }), ({
         "title": "Card 1",
         "board": "New board"
     }, {
         "status": "The card is removed."
     }))
     for value in x:
         data, extended = value
         with app.test_client() as client:
             request = client.post('api/v1/card/delete',
                                   headers=headers,
                                   json=data)
             with self.subTest(x=value):
                 self.assertEqual(request.json, extended)
Exemplo n.º 4
0
 def test_3_board_list(self):
     """Test. Get all boards."""
     headers = {"UserName": "******", "UserSecret": "456"}
     with app.test_client() as client:
         request = client.post('api/v1/board/list', headers=headers)
         resp_dict = {'count': None}
         resp_dict['count'] = request.json['count']
         self.assertEqual(resp_dict, {'count': '1'})
Exemplo n.º 5
0
 def test_registration_1(self):
     """ create 2 new users """
     test_bob = {"login": "******", "password": "******"}
     test_kik = {"login": "******", "password": "******"}
     x = (test_bob, test_kik)
     for sent in x:
         with app.test_client() as client:
             relult = client.post('api/v2/registration/', json=sent)
Exemplo n.º 6
0
 def test_check_message_2(self):
     """ /check_message/ for urser """
     with app.test_client() as client:
         sent = {"not_password": '******'}
         relult = client.post('/api/v2/test_kik/check_message/', json=sent)
         self.assertEqual(relult.json, {
             "status": False,
             "info": "incorrect json"
         })
Exemplo n.º 7
0
 def test_registration_2(self):
     """ json not correct  """
     sent = {"logmn": "bob", "pakword": 123}
     with app.test_client() as client:
         relult = client.post('api/v2/registration/', json=sent)
         self.assertEqual(relult.json, {
             'info': 'incorrect data',
             'status': False
         })
Exemplo n.º 8
0
 def test_authentication_3(self):
     """ /authentication/ Not user in the system """
     sent = {"pakword": "123"}
     with app.test_client() as client:
         relult = client.post('/api/v2/nott_bob/authentication/', json=sent)
         self.assertEqual(relult.json, {
             'info': 'incorrect data',
             'status': False
         })
Exemplo n.º 9
0
 def test_is_login_3(self):
     """ /is_login/ If json is not correct """
     with app.test_client() as client:
         sent = {"abrktl": 'notlogin'}
         relult = client.post('/api/v2/is_login/', json=sent)
         self.assertEqual(relult.json, {
             'info': 'incorrect data',
             'status': False
         })
Exemplo n.º 10
0
 def test_get_user(self):
     latitude = 48.704578
     longitude = 44.507112
     radius = 50
     sent = {"latitude": latitude, "longitude": longitude, "radius": radius}
     url = r'/api/v0.1/get_users'
     with app.test_client() as client:
         relult = client.post(url, json=sent)
         self.assertIsInstance(relult.json['users'], list)
Exemplo n.º 11
0
 def test_is_whom_3(self):
     """ /is_whom_login/ If json not correct """
     with app.test_client() as client:
         sent = {"not_password": "******", "whom": 'not_test_kik'}
         relult = client.post('/api/v2/test_bob/is_whom_login/', json=sent)
         self.assertEqual(relult.json, {
             "status": False,
             "info": "incorrect data"
         })
Exemplo n.º 12
0
 def test_add_user2(self):
     """Not enough parameters for json."""
     latitude = 55.753960
     sent = {"latitude": latitude}
     url = r'/api/v0.1/add_user'
     with app.test_client() as client:
         relult = client.post(url, json=sent)
         self.assertEqual(relult.json, {
             'info': 'invalid json',
             'status': False
         })
Exemplo n.º 13
0
 def test_add_user1(self):
     """Correct data submitted."""
     latitude = 55.753960
     longitude = 37.620393
     sent = {"latitude": latitude, "longitude": longitude}
     url = r'/api/v0.1/add_user'
     with app.test_client() as client:
         relult = client.post(url, json=sent)
         self.assertEqual(relult.json, {
             'info': 'user added successfully',
             'status': True
         })
Exemplo n.º 14
0
 def test_write_message_1(self):
     """ /write_message/ Save massage in BD  
         valid json """
     sent = {
         "password": "******",
         "message": "Hi kik!",
         "whom": "test_kik",
         "data": 1589871051.0788183
     }
     with app.test_client() as client:
         relult = client.post('/api/v2/test_bob/write_message/', json=sent)
         self.assertEqual(relult.json, {'status': True})
Exemplo n.º 15
0
    def test_6_column_info(self):
        """Test. Этот отчет позволяет получить информацию о задачах, которые находятся в определенной
        колонке.

        """
        headers = {"UserName": "******", "UserSecret": "456"}
        x = (({
            "oard": "New board",
            "column": "ToDo",
            "assignee": "Username"
        }, {
            "status": "Invalid request form 'data' of client."
        }), ({
            "board": "New board",
            "column": "ToDo",
            "assignee": "Other name"
        }, {
            "status": "The information about these columns are absent."
        }))
        for value in x:
            data, extended = value
            with app.test_client() as client:
                request = client.post('api/v1/report/cards_by_column',
                                      headers=headers,
                                      json=data)
                with self.subTest(x=value):
                    self.assertEqual(request.json, extended)
        data = {"board": "New board", "column": "ToDo", "assignee": "Username"}
        with app.test_client() as client:
            request = client.post('api/v1/report/cards_by_column',
                                  headers=headers,
                                  json=data)
            resp_dict = {
                'assignee': request.json['assignee'],
                'board': request.json['board']
            }
            self.assertEqual(resp_dict, {
                'assignee': 'Username',
                'board': 'New board'
            })
Exemplo n.º 16
0
 def test_write_message_2(self):
     """ /write_message/ Save massage in BD  
         not valid json """
     sent = {
         "not_password": "******",
         "message": "Hi kik!",
         "not_whom": "test_kik",
         "data": 1589871051.0788183
     }
     with app.test_client() as client:
         relult = client.post('/api/v2/test_bob/write_message/', json=sent)
         self.assertEqual(relult.json, {
             "status": False,
             "info": "incorrect json"
         })
Exemplo n.º 17
0
 def test_update_user2(self):
     """Incorrect data transferred."""
     latitude = 55.753960
     longitude = 37.620393
     user_id = 3
     sent = {
         "latitude": latitude,
         "longitude": longitude,
         'qweewr': user_id
     }
     url = r'/api/v0.1/update_user'
     with app.test_client() as client:
         relult = client.post(url, json=sent)
         self.assertEqual(relult.json, {
             'info': 'invalid json',
             'status': False
         })
Exemplo n.º 18
0
    def test_update_user1(self):
        """The correct data has been
        submitted for updating.

        """
        latitude = 55.753960
        longitude = 37.620393
        user_id = 3
        sent = {
            "latitude": latitude,
            "longitude": longitude,
            'user_id': user_id
        }
        url = r'/api/v0.1/update_user'
        with app.test_client() as client:
            relult = client.post(url, json=sent)
            self.assertEqual(relult.json, {
                'info': 'data changed successfully',
                'status': True
            })
Exemplo n.º 19
0
 def test_1_get_all_users(self):
     """Test. It must get all the users."""
     x = (({
         "UserName": "******",
         "UserSecret": "456"
     }, ({
         'users': [{
             'username': '******'
         }]
     })), ({
         "UserNam": "Kop",
         "UserSecret": "456"
     }, ({
         "status": "Authentification Error."
     })), ({
         "UserName": "******",
         "serSecret": "456"
     }, ({
         "status": "Authentification Error."
     })), ({
         "": "Kop",
         "UserSecret": "456"
     }, ({
         "status": "Authentification Error."
     })), ({
         0: "Kop",
         "UserSecret": "456"
     }, ({
         "status": "Authentification Error."
     })))
     for value in x:
         inp_headers, extended = value
         with app.test_client() as client:
             request = client.post('api/v1/user/list', headers=inp_headers)
             with self.subTest(x=value):
                 self.assertEqual(request.json, extended)
Exemplo n.º 20
0
 def test_is_login_4(self):
     """ /is_login/ Use get instead post  """
     with app.test_client() as client:
         relult = client.get('/api/v2/is_login/')
         self.assertEqual(relult.json, None)
Exemplo n.º 21
0
 def test_is_login_2(self):
     """ /is_login/ If login is not in DB """
     with app.test_client() as client:
         sent = {"login": '******'}
         relult = client.post('/api/v2/is_login/', json=sent)
         self.assertEqual(relult.json, {'status': False})
Exemplo n.º 22
0
 def test_is_login_1(self):
     """ /is_login/ If login is in DB """
     with app.test_client() as client:
         sent = {"login": '******'}
         relult = client.post('/api/v2/is_login/', json=sent)
         self.assertEqual(relult.json, {'status': True})
Exemplo n.º 23
0
 def test_is_whom_2(self):
     """ /is_whom_login/ If user in not DB"""
     with app.test_client() as client:
         sent = {"password": "******", "whom": 'not_test_kik'}
         relult = client.post('/api/v2/test_bob/is_whom_login/', json=sent)
         self.assertEqual(relult.json, {"status": False})
Exemplo n.º 24
0
 def test_read_message_2(self):
     """ /read_message/ for urser no correct password """
     with app.test_client() as client:
         sent = {"password": ["not123"]}
         relult = client.post('/api/v2/test_kik/read_message/', json=sent)
         self.assertEqual(relult.json, {"status": False})
Exemplo n.º 25
0
 def test_read_message_1(self):
     """ /read_message/ for urser """
     with app.test_client() as client:
         sent = {"password": "******"}
         relult = client.post('/api/v2/test_kik/read_message/', json=sent)
         self.assertEqual(relult.json['status'], True)
Exemplo n.º 26
0
 def test_5_update_card(self):
     """Test. The creation test of a new card.The update test of a new card."""
     headers = {"UserName": "******", "UserSecret": "456"}
     x = (
         ({
             "title": "Card 1",
             "board": "New board",
             "status": "ToDo",
         }, {
             "status": "The card has updated."
         }),
         ({
             "title": "Card 1",
             "oard": "New board",
             "status": "ToDo",
         }, {
             "status": "Invalid request form 'data' of client."
         }),
         ({
             "title": "Card 1",
             "board": "New board",
             "status": "ToDo",
             "description": "New description",
             "assignee": "Username",
             "estimation": "7w"
         }, {
             "status": "The card has updated."
         }),
         ({
             "title": "Card 1",
             "board": "New board",
             "status": "ToDo",
             "description": "New description",
             "assignee": "Username",
             "estimation": "7P"
         }, {
             "status":
             "Invalid 'estimation'. Please repair the field 'estimation'."
         }),
         ({
             "title": "Card 1",
             "board": "Такой доски нет",
             "status": "ToDo",
         }, {
             "status": "The 'Board' and the 'title' have not match."
         }),
         ({
             "title": "Card 1",
             "board": "New board",
             "status": "Noooo",
             "description": "Need to check",
             "assignee": "Username",
             "estimation": "4hd"
         }, {
             "status":
             "Invalid 'estimation'. Please repair the field 'estimation'."
         }),
         ({
             "title": "Card 1",
             "board": "New board",
             "status": "Noooo",
             "description": "Need to check",
             "assignee": "Username",
             "estimation": "414"
         }, {
             "status":
             "Invalid 'estimation'. Please repair the field 'estimation'."
         }),
     )
     for value in x:
         data, extended = value
         with app.test_client() as client:
             request = client.post('api/v1/card/update',
                                   headers=headers,
                                   json=data)
             with self.subTest(x=value):
                 self.assertEqual(request.json, extended)
Exemplo n.º 27
0
 def test_check_message_1(self):
     """ /check_message/ for urser """
     with app.test_client() as client:
         sent = {"password": "******"}
         relult = client.post('/api/v2/test_kik/check_message/', json=sent)
         self.assertEqual(relult.json, {"status": True, 'counter': 1})
Exemplo n.º 28
0
 def test_authentication_1(self):
     """ /authentication/ User is in the system """
     sent = {"password": "******"}
     with app.test_client() as client:
         relult = client.post('/api/v2/test_bob/authentication/', json=sent)
         self.assertEqual(relult.json, {'status': True})
Exemplo n.º 29
0
    def test_4_card_create(self):
        """Test. The creation test of a new card.
        
        The problem in logic: if "status","description","assignee",
        "Username", "estimation" will have the mistakes of key,
        in this case they have not updated!!!

        """
        headers = {"UserName": "******", "UserSecret": "456"}
        x = (
            ({
                "title": "Card 1",
                "board": "New board",
                "status": "Noooo",
                "description": "Need to check",
                "assignee": "Username",
                "estimation": "4w"
            }, {
                "status": "The card is created."
            }),
            ({
                "itle": "Card 1",
                "board": "New board",
                "status": "Noooo",
                "description": "Need to check",
                "assignee": "Username",
                "estimation": "4w"
            }, {
                "status": "Invalid request form 'data' of client."
            }),
            ({
                "title": "Card 1",
                "board": "Не известная доска",
                "status": "Noooo",
                "description": "Need to check",
                "assignee": "Username",
                "estimation": "4w"
            }, {
                "status":
                "The new card was don't created, such board no exist."
            }),
            ({
                "title": "Card 1",
                "board": "New board",
                "status": "Noooo",
                "description": "Need to check",
                "assignee": "Username",
                "estimation": "4w"
            }, {
                "status": "This a card already exist at this board."
            }),
            ({
                "title": "Card 1",
                "board": "New board",
                "status": "Noooo",
                "description": "Need to check",
                "assignee": "Username",
                "estimation": "4"
            }, {
                "status":
                "Invalid 'estimation'. Please repair the field 'estimation'."
            }),
            ({
                "title": "Card 1",
                "board": "New board",
                "status": "Noooo",
                "description": "Need to check",
                "assignee": "Username",
                "estimation": "4hd"
            }, {
                "status":
                "Invalid 'estimation'. Please repair the field 'estimation'."
            }),
        )
        for value in x:
            data, extended = value
            with app.test_client() as client:
                request = client.post('api/v1/card/create',
                                      headers=headers,
                                      json=data)
                with self.subTest(x=value):
                    self.assertEqual(request.json, extended)