class TestFavoriteView(TestCase):

    """docstring for TestFavoriteView"""

    def setUp(self):
        # self.favorite = Favorite()

        self.busline = Busline()
        self.busline.line_number = "002"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.busline.save()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()

        # self.favorite.user = self.user
        # self.favorite.busline = self.busline
        # self.favorite.save()

    def test_get_favorite_add(self):
        self.toggle_favorite(self.user.username, self.busline.line_number)

    def test_get_favorite_un_favorite(self):
        self.toggle_favorite(self.user.username, self.busline.line_number)
        # second access to un-favorite
        self.toggle_favorite(self.user.username, self.busline.line_number)

    def toggle_favorite(self, username, line_number):
        response = self.client.get(
            "/favorite/?username="******"&line_number=" + line_number)
        code = response.status_code
        self.assertEquals(code, STATUS_OK)
Beispiel #2
0
class TestPostView(TestCase):
    """
    This test method is used for make the tests in changes on the posts
    and view results.
    """
    def setUp(self):
        self.post = Post()

        self.busline = Busline()
        self.busline.line_number = "001"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.busline.save()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()

        self.post.busline = self.busline
        self.post.traffic = 1
        self.post.capacity = 1
        self.post.user = self.user
        self.post.save()

    """
    This test method is used for analysis of method obtain the corrects
    posts.
    """

    def test_get(self):
        response = self.client.get("/posts/")
        code = response.status_code
        self.assertEquals(code, STATUS_OK)

    def test_get_post(self):
        post_id = self.post.id
        response = self.client.get("/posts/%s/" % str(post_id))
        code = response.status_code
        self.assertEquals(code, STATUS_OK)

    """
    This test method is used for analysis of method obtain the correct
    message when the terminal is null.
    """

    def test_get_post_null(self):
        response = self.client.get('\
            /posts/%s/' % (str(GENERIC_NOT_FOUND_ID)))
        code = response.status_code
        self.assertEquals(code, STATUS_NOT_FOUND)

    """
    This test method is used for analysis of method obtain the correct
    message when the post is not found.
    """

    def test_get_post_not_found(self):
        response = self.client.get("/posts/" + str(GENERIC_NOT_FOUND_ID) + "/")
        code = response.status_code
        self.assertEquals(code, STATUS_OK)
Beispiel #3
0
class TestFavoriteView(TestCase):
    """docstring for TestFavoriteView"""
    def setUp(self):
        # self.favorite = Favorite()

        self.busline = Busline()
        self.busline.line_number = "002"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.busline.save()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()

        # self.favorite.user = self.user
        # self.favorite.busline = self.busline
        # self.favorite.save()

    def test_get_favorite_add(self):
        self.toggle_favorite(self.user.username, self.busline.line_number)

    def test_get_favorite_un_favorite(self):
        self.toggle_favorite(self.user.username, self.busline.line_number)
        # second access to un-favorite
        self.toggle_favorite(self.user.username, self.busline.line_number)

    def toggle_favorite(self, username, line_number):
        response = self.client.get("/favorite/?username="******"&line_number=" + line_number)
        code = response.status_code
        self.assertEquals(code, STATUS_OK)
Beispiel #4
0
class TestFavorite(TestCase):

    """
    This test method is used for make the tests in changes on the favorites.
    """

    def setUp(self):
        self.favorite = Favorite()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()

        self.busline = Busline()
        self.busline.line_number = "001"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.terminal = Terminal(description="terminal")
        self.terminal.save()
        self.busline.save()

        self.favorite.user = self.user
        self.favorite.busline = self.busline
        self.favorite.save()

    def test_str(self):
        self.assertEquals(
            "testuser - 001", self.favorite.__str__())
Beispiel #5
0
    def setUp(self):
        # self.favorite = Favorite()

        self.busline = Busline()
        self.busline.line_number = "002"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.busline.save()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()
Beispiel #6
0
class TestPost(TestCase):

    """
    This test method is used for make the tests in changes on the post.
    """

    def setUp(self):
        self.post = Post()

        self.busline = Busline()
        self.busline.line_number = "001"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.busline.save()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()

        self.post.busline = self.busline
        self.post.traffic = 1
        self.post.capacity = 1
        self.post.user = self.user
        self.post.save()
        self.date_now = self.post.date
        self.time_now = self.post.time

    def test_str(self):
        self.assertEquals(
            "id: 1 date: %s %s busline_id: 1" % (self.date_now, self.time_now),
            self.post.__str__())

    def test_api_all(self):
        self.assertEquals(1, self.post.api_all().count())

    """
    This test method is used for make the tests in search of the official
    application and his relationship with API.
    """

    def test_api_filter_contains(self):
        busline = self.busline
        self.assertEquals(1, self.post.api_filter_contains(busline).count())

    """
    This test method is used for make the tests in catcher of the official
    application and converts to the API.
    """

    def test_api_get(self):
        post = self.post
        post_list = self.post.api_get(post.id)
        self.assertEquals("testuser", post_list.user.username)
Beispiel #7
0
    def setUp(self):
        self.post = Post()

        self.busline = Busline()
        self.busline.line_number = "001"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.busline.save()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()

        self.post.busline = self.busline
        self.post.traffic = 1
        self.post.capacity = 1
        self.post.user = self.user
        self.post.save()
Beispiel #8
0
    def setUp(self):
        self.favorite = Favorite()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()

        self.busline = Busline()
        self.busline.line_number = "001"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.terminal = Terminal(description="terminal")
        self.terminal.save()
        self.busline.save()

        self.favorite.user = self.user
        self.favorite.busline = self.busline
        self.favorite.save()
    def setUp(self):
        # self.favorite = Favorite()

        self.busline = Busline()
        self.busline.line_number = "002"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.busline.save()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()
Beispiel #10
0
 def setUp(self):
     self.client = Client()
     self.request = RequestFactory()
     self.busline = Busline()
     self.user = BusinemeUser()
     self.favorite = Favorite()
     self.busline.line_number = '001'
     self.busline.description = 'route'
     self.busline.route_size = 0.1
     self.busline.fee = 3.50
     self.busline.save()
     self.user = BusinemeUser.objects.create_user(username='******',
                                                  password='******')
    def setUp(self):
        self.post = Post()

        self.busline = Busline()
        self.busline.line_number = "001"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.busline.save()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()

        self.post.busline = self.busline
        self.post.traffic = 1
        self.post.capacity = 1
        self.post.user = self.user
        self.post.save()
class TestPostView(TestCase):

    """
    This test method is used for make the tests in changes on the posts
    and view results.
    """

    def setUp(self):
        self.post = Post()

        self.busline = Busline()
        self.busline.line_number = "001"
        self.busline.route_size = 0.1
        self.busline.fee = 3.50
        self.busline.save()

        self.user = BusinemeUser()
        self.user.username = "******"
        self.user.save()

        self.post.busline = self.busline
        self.post.traffic = 1
        self.post.capacity = 1
        self.post.user = self.user
        self.post.save()

    """
    This test method is used for analysis of method obtain the corrects
    posts.
    """

    def test_get(self):
        response = self.client.get("/posts/")
        code = response.status_code
        self.assertEquals(code, STATUS_OK)

    def test_get_post(self):
        post_id = self.post.id
        response = self.client.get("/posts/%s/" % str(post_id))
        code = response.status_code
        self.assertEquals(code, STATUS_OK)

    """
    This test method is used for analysis of method obtain the correct
    message when the terminal is null.
    """

    def test_get_post_null(self):
        response = self.client.get('\
            /posts/%s/' % (str(GENERIC_NOT_FOUND_ID)))
        code = response.status_code
        self.assertEquals(code, STATUS_NOT_FOUND)

    """
    This test method is used for analysis of method obtain the correct
    message when the post is not found.
    """

    def test_get_post_not_found(self):
        response = self.client.get(
            "/posts/" + str(GENERIC_NOT_FOUND_ID) + "/")
        code = response.status_code
        self.assertEquals(code, STATUS_OK)
Beispiel #13
0
def create_user(request):
    """PUT method for create an user by receiving
    four arguments from application."""

    new_user = BusinemeUser()
    new_user.username = request.POST['username']
    new_user.first_name = request.POST['first_name']
    new_user.last_name = request.POST['last_name']
    new_user.set_password(request.POST['password'])

    # Must check if the assertives is  write correcly and define a message
    # error for each one

    username = new_user.username
    first_name = new_user.first_name
    last_name = new_user.last_name

    new_user.assertEquals(username, None)
    new_user.assertEquals(first_name, None)
    new_user.assertEquals(last_name, None)

    new_user.assertEquals(username, '')
    new_user.assertEquals(first_name, '')
    new_user.assertEquals(last_name, '')

    new_user.save()