コード例 #1
0
ファイル: abs-shadow-tests.py プロジェクト: timmc/kpawebgen
 def test_bail_on_bad_merge(self):
   """Must bail when md5/path pair matches differently on the two aspects."""
   self.cr_load("bad_merge")
   s = Shadow(self.loc_in_cr(shadow))
   r = Reader(self.loc_in_cr("KPA"))
   self.expect_error(lambda:s.apply_latest_data(r.read_latest_data(), 'fake'),
                     "Impossible to resolve",
                     "Bail on bad merge.")
コード例 #2
0
ファイル: abs-reader-tests.py プロジェクト: timmc/kpawebgen
  def test_read_standard(self):
    """Read a KPA database and check that the result makes sense."""
    self.cr_load("standard")
    sm = SettingsManager(self.loc_in_cr('kpawebgen.json'))
    r = Reader(sm.abspath('kpa_dir'))
    m = r.read_latest_data()

    self.assertEqual(7, len(m.images))
    beetle = (i for i in m.images if i['path'] == 'IMG_5179.JPG').next()
    beetle_tags = beetle['tags']
    del beetle['tags']
    beetle_timestamp = datetime.datetime(2009, 6, 25, 7, 45, 50)
    expected_beetle = {'imageID':None,
                       'md5':'34f7adfce54bd34bf5f0266dd2c7b800',
                       'path':'IMG_5179.JPG',
                       'width':800,
                       'height':600,
                       'angle':0,
                       'label':'IMG_5179',
                       'description':'Regular public.',
                       'stackOrder':None,
                       'stackID':None,
                       'startDate':beetle_timestamp,
                       'endDate':beetle_timestamp}
    self.assertEqual(beetle, expected_beetle)

    # next() throws if no match
    locat = (i for i in m.cats if i['catName'] == 'Location').next()
    inn_tag = (i for i in m.tags if i['tagName'] == 'Orange Hill Beach Inn' and
                                    i['catID'] == locat['catID']).next()
    island_tag = (i for i in m.tags
                          if i['catID'] == locat['catID'] and
                             i['tagName'] == 'San Salvador Island').next()
    
    self.assertEqual(11, len(beetle_tags)) # no inherit
    beetle_tags.index({'tagID':inn_tag['tagID'],
                       'catID':locat['catID']})

    self.assertEqual(3, len(m.tag_tags))
    m.tag_tags.index({'catID':locat['catID'],
                      'setID':island_tag['tagID'],
                      'tagID':inn_tag['tagID']})