Exemple #1
0
    def test_we_dont_lock_if_we_dont_want_to(self, mocklock, mockgetfirst):
        """ if everything goes well, return the image stream and the img_id"""
        mockgetfirst.return_value = "thiscouldbea.jpg"
        result = camup.acquire_a_picture(lockit=False)

        assert mockgetfirst.called is True
        assert mocklock.called is False
        self.assertEqual(("datastream", "thiscouldbea"), result)
Exemple #2
0
    def test_alright(self, mocklock, mockgetfirst):
        """ if everything goes well, return the image stream and the img_id"""
        mockgetfirst.return_value = "thiscouldbea.jpg"
        result = camup.acquire_a_picture()

        mocklock.assert_called_with("thiscouldbea.jpg")
        assert mockgetfirst.called is True
        self.assertEqual(("datastream", "thiscouldbea"), result)
    def test_alright(self,mocklock,mockgetfirst):
        """ if everything goes well, return the image stream and the img_id"""
        mockgetfirst.return_value = "thiscouldbea.jpg"
        result = camup.acquire_a_picture()

        mocklock.assert_called_with("thiscouldbea.jpg")
        assert mockgetfirst.called is True
        self.assertEqual(("datastream","thiscouldbea"), result)
    def test_we_dont_lock_if_we_dont_want_to(self,mocklock,mockgetfirst):
        """ if everything goes well, return the image stream and the img_id"""
        mockgetfirst.return_value = "thiscouldbea.jpg"
        result = camup.acquire_a_picture(lockit=False)

        assert mockgetfirst.called is True
        assert mocklock.called is False
        self.assertEqual(("datastream","thiscouldbea"), result)
Exemple #5
0
def get_image(picture = None):
    """
    plain and simple, get the last picture and send it to the client
    """
    try:
        img, img_id = acquire_a_picture(lockit=False, last=True)
    except AssertionError:
        return render_template("error.html"), 404

    picture_file = os.path.join(SAVE_FOLDER, "{0}.jpg".format(img_id) )
    return send_file(picture_file)