Ejemplo n.º 1
0
 def test_json_product_list(self):
     """
     When listing product endpoints, the resulting JSON should contain a
     service object, and a workspace object, and within that, an array of
     product descriptors.
     """
     cf = cloudfeeds.CloudFeeds(tenant_id='1234', clock=None)
     cf.register_product(title="The hoohaw product", href="hoohaw")
     cf.register_product(title="The goober product", href="goober")
     listing = MatchesDict({
         "service": MatchesDict({
             "workspace": MatchesSetwise(
                 MatchesDict({
                     "collection": MatchesDict({
                         "href": Equals("hoohaw"),
                         "title": Equals("The hoohaw product"),
                     }),
                     "title": Equals("The hoohaw product"),
                 }),
                 MatchesDict({
                     "collection": MatchesDict({
                         "href": Equals("goober"),
                         "title": Equals("The goober product"),
                     }),
                     "title": Equals("The goober product"),
                 }),
             ),
         })
     })
     self.assertEquals(
         listing.match(cloudfeeds.render_product_endpoints_dict(
             cf.get_product_endpoints()
         )),
         None
     )
Ejemplo n.º 2
0
 def test_json_description(self):
     """
     When listing product endpoints, we expect our JSON to look a certain
     way.  The easiest way to do that is to acquire the corresponding
     dict, then pass it through json.dump with your preferred formatting
     settings.
     """
     cfp = cloudfeeds.CloudFeedsProduct(title='title', href='href')
     d = cloudfeeds.render_product_dict(cfp)
     productDescription = MatchesDict({
         "title": Equals("title"),
         "collection": MatchesDict({
             "href": Equals("href"),
             "title": Equals("title"),
         }),
     })
     self.assertEquals(productDescription.match(d), None)
Ejemplo n.º 3
0
 def test_json_description(self):
     """
     When listing product endpoints, we expect our JSON to look a certain
     way.  The easiest way to do that is to acquire the corresponding
     dict, then pass it through json.dump with your preferred formatting
     settings.
     """
     cfp = cloudfeeds.CloudFeedsProduct(title='title', href='href')
     d = cloudfeeds.render_product_dict(cfp)
     productDescription = MatchesDict({
         "title":
         Equals("title"),
         "collection":
         MatchesDict({
             "href": Equals("href"),
             "title": Equals("title"),
         }),
     })
     self.assertEquals(productDescription.match(d), None)
Ejemplo n.º 4
0
 def test_json_product_list(self):
     """
     When listing product endpoints, the resulting JSON should contain a
     service object, and a workspace object, and within that, an array of
     product descriptors.
     """
     cf = cloudfeeds.CloudFeeds(tenant_id='1234', clock=None)
     cf.register_product(title="The hoohaw product", href="hoohaw")
     cf.register_product(title="The goober product", href="goober")
     listing = MatchesDict({
         "service":
         MatchesDict({
             "workspace":
             MatchesSetwise(
                 MatchesDict({
                     "collection":
                     MatchesDict({
                         "href": Equals("hoohaw"),
                         "title": Equals("The hoohaw product"),
                     }),
                     "title":
                     Equals("The hoohaw product"),
                 }),
                 MatchesDict({
                     "collection":
                     MatchesDict({
                         "href": Equals("goober"),
                         "title": Equals("The goober product"),
                     }),
                     "title":
                     Equals("The goober product"),
                 }),
             ),
         })
     })
     self.assertEquals(
         listing.match(
             cloudfeeds.render_product_endpoints_dict(
                 cf.get_product_endpoints())), None)