Пример #1
0
def test_maptags():
  twanagerutils.init(config)
  setup_testdata()
  twanagerutils.lowertags(["tmp"])
  twanagerutils.maptags(["tmp","cat=feline;kitty=feline;lion=feline;tiger=feline"])
  filtered_felines = list(control.filter_tiddlers_from_bag(store.get(Bag("tmp")),"select=tag:feline"))
  assert len(filtered_felines) is 6
Пример #2
0
def test_setfield():
  twanagerutils.init(config)
  setup_testdata()

  twanagerutils.setfield(["tmp","read","yes"])

  assert store.get(Tiddler("Ben","tmp")).fields["read"] == 'yes'
  assert store.get(Tiddler("Whiskers","tmp")).fields["read"] == 'yes'
Пример #3
0
def test_lowercase():
  twanagerutils.init(config)
  setup_testdata()   
  twanagerutils.lowertags(["tmp"])
  tid1 = store.get(Tiddler(u"Andrew","tmp"))
  
  assert tid1.tags == ['pet','animal','kitty','toysrus']
  assert store.get(Tiddler("Whiskers","tmp")).tags == ['i write like a five year old','kitty','pet','lolcat']
Пример #4
0
def test_nospacetags():
  twanagerutils.init(config)
  setup_testdata()

  twanagerutils.uppertags(["tmp"])
  twanagerutils.nospacetags(["tmp"])

  assert store.get(Tiddler("Ben","tmp")).tags == ['CAT','ILOVEMYCAT']
  assert store.get(Tiddler("Whiskers","tmp")).tags == ['IWRITELIKEAFIVEYEAROLD','KITTY','PET','LOLCAT']
Пример #5
0
def test_mapfield():
  twanagerutils.init(config)
  setup_testdata()    
  twanagerutils.mapfield(["tmp","badfield","ks","new ks"])
  tid1 = store.get(Tiddler(u"Andrew","tmp"))
  assert tid1.fields['badfield'] == 'z'
  
  tid1 = store.get(Tiddler(u"Chris","tmp"))
  assert tid1.fields['badfield'] == 'new ks'
Пример #6
0
def test_uppercase():
  twanagerutils.init(config)
  setup_testdata()


  twanagerutils.uppertags(["tmp"])
  tid1 = store.get(Tiddler(u"Andrew","tmp"))

  assert tid1.tags == ['PET','ANIMAL','KITTY','TOYSRUS']
  assert store.get(Tiddler("Whiskers","tmp")).tags == ['I WRITE LIKE A FIVE YEAR OLD','KITTY','PET','LOLCAT']
Пример #7
0
def test_removefield():
  twanagerutils.init(config)
  setup_testdata()

  twanagerutils.removefield(["tmp","badfield"])

  try:
    x = store.get(Tiddler("Ben","tmp")).fields["badfield"]
    assert True is False
  except KeyError:
    pass
Пример #8
0
def test_renamefield():
  twanagerutils.init(config)
  setup_testdata()

  twanagerutils.renamefield(["tmp","badfield","terriblefield"])

  x = store.get(Tiddler("Ben","tmp"))
  try:
    gone = x.fields["badfield"]
    assert False is True
  except KeyError:
    there = x.fields['terriblefield']
    assert there == 'z'
    pass
Пример #9
0
def test_removefieldwithvalue():
  twanagerutils.init(config)
  setup_testdata()

  twanagerutils.removefieldwithvalue(["tmp","badfield","zs"]) #only martin should match this

  x = store.get(Tiddler("Ben","tmp")).fields["badfield"]
  assert x =='z'
  
  tiddlers = store.get(Bag("tmp")).list_tiddlers()
  for tiddler in tiddlers:
    tiddler =store.get(tiddler)
    if tiddler.title == 'Martin':
      assert "badfield" not in tiddler.fields
    elif tiddler.title == 'Ben':
      assert tiddler.fields["badfield"] == u"z"
    else:
      assert "badfield" in tiddler.fields