Ejemplo n.º 1
0
    def test_get_skill_not_exist(self, mock_get_skill, mock_abort):
        """Api should return information about skill."""
        mock_get_skill.return_value = None
        Skill.get(1)

        mock_abort.assert_called_once_with(404,
                                           message="No such skill with ID=1")
Ejemplo n.º 2
0
    def test_put_skill_wrong_json(self, mock_abort):
        """Api should return information about skill."""
        with app.test_request_context(json=self.wrong_json):
            Skill.put(1)

            mock_abort.assert_called_once_with(404,
                                               message=self.wrong_json_msg)
Ejemplo n.º 3
0
    def test_put_skill_not_valid(self, mock_abort):
        """Api should return information about skill."""
        with app.test_request_context(json=self.post_invalid_data):
            Skill.put(1)

            mock_abort.assert_called_once_with(404,
                                               message=self.not_valid_json_msg)
Ejemplo n.º 4
0
    def test_put_skill_fail(self, mock_update, mock_abort):
        """Api should return information about skill."""
        with app.test_request_context(json=self.post_valid_data):
            mock_update.return_value = False
            Skill.put(1)

            mock_abort.assert_called_once_with(404,
                                               message=self.update_fail_msg)
Ejemplo n.º 5
0
    def test_put_skill_success(self, mock_update):
        """Api should return information about skill."""
        with app.test_request_context(json=self.post_valid_data):

            mock_update.return_value = True
            response = Skill.put(1)

            self.assertEqual(response.status_code, 201)
            self.assertEqual(response.json['message'], self.update_success_msg)
Ejemplo n.º 6
0
    def test_get_skill(self, mock_get_skill):
        """Api should return information about skill."""
        mock_get_skill.return_value = self.valid_test_data[0]
        response = Skill.get(1)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.json['id'], self.valid_test_data[0]['id'])
        self.assertEqual(response.json['name'],
                         self.valid_test_data[0]['name'])
Ejemplo n.º 7
0
    def test_get_skill_wrong_id_case2(self, mock_abort):
        """Api should return information about skill."""
        Skill.get(-1)

        mock_abort.assert_called_once_with(404,
                                           message="No such skill with ID=-1")