Exemplo n.º 1
0
    def post(self, version):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        name = self.request.get('name', default_value=None)
        description = self.request.get('description', default_value=None)

        if not name or not description:
            self.error(400, "Bad Data: Name: %s, Description: %s" \
                           % (name, description))
            return

        slug = slugify.slugify(name)
        existing_s = Service.get_by_slug(slug)

        if existing_s:
            self.error(404, "A sevice with this name already exists")
            return

        s = Service(name=name, slug=slug, description=description)
        s.put()

        invalidate_cache()

        self.response.set_status(201)
        self.json(s.rest(self.base_url(version)))
Exemplo n.º 2
0
 def tnx(service_data, country_data, user):
     service = Service(key_name = u"<%s>" % service_data["id"])
     service.id = service_data["id"]
     service.user = user
     service.countries = json.dumps(country_data)
     service.put()
     pointer_to_service["service"] = service
Exemplo n.º 3
0
    def post(self, version):
        logging.debug("ServicesListHandler#post")

        if (self.valid_version(version)):

            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)

            if name and description:
                slug = slugify.slugify(name)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if existing_s:
                    existing_s.description = description
                    existing_s.put()
                    self.json(existing_s.rest(self.base_url(version)))
                # Create new service
                else:
                    s = Service(name=name, slug=slug, description=description)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
            else:
                self.error(
                    400, "Bad Data: Name: %s, Description: %s" %
                    (name, description))
        else:
            self.error(404, "API Version %s not supported" % version)
Exemplo n.º 4
0
    def post(self, version):
        logging.debug("ServicesListHandler#post")

        if (self.valid_version(version)):
            
            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)
            serviceurl = self.request.get('serviceurl', default_value=None)
            pattern = self.request.get('pattern', default_value=None)
            freq = self.request.get('freq', default_value=None)
            
            if name and description:
                slug = slugify.slugify(name)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if existing_s:
                    existing_s.description = description
                    existing_s.serviceurl = serviceurl
                    existing_s.pattern = pattern
                    existing_s.freq = freq
                    existing_s.put()
                    self.json(existing_s.rest(self.base_url(version)))
                # Create new service
                else:
                    s = Service(name=name, slug=slug, description=description, serviceurl=serviceurl)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
            else:
                self.error(400, "Bad Data: Name: %s, Description: %s" % (name, description))
        else:
            self.error(404, "API Version %s not supported" % version)
Exemplo n.º 5
0
    def post(self, version):
        logging.debug("ServicesListHandler#post")

        if (self.valid_version(version)):
            
            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)
            region = self.request.get('region', default_value=None)
            
            if name and description and region:
                slug = Service.slugify(name, region)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if existing_s:
                    existing_s.description = description
                    if region:
                        existing_s.region = Region.get_by_name(region)
                        existing_s.slug = Service.slugify(name, region)
                    existing_s.put()
                    self.json(existing_s.rest(self.base_url(version)))
                # Create new service
                else:
                    region = Region.get_by_name(region)
                    s = Service(name=name, slug=slug, description=description, region=region)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
            else:
                self.error(400, "Bad Data: Name: %s, Description: %s, Region: %s" % (name, description, region))
        else:
            self.error(404, "API Version %s not supported" % version)
Exemplo n.º 6
0
    def addservice_command(self, message=None):
        """Create a new service"""

        service_name = message.body.split(' ')[1]
        service = Service(key_name=service_name, name=service_name)
        service.put()

        message.reply("Added service %s" % service_name)
Exemplo n.º 7
0
class ServiceInstanceTest(StashboardTest):

    def setUp(self):
        super(ServiceInstanceTest, self).setUp()
        self.service = Service(name="Foo", slug="foo", description="foo")
        self.service.put()

    @patch("handlers.api.invalidate_cache")
    def test_delete_service(self, mock):
        response = self.delete("/admin/api/v1/services/foo")
        self.assertEquals(response.status_code, 200)

    def test_delete_wrong_service(self):
        response = self.delete("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_delete_wrong_version(self):
        response = self.delete("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_service(self):
        response = self.post("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_version(self):
        response = self.post("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_update_desc(self):
        response = self.post("/admin/api/v1/services/foo",
                data={"description": "hello"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = Service.get(self.service.key())
        self.assertEquals(service.description, "hello")

    def test_post_update(self):
        response = self.post("/admin/api/v1/services/foo",
            data={"name": "bar"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = Service.get(self.service.key())
        self.assertEquals(service.name, "bar")

    def test_get_wrong_service(self):
        response = self.get("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_get_wrong_version(self):
        response = self.get("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_get_service(self):
        response = self.get("/admin/api/v1/services/foo")
        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.headers["Content-Type"], "application/json")
Exemplo n.º 8
0
    def test_create_event(self):
        s = Service(slug=u"hey", name=u"you", description=u"lol")
        s.put()

        stat = Status(name=u"you", slug=u"leave", description=u"why",
                      image=u"cry")
        stat.put()

        e = Event(status=stat, service=s, message=u"¨¥¨œ∑´æ")
        e.put()

        data = e.rest("/api")
Exemplo n.º 9
0
    def test_create_event(self):
        s = Service(slug=u"hey", name=u"you", description=u"lol")
        s.put()

        stat = Status(name=u"you",
                      slug=u"leave",
                      description=u"why",
                      image=u"cry")
        stat.put()

        e = Event(status=stat, service=s, message=u"¨¥¨œ∑´æ")
        e.put()

        data = e.rest("/api")
Exemplo n.º 10
0
 def post(self):
     data = self.request.body
     temp = data
     s = Service()
     try:            
         s.category = temp['category']
         s.desc = temp['desc'] 
         s.extras = temp['extras']
         s.location = db.GeoPtProperty(temp['location'])
         s.mode = temp['mode']
         s.title = temp['title']            
     except:
         self.response.out.write('not registered due to technical difficulties')
     if s:
         s.put()
         self.restponse.out.write(s.title)
Exemplo n.º 11
0
    def post(self, version):
        if self.valid_version(version):

            name = self.request.get("name", default_value=None)
            description = self.request.get("description", default_value=None)

            if name and description:
                slug = slugify.slugify(name)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if not existing_s:
                    s = Service(name=name, slug=slug, description=description)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
                else:
                    self.error(404, "A sevice with this name already exists")
            else:
                self.error(400, "Bad Data: Name: %s, Description: %s" % (name, description))
        else:
            self.error(404, "API Version %s not supported" % version)
Exemplo n.º 12
0
    def post(self, version):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        name = self.request.get('name', default_value=None)
        description = self.request.get('description', default_value=None)
        slist = self.request.get('list', default_value=None)
        l = None

        if slist:
            l = List.all().filter("slug =", slist).get()

        if not name:
            self.error(400, "Bad name: %s" % name)
            return

        if not description:
            self.error(400, "Bad description: %s" % description)
            return

        if slist and not l:
            self.error(400, "Bad list slug: %s" % slist)
            return

        slug = slugify.slugify(name)
        existing_s = Service.get_by_slug(slug)

        if existing_s:
            self.error(404, "A sevice with this name already exists")
            return

        s = Service(name=name, slug=slug, description=description, list=l)
        s.put()

        invalidate_cache()

        self.response.set_status(201)
        self.json(s.rest(self.base_url(version)))
Exemplo n.º 13
0
    def post(self, version):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        name = self.request.get('name', default_value=None)
        description = self.request.get('description', default_value=None)
        slist = self.request.get('list', default_value=None)
        l = None

        if slist:
            l = List.all().filter("slug =", slist).get()

        if not name:
            self.error(400, "Bad name: %s" % name)
            return

        if not description:
            self.error(400, "Bad description: %s" % description)
            return

        if slist and not l:
            self.error(400, "Bad list slug: %s" % slist)
            return

        slug = slugify.slugify(name)
        existing_s = Service.get_by_slug(slug)

        if existing_s:
            self.error(404, "A sevice with this name already exists")
            return

        s = Service(name=name, slug=slug, description=description, list=l)
        s.put()

        invalidate_cache()

        self.response.set_status(201)
        self.json(s.rest(self.base_url(version)))
Exemplo n.º 14
0
    def post(self, version):
        if (self.valid_version(version)):

            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)

            if name and description:
                slug = slugify.slugify(name)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if not existing_s:
                    s = Service(name=name, slug=slug, description=description)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
                else:
                    self.error(404, "A sevice with this name already exists")
            else:
                self.error(
                    400, "Bad Data: Name: %s, Description: %s" %
                    (name, description))
        else:
            self.error(404, "API Version %s not supported" % version)
Exemplo n.º 15
0
 def test_create_service(self):
     s = Service(slug=u"Ð", name=u"µ", description=u"À")
     s.put()
     data = s.rest("/api")
Exemplo n.º 16
0
from google.appengine.ext import db
from models import Status, Service, Event
from datetime import datetime, timedelta, date

# Create the default statuses
Status.install_defaults()

# Create Services
service = {
    "name": "Service Foo",
    "slug": "service-foo",
    "description": "Scalable and reliable foo service across the globe",
    }

services = []
for i in "ABCDEFGHIJ":
    foo = Service(name=service["name"] + i, slug=service["slug"] + i,
                  description=service["description"])
    foo.put()
    services.append(foo)


# Given one service a bunch of events
foo = services[0]

bad = Status.get_by_slug("down")

for i in range(10):
    Event(service=foo, status=bad, message="Event %s" % i).put()
Exemplo n.º 17
0
class ServiceInstanceTest(StashboardTest):
    def setUp(self):
        super(ServiceInstanceTest, self).setUp()
        self.service_list = List(slug="foo", name="Foo", description="Bar")
        self.service_list.put()
        self.service = Service(name="Foo", slug="foo", description="foo")
        self.service.put()

    @patch("handlers.api.invalidate_cache")
    def test_delete_service(self, mock):
        response = self.delete("/admin/api/v1/services/foo")
        self.assertEquals(response.status_code, 200)

    def test_delete_wrong_service(self):
        response = self.delete("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_delete_wrong_version(self):
        response = self.delete("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_service(self):
        response = self.post("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_version(self):
        response = self.post("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_update_list(self):
        response = self.post("/admin/api/v1/services/foo",
                             data={"list": "foo"})

        print response.content

        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = Service.get(self.service.key())
        self.assertEquals(service.list.name, "Foo")

    def test_post_update_desc(self):
        response = self.post("/admin/api/v1/services/foo",
                             data={"description": "hello"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = Service.get(self.service.key())
        self.assertEquals(service.description, "hello")

    def test_post_update(self):
        response = self.post("/admin/api/v1/services/foo",
                             data={"name": "bar"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = Service.get(self.service.key())
        self.assertEquals(service.name, "bar")

    def test_get_wrong_service(self):
        response = self.get("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_get_wrong_version(self):
        response = self.get("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_get_service(self):
        response = self.get("/admin/api/v1/services/foo")
        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.headers["Content-Type"], "application/json")
Exemplo n.º 18
0
from google.appengine.ext import db
from models import Status, Service, Event
from datetime import datetime, timedelta, date

# Create the default statuses
Status.install_defaults()

# Create Services
service = {
    "name": "Service Foo",
    "slug": "service-foo",
    "description": "Scalable and reliable foo service across the globe",
}

services = []
for i in "ABCDEFGHIJ":
    foo = Service(name=service["name"] + i,
                  slug=service["slug"] + i,
                  description=service["description"])
    foo.put()
    services.append(foo)

# Given one service a bunch of events
foo = services[0]

bad = Status.get_by_slug("down")

for i in range(10):
    Event(service=foo, status=bad, message="Event %s" % i).put()
Exemplo n.º 19
0
 def test_create_service(self):
     s = Service(slug=u"Ð", name=u"µ", description=u"À")
     s.put()
     data = s.rest("/api")
Exemplo n.º 20
0
class ServiceListInstanceTest(StashboardTest):
    def setUp(self):
        super(ServiceListInstanceTest, self).setUp()
        self.service_list = List(slug="foo", name="Foo", description="Bar")
        self.service_list.put()
        self.service = Service(list=self.service_list,
                               name="Foo",
                               slug="foo",
                               description="foo")
        self.service.put()

    def test_resource_url(self):
        service_list = List(slug="foo", name="Foo", description="Bar")
        self.assertEquals(service_list.resource_url(), "/service-lists/foo")

    def test_url(self):
        service_list = List(slug="foo", name="Foo", description="Bar")
        self.assertEquals(service_list.url(), "/service-lists/foo")

    def test_delete_wrong_service(self):
        response = self.delete("/admin/api/v1/service-lists/bar")
        self.assertEquals(response.status_code, 404)

    def test_delete_wrong_version(self):
        response = self.delete("/admin/api/foo/service-lists/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_service(self):
        response = self.post("/admin/api/v1/service-lists/bar")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_version(self):
        response = self.post("/admin/api/foo/service-lists/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_update_desc(self):
        response = self.post("/admin/api/v1/service-lists/foo",
                             data={"description": "hello"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = List.get(self.service_list.key())
        self.assertEquals(service.description, "hello")

    def test_post_update(self):
        response = self.post("/admin/api/v1/service-lists/foo",
                             data={"name": "bar"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = List.get(self.service_list.key())
        self.assertEquals(service.name, "bar")

    def test_get_wrong_service(self):
        response = self.get("/admin/api/v1/service-lists/bar")
        self.assertEquals(response.status_code, 404)

    def test_get_wrong_version(self):
        response = self.get("/admin/api/foo/service-lists/foo")
        self.assertEquals(response.status_code, 404)

    def test_get_service_list(self):
        response = self.get("/admin/api/v1/service-lists/foo")
        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.headers["Content-Type"], "application/json")
Exemplo n.º 21
0
class ServiceListInstanceTest(StashboardTest):

    def setUp(self):
        super(ServiceListInstanceTest, self).setUp()
        self.service_list = List(slug="foo", name="Foo", description="Bar")
        self.service_list.put()
        self.service = Service(list=self.service_list, name="Foo", slug="foo",
                               description="foo")
        self.service.put()

    def test_resource_url(self):
        service_list = List(slug="foo", name="Foo", description="Bar")
        self.assertEquals(service_list.resource_url(), "/service-lists/foo")

    def test_url(self):
        service_list = List(slug="foo", name="Foo", description="Bar")
        self.assertEquals(service_list.url(), "/service-lists/foo")

    def test_delete_wrong_service(self):
        response = self.delete("/admin/api/v1/service-lists/bar")
        self.assertEquals(response.status_code, 404)

    def test_delete_wrong_version(self):
        response = self.delete("/admin/api/foo/service-lists/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_service(self):
        response = self.post("/admin/api/v1/service-lists/bar")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_version(self):
        response = self.post("/admin/api/foo/service-lists/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_update_desc(self):
        response = self.post("/admin/api/v1/service-lists/foo",
                data={"description": "hello"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = List.get(self.service_list.key())
        self.assertEquals(service.description, "hello")

    def test_post_update(self):
        response = self.post("/admin/api/v1/service-lists/foo",
                    data={"name": "bar"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = List.get(self.service_list.key())
        self.assertEquals(service.name, "bar")

    def test_get_wrong_service(self):
        response = self.get("/admin/api/v1/service-lists/bar")
        self.assertEquals(response.status_code, 404)

    def test_get_wrong_version(self):
        response = self.get("/admin/api/foo/service-lists/foo")
        self.assertEquals(response.status_code, 404)

    def test_get_service_list(self):
        response = self.get("/admin/api/v1/service-lists/foo")
        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.headers["Content-Type"], "application/json")
Exemplo n.º 22
0
class HistoryTest(TestbedTest):
    def setUp(self):
        super(HistoryTest, self).setUp()
        Status.load_defaults()
        self.service = Service(slug="account",
                               name="Account",
                               description="The BEST SERVICE")
        self.service.put()

    def test_history_order(self):
        start = date(2011, 4, 13)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)
        self.assertEquals(len(history), 5)

        history_days = [h["day"] for h in history]
        expected = [
            date(2011, 4, 12),
            date(2011, 4, 11),
            date(2011, 4, 10),
            date(2011, 4, 9),
            date(2011, 4, 8),
        ]

        self.assertEquals(history_days, expected)

    def test_history_order_early_month(self):
        start = date(2011, 4, 2)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)

        history_days = [h["day"] for h in history]
        expected = [
            date(2011, 4, 1),
            date(2011, 3, 31),
            date(2011, 3, 30),
            date(2011, 3, 29),
            date(2011, 3, 28),
        ]

        self.assertEquals(history_days, expected)

        for h in history:
            self.assertFalse(h["information"])

    def test_history_order_late_month(self):
        start = date(2011, 4, 5)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)

        history_days = [h["day"] for h in history]
        expected = [
            date(2011, 4, 4),
            date(2011, 4, 3),
            date(2011, 4, 2),
            date(2011, 4, 1),
            date(2011, 3, 31),
        ]

        self.assertEquals(history_days, expected)

    def test_history_no_errors_boundary(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 5)
        event = Event(status=down,
                      service=self.service,
                      start=now,
                      message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))
        self.assertEquals(history[0]["information"], False)

    def test_history_one_error(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 4, 12)
        event = Event(status=down,
                      service=self.service,
                      start=now,
                      message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))

        self.assertEquals(history[0]["information"], True)
        self.assertEquals(history[0]["name"], "information")

    def test_history_one_error_boundary(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 3, 31)
        event = Event(status=down,
                      service=self.service,
                      start=now,
                      message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))

        self.assertEquals(history[4]["information"], True)
        self.assertEquals(history[4]["name"], "information")

    def test_history_count(self):
        up = Status.get_by_slug("up")
        history = self.service.history(10, up, start=date(2011, 4, 5))
        self.assertEquals(len(history), 10)

    def test_history_current_status(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 4, 12, 51)
        event = Event(status=down,
                      service=self.service,
                      start=now,
                      message="HEY")
        event.put()

        history, = self.service.history(1, up, start=date(2011, 4, 5))

        self.assertEquals(history["information"], True)
Exemplo n.º 23
0
# THE SOFTWARE.

from google.appengine.ext import db
from models import Status, Service, Event, Region
from datetime import datetime, timedelta, date

na = Region(name="North America")
na.put()

emea = Region(name="EMEA")
emea.put()

foo = Service(name="Service Foo", slug="service-foo", region=na,
              description="Scalable and reliable foo service across the globe")
foo.slug = Service.slugify(foo.name, foo.region.name)
foo.put()

bar = Service(name="Service Bar", slug="service-bar", region=emea,
             description="Scalable and reliable foo service")
bar.slug = Service.slugify(bar.name, bar.region.name)
bar.put()

delete = Service(name="Delete Me", slug="delete", region=na,
                description="Delete Me Please")
delete.slug = Service.slugify(delete.name, delete.region.name)
delete.put()

bar = Service.get_by_slug("emea-service-bar")
cat = Status.get_by_slug("down")        

dates = [
Exemplo n.º 24
0
class HistoryTest(TestbedTest):

    def setUp(self):
        super(HistoryTest, self).setUp()
        Status.load_defaults()
        self.service = Service(slug="account", name="Account",
                               description="The BEST SERVICE")
        self.service.put()

    def test_history_order(self):
        start = date(2011, 4, 13)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)
        self.assertEquals(len(history), 5)

        history_days = [ h["day"] for h in history ]
        expected = [
            date(2011, 4, 12),
            date(2011, 4, 11),
            date(2011, 4, 10),
            date(2011, 4, 9),
            date(2011, 4, 8),
            ]

        self.assertEquals(history_days, expected)

    def test_history_order_early_month(self):
        start = date(2011, 4, 2)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)

        history_days = [ h["day"] for h in history ]
        expected = [
            date(2011, 4, 1),
            date(2011, 3, 31),
            date(2011, 3, 30),
            date(2011, 3, 29),
            date(2011, 3, 28),
            ]

        self.assertEquals(history_days, expected)

        for h in history:
            self.assertFalse(h["information"])


    def test_history_order_late_month(self):
        start = date(2011, 4, 5)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)

        history_days = [ h["day"] for h in history ]
        expected = [
            date(2011, 4, 4),
            date(2011, 4, 3),
            date(2011, 4, 2),
            date(2011, 4, 1),
            date(2011, 3, 31),
            ]

        self.assertEquals(history_days, expected)

    def test_history_no_errors_boundary(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 5)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))
        self.assertEquals(history[0]["information"], False)

    def test_history_one_error(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 4, 12)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))

        self.assertEquals(history[0]["information"], True)
        self.assertEquals(history[0]["name"], "information")

    def test_history_one_error_boundary(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 3, 31)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))

        self.assertEquals(history[4]["information"], True)
        self.assertEquals(history[4]["name"], "information")

    def test_history_count(self):
        up = Status.get_by_slug("up")
        history = self.service.history(10, up, start=date(2011, 4, 5))
        self.assertEquals(len(history), 10)

    def test_history_current_status(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 4, 12, 51)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history, = self.service.history(1, up, start=date(2011, 4, 5))

        self.assertEquals(history["information"], True)